From ef32f16fc284e5017da6016f72a17957fa2fef34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 6 Feb 2017 15:28:23 +0100 Subject: macOS: Rewrite window state handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of relying on specific notifications to change the window state we now evaluate the state based on the current window state. This allows us to get rid of windowShouldZoom in the window delegate, making window state handling work for foreign windows as well, and also allows us to re-evaluate the state in more places, such as when moving a window, which may bring it out of maximized state. The full screen state is tracked by a helper category that doesn't just rely on the styleFlag, but also on the full screen notifications. This is needed as macOS will complain if you try to go in or out of fullscreen while a transition is in effect. The differentiation between performFoo: and foo: has been removed, as the latter works in both cases and doesn't rely on the button being visible/enabled. These changes fixes many observed quirks in the window state handling that also resulted in making it hard to write tests that relied on the fullscreen/maximized operations always working. Change-Id: I0538c42d9223a56f20ec9156f4939288e0750552 Reviewed-by: Timur Pocheptsov Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/cocoa/qcocoawindow.h') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index b057299d0e..f60597fe42 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -217,7 +217,7 @@ public: bool windowShouldClose(); bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const; - void handleWindowStateChanged(Qt::WindowState); + void reportCurrentWindowState(bool unconditionally = false); NSInteger windowLevel(Qt::WindowFlags flags); NSUInteger windowStyleMask(Qt::WindowFlags flags); @@ -284,10 +284,15 @@ protected: QCocoaNSWindow *createNSWindow(bool shouldBeChildNSWindow, bool shouldBePanel); QRect nativeWindowGeometry() const; - void syncWindowState(Qt::WindowState newState); void reinsertChildWindow(QCocoaWindow *child); void removeChildWindow(QCocoaWindow *child); + Qt::WindowState windowState() const; + void applyWindowState(Qt::WindowState newState); + void toggleMaximized(); + void toggleFullScreen(); + bool isTransitioningToFullScreen() const; + // private: public: // for QNSView friend class QCocoaBackingStore; @@ -304,8 +309,7 @@ public: // for QNSView bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy Qt::WindowFlags m_windowFlags; - bool m_effectivelyMaximized; - Qt::WindowState m_synchedWindowState; + Qt::WindowState m_lastReportedWindowState; Qt::WindowModality m_windowModality; QPointer m_enterLeaveTargetWindow; bool m_windowUnderMouse; @@ -339,11 +343,6 @@ public: // for QNSView int m_topContentBorderThickness; int m_bottomContentBorderThickness; - // used by showFullScreen in fake mode - QRect m_normalGeometry; - Qt::WindowFlags m_oldWindowFlags; - NSApplicationPresentationOptions m_presentationOptions; - struct BorderRange { BorderRange(quintptr i, int u, int l) : identifier(i), upper(u), lower(l) { } quintptr identifier; -- cgit v1.2.3