summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-02-12 20:55:31 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-02-18 16:45:48 +0000
commit6273b484b35479eb5788425c8d90acacdf239623 (patch)
tree02f671caa2b8a1c1bba4e2eb2275a1ebd54d14e1
parentc36c5e9b552f826c96bf066252b49de03921c03f (diff)
macOS: Remove redundant tracking of modal sessions in QCocoaWindow
Change-Id: I43a40889b0731e4b480155256fc51eaa836e62a3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm9
4 files changed, 9 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
index 44a9c52b7b..9771cd0289 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h
@@ -171,6 +171,7 @@ public:
void temporarilyStopAllModalSessions();
void beginModalSession(QWindow *widget);
void endModalSession(QWindow *widget);
+ bool hasModalSession() const;
void cleanupModalSessions();
void cancelWaitForMoreEvents();
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index b944c3d28c..84ffadea83 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -672,6 +672,11 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
return currentModalSessionCached;
}
+bool QCocoaEventDispatcherPrivate::hasModalSession() const
+{
+ return !cocoaModalSessionStack.isEmpty();
+}
+
void QCocoaEventDispatcherPrivate::cleanupModalSessions()
{
// Go through the list of modal sessions, and end those
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 0a913ef66e..fef72bc496 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -253,7 +253,6 @@ public: // for QNSView
bool m_needsInvalidateShadow;
- bool m_hasModalSession;
bool m_frameStrutEventsEnabled;
QRect m_exposedRect;
int m_registerTouchCount;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 5a26f57c8c..2718dc9600 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -153,7 +153,6 @@ QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle)
, m_inSetStyleMask(false)
, m_menubar(nullptr)
, m_needsInvalidateShadow(false)
- , m_hasModalSession(false)
, m_frameStrutEventsEnabled(false)
, m_registerTouchCount(0)
, m_resizableTransientParent(false)
@@ -360,8 +359,7 @@ void QCocoaWindow::setVisible(bool visible)
} else if (window()->modality() == Qt::ApplicationModal) {
// Show the window as application modal
eventDispatcher()->beginModalSession(window());
- m_hasModalSession = true;
- } else if (m_view.window.canBecomeKeyWindow && eventDispatcher()->cocoaModalSessionStack.isEmpty()) {
+ } else if (m_view.window.canBecomeKeyWindow && !eventDispatcher()->hasModalSession()) {
[m_view.window makeKeyAndOrderFront:nil];
} else {
[m_view.window orderFront:nil];
@@ -393,9 +391,8 @@ void QCocoaWindow::setVisible(bool visible)
} else {
// Window not visible, hide it
if (isContentView()) {
- if (m_hasModalSession) {
+ if (eventDispatcher()->hasModalSession()) {
eventDispatcher()->endModalSession(window());
- m_hasModalSession = false;
} else {
if ([m_view.window isSheet]) {
Q_ASSERT_X(parentCocoaWindow, "QCocoaWindow", "Window modal dialog has no transient parent.");
@@ -405,7 +402,7 @@ void QCocoaWindow::setVisible(bool visible)
[m_view.window orderOut:nil];
- if (m_view.window == [NSApp keyWindow] && !eventDispatcher()->currentModalSession()) {
+ if (m_view.window == [NSApp keyWindow] && !eventDispatcher()->hasModalSession()) {
// Probably because we call runModalSession: outside [NSApp run] in QCocoaEventDispatcher
// (e.g., when show()-ing a modal QDialog instead of exec()-ing it), it can happen that
// the current NSWindow is still key after being ordered out. Then, after checking we