summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2013-06-03 18:33:03 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-12 10:09:13 +0200
commitb8c007ede01360594ec5399532f2229e82715cc3 (patch)
tree6c91bcc110be17bdd6796c0d3b88c949674e1511 /src/plugins
parent7ee15bfbb815df87ae0526f105a13a591b192c76 (diff)
Cocoa: Update window state when maximizing from the title bar
There's no NSWindow notification we can listen to, but we can override behavior from its delegate. Change-Id: I61cebf4119f83c770fe4e7f45ff0d4e8bf9d0df9 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h1
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm10
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h1
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm8
4 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 85f72a4dbb..d28e38886b 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -82,6 +82,7 @@ QT_END_NAMESPACE
- (void)drawRect:(NSRect)dirtyRect;
- (void)updateGeometry;
- (void)windowNotification : (NSNotification *) windowNotification;
+- (void)notifyWindowWillZoom:(BOOL)willZoom;
- (void)viewDidHide;
- (void)viewDidUnhide;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 529a0ccfe7..ec53fc6a7e 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -306,6 +306,16 @@ static QTouchDevice *touchDevice = 0;
}
}
+- (void)notifyWindowWillZoom:(BOOL)willZoom
+{
+ Qt::WindowState newState = willZoom ? Qt::WindowMaximized : Qt::WindowNoState;
+ QWindowSystemInterface::handleWindowStateChanged(m_window, newState);
+ // We want to read the window state back from the window,
+ // but the event we just sent may be asynchronous.
+ QWindowSystemInterface::flushWindowSystemEvents();
+ m_platformWindow->setSynchedWindowStateFromWindow();
+}
+
- (void)viewDidHide
{
m_platformWindow->obscureWindow();
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index 9a616ba8e8..06e11fffbb 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -57,6 +57,7 @@
- (void)windowDidMove:(NSNotification *)notification;
- (void)windowWillMove:(NSNotification *)notification;
- (BOOL)windowShouldClose:(NSNotification *)notification;
+- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index 8e17936a78..10536bd5f4 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -90,4 +90,12 @@
return YES;
}
+- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
+{
+ Q_UNUSED(newFrame);
+ if (m_cocoaWindow && m_cocoaWindow->m_qtView)
+ [m_cocoaWindow->m_qtView notifyWindowWillZoom:![window isZoomed]];
+ return YES;
+}
+
@end