14#include <QtGui/private/qwindow_p.h>
15#include <qpa/qplatformintegration.h>
18#import <QuartzCore/CAEAGLLayer.h>
22#import <QuartzCore/CAMetalLayer.h>
38 m_view = [[QUIMetalView alloc] initWithQIOSWindow:
this];
41 m_view = [[
QUIView alloc] initWithQIOSWindow:
this];
62 dispatch_async(dispatch_get_main_queue(), ^{
75 [m_view touchesCancelled:[NSSet
set] withEvent:0];
79 m_view.platformWindow = 0;
80 [m_view removeFromSuperview];
87 return window()->requestedFormat();
91bool QIOSWindow::blockedByModal()
94 return modalWindow && modalWindow !=
window();
99 m_view.hidden = !visible;
100 [m_view setNeedsDisplay];
110 if (blockedByModal()) {
119 }
else if (!visible && [m_view isActiveWindow]) {
122 NSArray<UIView *> *subviews = m_view.viewController.view.subviews;
123 for (
int i =
int(subviews.count) - 1;
i >= 0; --
i) {
124 UIView *
view = [subviews objectAtIndex:
i];
129 if (!
w || !
w->isTopLevel())
144 if (![m_view canBecomeFirstResponder])
161 m_normalGeometry =
rect;
168 [m_view setNeedsLayout];
179 [m_view layoutIfNeeded];
188void QIOSWindow::applyGeometry(
const QRect &
rect)
196 m_view.frame =
rect.toCGRect();
200 [m_view setNeedsLayout];
203 [m_view layoutIfNeeded];
208 UIEdgeInsets safeAreaInsets = m_view.qt_safeAreaInsets;
209 return QMargins(safeAreaInsets.left, safeAreaInsets.top,
210 safeAreaInsets.right, safeAreaInsets.bottom);
227 [m_view.qtViewController updateProperties];
230 applyGeometry(
QRect());
239 QRect uiWindowBounds = QRectF::fromCGRect(m_view.window.bounds).toRect();
245 applyGeometry(fullscreenGeometry);
247 applyGeometry(maximizedGeometry);
249 applyGeometry(m_normalGeometry);
255 UIView *parentView = parentWindow ?
reinterpret_cast<UIView *
>(parentWindow->
winId())
258 [parentView addSubview:m_view];
266 if (blockedByModal())
270 [m_view.window makeKeyWindow];
271 [m_view becomeFirstResponder];
273 if (
window()->isTopLevel())
277void QIOSWindow::raiseOrLower(
bool raise)
284 NSArray<UIView *> *subviews = m_view.superview.subviews;
285 if (subviews.count == 1)
288 for (
int i =
int(subviews.count) - 1;
i >= 0; --
i) {
289 UIView *
view =
static_cast<UIView *
>([subviews objectAtIndex:
i]);
294 [m_view.superview insertSubview:m_view aboveSubview:
view];
298 [m_view.superview insertSubview:m_view atIndex:0];
301void QIOSWindow::updateWindowLevel()
309 else if (
window()->isModal())
322 QIOSWindow *transientParentWindow = transientParent ?
static_cast<QIOSWindow *
>(transientParent->handle()) : 0;
323 if (transientParentWindow)
324 m_windowLevel =
qMax(transientParentWindow->m_windowLevel, m_windowLevel);
334 [m_view.qtViewController updateProperties];
340 [m_view sendUpdatedExposeEvent];
345 return m_view.contentScaleFactor;
359CAEAGLLayer *QIOSWindow::eaglLayer()
const
361 Q_ASSERT([m_view.layer isKindOfClass:[CAEAGLLayer class]]);
362 return static_cast<CAEAGLLayer *
>(m_view.layer);
366#ifndef QT_NO_DEBUG_STREAM
381#include "moc_qioswindow.cpp"
static QWindow * modalWindow()
Returns the most recently shown modal window.
void applicationStateChanged(Qt::ApplicationState state)
QIOSWindow(QWindow *window)
bool shouldAutoActivateWindow() const
void handleContentOrientationChange(Qt::ScreenOrientation orientation) override
Handle changes to the orientation of the platform window's contents.
void setParent(const QPlatformWindow *window) override
This function is called to enable native child window in QPA.
void clearAccessibleCache()
void setWindowState(Qt::WindowStates state) override
Requests setting the window state of this surface to type.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
void requestUpdate() override
Requests an QEvent::UpdateRequest event.
void setOpacity(qreal level) override
Reimplement to be able to let Qt set the opacity level of a window.
qreal devicePixelRatio() const override
Reimplement this function in subclass to return the device pixel ratio for the window.
bool isExposed() const override
Returns if this window is exposed in the windowing system.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
QMargins safeAreaMargins() const override
The safe area margins of a window represent the area that is safe to place content within,...
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
QSurfaceFormat format() const override
Returns the actual surface format of the window.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
\inmodule QtCore\reentrant
constexpr bool isEmpty() const noexcept
Returns true if the rectangle is empty, otherwise returns false.
QRect intersected(const QRect &other) const noexcept
Qt::ScreenOrientation contentOrientation
Qt::WindowStates windowState
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState=-1)
Qt::WindowFlags flags
the window flags of the window
SurfaceType surfaceType() const override
Returns the surface type of the window.
Qt::ScreenOrientation contentOrientation
the orientation of the window's contents
qreal opacity
The opacity of the window in the windowing system.
Combined button and popup list for selecting options.
@ MaximizeUsingFullscreenGeometryHint
QDebug operator<<(QDebug debug, const QIOSWindow *window)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
Q_GUI_EXPORT QWindowPrivate * qt_window_private(QWindow *window)
QFuture< QSet< QChar > > set
[10]
QT_BEGIN_NAMESPACE bool toBool(const QString &str)