summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-08-13 12:05:17 (GMT)
committerJesper Thomschutz <jesper.thomschutz@nokia.com>2010-08-16 12:09:21 (GMT)
commitee8caa1a895d8febcfdb0a797bdbd7339e28e815 (patch)
tree199c9429da83a47d0b91241baa5c0a794649c540
parent4fc3b97f1d4d0d8601616c1a0ec80c9af28cdcfd (diff)
downloadQt-ee8caa1a895d8febcfdb0a797bdbd7339e28e815.zip
Qt-ee8caa1a895d8febcfdb0a797bdbd7339e28e815.tar.gz
Qt-ee8caa1a895d8febcfdb0a797bdbd7339e28e815.tar.bz2
Cocoa: Stacking order of modal dialogs is wrong
Modal dialogs were sometimes hidden behind other normal windows on screen. The reason was that, upon going modal for a window, we actually resat the stacking level on the window in a faulty attempt to respect any stays-on-top window flags. This patch makes sure we avoid doing that, and at the same time, ensures we don't reintroduce the original bug as well. Task-number: QTBUG-12841 Reviewed-by: cduclos (cherry picked from commit 6d0d767e63df3c997d6d7a8cb6cd4bf8c0dfc835)
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index e26fbde..89f01d8 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -785,7 +785,7 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
// the stacking order of the windows while doing so, we put
// up a block that is used in QCocoaWindow and QCocoaPanel:
int stackSize = cocoaModalSessionStack.size();
- for (int i=stackSize-1; i>=0; --i) {
+ for (int i=0; i<stackSize; ++i) {
QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
if (info.session) {
[NSApp endModalSession:info.session];
@@ -822,12 +822,12 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
QBoolBlocker block1(blockSendPostedEvents, true);
info.nswindow = window;
[(NSWindow*) info.nswindow retain];
- // When creating a modal session cocoa will rearrange the windows.
- // In order to avoid windows to be put behind another we need to
- // keep the window level.
- int level = [window level];
+ int levelBeforeEnterModal = [window level];
info.session = [NSApp beginModalSessionForWindow:window];
- [window setLevel:level];
+ // Make sure we don't stack the window lower that it was before
+ // entering modal, in case it e.g. had the stays-on-top flag set:
+ if (levelBeforeEnterModal > [window level])
+ [window setLevel:levelBeforeEnterModal];
}
currentModalSessionCached = info.session;
}