summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2011-04-07 09:38:46 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2011-04-07 09:38:46 (GMT)
commitbaaa5ae00038c34c8a7539229cda083a8afde280 (patch)
tree4122631a48a838cd7753fc4ab0439b2f284b7361
parent32228c4f2b3419a35d1623377050ef72edf73c92 (diff)
downloadQt-baaa5ae00038c34c8a7539229cda083a8afde280.zip
Qt-baaa5ae00038c34c8a7539229cda083a8afde280.tar.gz
Qt-baaa5ae00038c34c8a7539229cda083a8afde280.tar.bz2
Cocoa: p1 bug fix: fix auto test regressions
Ref: 32228c4f2b3419a35d1623377050ef72edf73c92 It seems that the change above broke some auto tests, which revealed a true problem. When it comes to modal dialog, children still needs to be stacked on top of modal parents, as they the user cannot use the mouse to raise it. So rather than removing subWindowStacking fully, we narrow it even further down to only be used for children of modal dialogs. All in all, this is close to removing it, but still us it for certain corner cases. Task-number: QTBUG-11481 Reviewed-by: msorvig
-rw-r--r--src/gui/kernel/qwidget_mac.mm15
-rw-r--r--tests/auto/macnativeevents/tst_macnativeevents.cpp8
2 files changed, 17 insertions, 6 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 0f4abfa..aca1d53 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2795,11 +2795,9 @@ void QWidgetPrivate::transferChildren()
void QWidgetPrivate::setSubWindowStacking(bool set)
{
// After hitting too many unforeseen bugs trying to put Qt on top of the cocoa child
- // window API, we have decided to revert this behaviour. For compability
- // reasons we leave the code here for applications depending on it:
+ // window API, we have decided to revert this behaviour as much as we can. We
+ // therefore now only allow child windows to exist for children of modal dialogs.
static bool use_behaviour_qt473 = !qgetenv("QT_MAC_USE_CHILDWINDOWS").isEmpty();
- if (use_behaviour_qt473 == false)
- return;
// This will set/remove a visual relationship between parent and child on screen.
// The reason for doing this is to ensure that a child always stacks infront of
@@ -2829,7 +2827,10 @@ void QWidgetPrivate::setSubWindowStacking(bool set)
if (NSWindow *pwin = [qt_mac_nativeview_for(parent) window]) {
if (set) {
Qt::WindowType ptype = parent->window()->windowType();
- if ([pwin isVisible] && (ptype == Qt::Window || ptype == Qt::Dialog) && ![qwin parentWindow]) {
+ if ([pwin isVisible]
+ && (ptype == Qt::Window || ptype == Qt::Dialog)
+ && ![qwin parentWindow]
+ && (!use_behaviour_qt473 && parent->windowModality() == Qt::ApplicationModal)) {
NSInteger level = [qwin level];
[pwin addChildWindow:qwin ordered:NSWindowAbove];
if ([qwin level] < level)
@@ -2841,6 +2842,10 @@ void QWidgetPrivate::setSubWindowStacking(bool set)
}
}
+ // Only set-up child windows for q if q is modal:
+ if (set && !use_behaviour_qt473 && q->windowModality() != Qt::ApplicationModal)
+ return;
+
QObjectList widgets = q->children();
for (int i=0; i<widgets.size(); ++i) {
QWidget *child = qobject_cast<QWidget *>(widgets.at(i));
diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp
index ac7298c..731fe0a 100644
--- a/tests/auto/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp
@@ -68,7 +68,7 @@ private slots:
void testMouseEnter();
void testChildDialogInFrontOfModalParent();
#ifdef QT_MAC_USE_COCOA
- void testChildWindowInFrontOfParentWindow();
+// void testChildWindowInFrontOfParentWindow();
// void testChildToolWindowInFrontOfChildNormalWindow();
void testChildWindowInFrontOfStaysOnTopParentWindow();
#endif
@@ -314,6 +314,11 @@ void tst_MacNativeEvents::testChildDialogInFrontOfModalParent()
}
#ifdef QT_MAC_USE_COCOA
+#if 0
+// This test is disabled as of Qt-4.7.4 because we cannot do it
+// unless we use the Cocoa sub window API. But using that opens up
+// a world of side effects that we cannot live with. So we rather
+// not support child-on-top-of-parent instead.
void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow()
{
// Test that a child window always stacks in front of its parent window.
@@ -338,6 +343,7 @@ void tst_MacNativeEvents::testChildWindowInFrontOfParentWindow()
QTest::qWait(100);
QVERIFY(!child.isVisible());
}
+#endif
/* This test can be enabled once setStackingOrder has been fixed in qwidget_mac.mm
void tst_MacNativeEvents::testChildToolWindowInFrontOfChildNormalWindow()