diff options
author | Josh Faust <jfaust@suitabletech.com> | 2013-03-14 15:13:34 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-26 14:18:16 +0200 |
commit | c90d9b697f6ef549d33047332a9c44b40ded63f5 (patch) | |
tree | ef7c7686cfbc86ba6055831a14088b3531cd3026 /src/plugins | |
parent | e12d384d7b898f949bc5ad27a473eee2ec92a711 (diff) |
Fix ignoring close events on OSX
QNSWindowDelegate was not handling windowShouldClose, which is how you
can tell Cocoa that your window should not close if the close button is
pressed. This change moves the close handling from windowWillClose to
windowShouldClose, and adds an optional "accepted" pointer to
QWindowSystemInterface::handleCloseEvent so that QNSWindowDelegate can
return a true/false value for whether the window should actually close
Task-number: QTBUG-28965
Change-Id: I67c6296ad42cbeeb71413e05411467d4e558adb4
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 6 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindowdelegate.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindowdelegate.mm | 6 |
4 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index b2657b7725..60f448044e 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -132,7 +132,7 @@ public: void windowWillMove(); void windowDidMove(); void windowDidResize(); - void windowWillClose(); + bool windowShouldClose(); bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const; NSInteger windowLevel(Qt::WindowFlags flags); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 14b9b66c92..8e9fcc443b 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -684,10 +684,12 @@ void QCocoaWindow::windowDidResize() [m_qtView updateGeometry]; } -void QCocoaWindow::windowWillClose() +bool QCocoaWindow::windowShouldClose() { - QWindowSystemInterface::handleCloseEvent(window()); + bool accepted = false; + QWindowSystemInterface::handleCloseEvent(window(), &accepted); QWindowSystemInterface::flushWindowSystemEvents(); + return accepted; } bool QCocoaWindow::windowIsPopupType(Qt::WindowType type) const diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index 98ad7b8c9d..a5b46a971f 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -56,6 +56,7 @@ - (void)windowDidResize:(NSNotification *)notification; - (void)windowDidMove:(NSNotification *)notification; - (void)windowWillClose:(NSNotification *)notification; +- (BOOL)windowShouldClose:(NSNotification *)notification; @end diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index b19a401443..8e17936a78 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -80,12 +80,14 @@ } } -- (void)windowWillClose:(NSNotification *)notification +- (BOOL)windowShouldClose:(NSNotification *)notification { Q_UNUSED(notification); if (m_cocoaWindow) { - m_cocoaWindow->windowWillClose(); + return m_cocoaWindow->windowShouldClose(); } + + return YES; } @end |