summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2015-07-24 16:23:52 +0200
committerTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-07-27 12:35:20 +0000
commitf41cbc2d4599e7c6b6aac2d4bb374efae4efd72c (patch)
treed2c609e4b430da722df823d722766ca045f0f459 /src/plugins/platforms/cocoa
parent4ffdd865b09c8f595dcfc034ea6f3b5e07469b9f (diff)
Cococa integration - close popups in a windowWillClose callback
'Orphan' popups were already partially fixed as a side-effect of 10126b37d2e4655e17a2ea25b10801d8f9186f1c (orphan since the 'parent' is moving but popup stays in a now wrong position). This patch also tries to fix the case when a window closed. Change-Id: I0bbf474ab4f3b845d8bd337dae2abbae23192d0e Task-number: QTBUG-46262 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm20
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h1
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm7
4 files changed, 25 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 6415233250..b016004b23 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -219,6 +219,7 @@ public:
void windowDidResize();
void windowDidEndLiveResize();
bool windowShouldClose();
+ void windowWillClose();
bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const;
void setSynchedWindowStateFromWindow();
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 19a04b2f4b..7fb695630b 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -78,6 +78,14 @@ static bool isMouseEvent(NSEvent *ev)
}
}
+static void qt_closePopups()
+{
+ while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
+ QWindowSystemInterface::handleCloseEvent(popup->window());
+ QWindowSystemInterface::flushWindowSystemEvents();
+ }
+}
+
@implementation QNSWindowHelper
@synthesize window = _window;
@@ -1220,10 +1228,7 @@ void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
void QCocoaWindow::windowWillMove()
{
// Close any open popups on window move
- while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
- QWindowSystemInterface::handleCloseEvent(popup->window());
- QWindowSystemInterface::flushWindowSystemEvents();
- }
+ qt_closePopups();
}
void QCocoaWindow::windowDidMove()
@@ -1267,6 +1272,13 @@ bool QCocoaWindow::windowShouldClose()
return accepted;
}
+void QCocoaWindow::windowWillClose()
+{
+ // Close any open popups on window closing.
+ if (window() && !windowIsPopupType(window()->type()))
+ qt_closePopups();
+}
+
void QCocoaWindow::setSynchedWindowStateFromWindow()
{
if (QWindow *w = window())
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index ac1e8d62eb..46e8d40efb 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -57,6 +57,7 @@
- (void)windowWillMove:(NSNotification *)notification;
- (BOOL)windowShouldClose:(NSNotification *)notification;
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
+- (void)windowWillClose:(NSNotification *)notification;
@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index faa53b06ef..b96a9491e8 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -115,4 +115,11 @@
return YES;
}
+- (void)windowWillClose:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+ if (m_cocoaWindow)
+ m_cocoaWindow->windowWillClose();
+}
+
@end