summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget_mac.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-01-15 12:19:11 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2010-01-15 14:02:23 (GMT)
commit7dee69caea20b189d5f4f8e27179c5abfd73a815 (patch)
treefa35e0605c4da500944f08d56857b3b8ffaee23c /src/gui/kernel/qwidget_mac.mm
parent27ed53bbdcbb8ee9c9916bf90e5c9fe8157091ec (diff)
downloadQt-7dee69caea20b189d5f4f8e27179c5abfd73a815.zip
Qt-7dee69caea20b189d5f4f8e27179c5abfd73a815.tar.gz
Qt-7dee69caea20b189d5f4f8e27179c5abfd73a815.tar.bz2
Cocoa: sub-windows do not stack in front of parents
Seems like this were never implemented. This patch does. Task-number: QTBUG-7375
Diffstat (limited to 'src/gui/kernel/qwidget_mac.mm')
-rw-r--r--src/gui/kernel/qwidget_mac.mm42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 2d3c862..e30bf95 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2732,6 +2732,35 @@ void QWidgetPrivate::transferChildren()
}
}
+#ifdef QT_MAC_USE_COCOA
+void QWidgetPrivate::setSubWindowStacking(bool set)
+{
+ Q_Q(QWidget);
+ if (!q->isWindow() || !q->testAttribute(Qt::WA_WState_Created))
+ return;
+
+ if (QWidget *parent = q->parentWidget()) {
+ if (parent->testAttribute(Qt::WA_WState_Created)) {
+ if (set)
+ [qt_mac_window_for(parent) addChildWindow:qt_mac_window_for(q) ordered:NSWindowAbove];
+ else
+ [qt_mac_window_for(parent) removeChildWindow:qt_mac_window_for(q)];
+ }
+ }
+
+ QList<QWidget *> widgets = q->findChildren<QWidget *>();
+ for (int i=0; i<widgets.size(); ++i) {
+ QWidget *child = widgets.at(i);
+ if (child->isWindow() && child->testAttribute(Qt::WA_WState_Created)) {
+ if (set)
+ [qt_mac_window_for(q) addChildWindow:qt_mac_window_for(child) ordered:NSWindowAbove];
+ else
+ [qt_mac_window_for(q) removeChildWindow:qt_mac_window_for(child)];
+ }
+ }
+}
+#endif
+
void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
{
Q_Q(QWidget);
@@ -2883,7 +2912,6 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f)
current = current->parentWidget();
}
}
-
invalidateBuffer(q->rect());
qt_event_request_window_change(q);
}
@@ -3345,6 +3373,7 @@ void QWidgetPrivate::show_sys()
#else
// sync the opacity value back (in case of a fade).
[window setAlphaValue:q->windowOpacity()];
+ setSubWindowStacking(true);
QWidget *top = 0;
if (QApplicationPrivate::tryModalHelper(q, &top)) {
@@ -3361,7 +3390,6 @@ void QWidgetPrivate::show_sys()
if (NSWindow *modalWin = qt_mac_window_for(top))
[modalWin orderFront:window];
}
-
#endif
if (q->windowType() == Qt::Popup) {
if (q->focusWidget())
@@ -3422,6 +3450,7 @@ void QWidgetPrivate::hide_sys()
QMacCocoaAutoReleasePool pool;
if(q->isWindow()) {
+ setSubWindowStacking(false);
OSWindowRef window = qt_mac_window_for(q);
if(qt_mac_is_macsheet(q)) {
#ifndef QT_MAC_USE_COCOA
@@ -4751,17 +4780,16 @@ void QWidgetPrivate::setModal_sys()
}
} else {
// INVARIANT: Window shold _not_ be window-modal (and as such, not a sheet).
- // If the window is application modal, there in no need to do much at this point.
if (alreadySheet){
// NB: the following call will call setModal_sys recursivly:
recreateMacWindow();
windowRef = qt_mac_window_for(q);
}
if (q->windowModality() == Qt::NonModal
- && primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) {
- // INVARIANT: Our window is a dialog that has a dialog parent that is
- // application modal, or . This means that q is supposed to be on top of this
- // dialog and not be modally shaddowed:
+ && primaryWindow && primaryWindow->windowModality() == Qt::ApplicationModal) {
+ // INVARIANT: Our window has a parent that is application modal.
+ // This means that q is supposed to be on top of this window and
+ // not be modally shaddowed:
if ([windowRef isKindOfClass:[NSPanel class]])
[static_cast<NSPanel *>(windowRef) setWorksWhenModal:YES];
}