Cococa integration - close popups in a windowWillClose callback
'Orphan' popups were already partially fixed as a side-effect of
10126b37d2
(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>
This commit is contained in:
parent
4ffdd865b0
commit
f41cbc2d45
@ -219,6 +219,7 @@ public:
|
||||
void windowDidResize();
|
||||
void windowDidEndLiveResize();
|
||||
bool windowShouldClose();
|
||||
void windowWillClose();
|
||||
bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const;
|
||||
|
||||
void setSynchedWindowStateFromWindow();
|
||||
|
@ -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())
|
||||
|
@ -57,6 +57,7 @@
|
||||
- (void)windowWillMove:(NSNotification *)notification;
|
||||
- (BOOL)windowShouldClose:(NSNotification *)notification;
|
||||
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
|
||||
- (void)windowWillClose:(NSNotification *)notification;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -115,4 +115,11 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification
|
||||
{
|
||||
Q_UNUSED(notification);
|
||||
if (m_cocoaWindow)
|
||||
m_cocoaWindow->windowWillClose();
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user