summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-01-25 12:58:29 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2017-02-11 21:48:45 +0000
commit0b18d51b89d49d0c6f26de45ecc415ba540930e5 (patch)
tree0cba56019ffe3b7558fb3bf722cff488937251f6 /src/plugins/platforms/cocoa/qcocoawindow.mm
parentfa3dca176e03b39e982c5aff7a68850140c52507 (diff)
macOS: Handle window state changes directly in QCocoaWindow
Now that notification callbacks are delivered directly to QCocoaWindow, it doesn't make sense to then send them to QPA via QNSView. By skipping the QNSView roundtrip we also enable window state notifications for foreign windows. As an optimization we no longer flush all window system events, but use the new synchronous API to deliver the window state change event. Change-Id: I529b625fbe22e664c34a51bcd4448d1bf0392e6b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 114efc3e92..2c4c06fdbc 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -1282,7 +1282,7 @@ void QCocoaWindow::windowDidEndLiveResize()
{
if (m_synchedWindowState == Qt::WindowMaximized && ![m_nsWindow isZoomed]) {
m_effectivelyMaximized = false;
- [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowNoState];
+ handleWindowStateChanged(Qt::WindowNoState);
}
}
@@ -1320,22 +1320,22 @@ void QCocoaWindow::windowDidResignKey()
void QCocoaWindow::windowDidMiniaturize()
{
- [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowMinimized];
+ handleWindowStateChanged(Qt::WindowMinimized);
}
void QCocoaWindow::windowDidDeminiaturize()
{
- [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowNoState];
+ handleWindowStateChanged(Qt::WindowNoState);
}
void QCocoaWindow::windowDidEnterFullScreen()
{
- [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowFullScreen];
+ handleWindowStateChanged(Qt::WindowFullScreen);
}
void QCocoaWindow::windowDidExitFullScreen()
{
- [qnsview_cast(m_view) notifyWindowStateChanged:Qt::WindowNoState];
+ handleWindowStateChanged(Qt::WindowNoState);
}
void QCocoaWindow::windowDidOrderOffScreen()
@@ -1399,12 +1399,6 @@ bool QCocoaWindow::windowShouldClose()
// --------------------------------------------------------------------------
-void QCocoaWindow::setSynchedWindowStateFromWindow()
-{
- if (QWindow *w = window())
- m_synchedWindowState = w->windowState();
-}
-
bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const
{
if (type == Qt::Widget)
@@ -1834,6 +1828,20 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
m_synchedWindowState = predictedState;
}
+void QCocoaWindow::handleWindowStateChanged(Qt::WindowState newState)
+{
+ // If the window was maximized, then fullscreen, then tried to go directly to "normal" state,
+ // this notification will say that it is "normal", but it will still look maximized, and
+ // if you called performZoom it would actually take it back to "normal".
+ // So we should say that it is maximized because it actually is.
+ if (newState == Qt::WindowNoState && m_effectivelyMaximized)
+ newState = Qt::WindowMaximized;
+
+ QWindowSystemInterface::handleWindowStateChanged<QWindowSystemInterface::SynchronousDelivery>(window(), newState);
+
+ m_synchedWindowState = window()->windowState();
+}
+
bool QCocoaWindow::setWindowModified(bool modified)
{
if (!m_nsWindow)