diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-10-24 16:17:28 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-10-28 05:22:52 +0000 |
commit | e3d21ef0bf11ea6ddb154490eec6b76b36df3e73 (patch) | |
tree | 7dd199ba40888069110552a641520b414044708b /src/plugins/platforms/cocoa/qcocoawindow.h | |
parent | 8a49b314e3566615cbf000b7914efda6e268b6f8 (diff) |
macOS: Remove m_isNSWindowChild in favor of m_view.window.parentWindow
Instead of manually maintaining the m_isNSWindowChild state, a new function
has been introduced, isChildNSWindow(), which evaluates the condition based
on whether or not m_view.window has a parent NSWindow.
To achieve this, the recreateWindow() function was refactored to make it the
sole point of deciding whether or not a reconfigure is needed, instead of
having the logic partily at the call sites. That means the shouldUsePanel()
and isNativeWindowTypeInconsistent() functions are no longer needed.
QNSWindowHelper is only used for QNSWindow and QNSPanel, and m_isNSWindowChild
is only set if the window has a parent (and child NSWindows was explicitly
enabled), so we can use the normal QWindow topLevel logic.
There's more potential for cleanup in recreateWindowIfNeeded(), but that's
for later patches to keep this patch as small as possible.
Verified NSWindowChild use-case with windowchildgeometry manual test.
Change-Id: I34e8ca0cc2f8a1c399cc72691d66e09fab843f4d
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.h')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 0f5b3841f7..7cf6621964 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -257,18 +257,31 @@ public: static QPoint bottomLeftClippedByNSWindowOffsetStatic(QWindow *window); QPoint bottomLeftClippedByNSWindowOffset() const; + + enum RecreationReason { + RecreationNotNeeded = 0, + ParentChanged = 0x1, + MissingWindow = 0x2, + WindowModalityChanged = 0x4, + ChildNSWindowChanged = 0x8, + ContentViewChanged = 0x10, + PanelChanged = 0x20, + }; + Q_DECLARE_FLAGS(RecreationReasons, RecreationReason) + Q_FLAG(RecreationReasons) + protected: - void recreateWindow(); - QCocoaNSWindow *createNSWindow(); + bool isChildNSWindow() const; + bool isContentView() const; - bool shouldUseNSPanel(); + void recreateWindowIfNeeded(); + QCocoaNSWindow *createNSWindow(bool shouldBeChildNSWindow, bool shouldBePanel); QRect nativeWindowGeometry() const; QCocoaWindow *parentCocoaWindow() const; void syncWindowState(Qt::WindowState newState); void reinsertChildWindow(QCocoaWindow *child); void removeChildWindow(QCocoaWindow *child); - bool isNativeWindowTypeInconsistent(); // private: public: // for QNSView @@ -286,7 +299,6 @@ public: // for QNSView bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy QCocoaWindow *m_parentCocoaWindow; - bool m_isNSWindowChild; // this window is a non-top level QWindow with a NSWindow. QList<QCocoaWindow *> m_childWindows; Qt::WindowFlags m_windowFlags; |