summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qwidget_mac.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2011-04-06 09:07:08 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2011-04-06 11:15:08 (GMT)
commit32228c4f2b3419a35d1623377050ef72edf73c92 (patch)
treea758a585ecd8d07d221fb09cc1173eeeb4170639 /src/gui/kernel/qwidget_mac.mm
parent2e0b5644e17f22ef3fc24ce4c762449149b24af6 (diff)
downloadQt-32228c4f2b3419a35d1623377050ef72edf73c92.zip
Qt-32228c4f2b3419a35d1623377050ef72edf73c92.tar.gz
Qt-32228c4f2b3419a35d1623377050ef72edf73c92.tar.bz2
Cocoa: p1 bug fix: revert use of subWindowStacking
This reverts commit 3c2373d7ea9bc91bb537c0725984d19ad0fbab01. After finding yet another bug related to cocoa child windows (QTBUG-17738), we have no other option than to admit it was a wrong move to use the API in the first place. Had we only known how many side-effects and hidden bugs it would introduce. The original problem we tried to solve were the cases where a stays-on-top parent window executed a modal child dialog. This child should always stay on top of its parent, but Cocoa would insist on pushing the window down to the modal window level upon activating/deactivating the application. Some window systems will always stack a window child on top of the parent, while others (X11) seems to be more selective on this issue. On Mac, we already stack windows a bit differently, thinking first and foremost on tool windows. Since this change is going into a patch release (which is debatable, since this changes behaviour, but p1 is a p1), we choose to add in a backdoor for those users who by chance depend on this behaviour. Setting the env var QT_MAC_USE_CHILDWINDOWS=1 will give you the old code path, but we plan to remove this for Qt-4.8. Also, this patch does fix the original bug described above by overriding the setLevel method in NSWindow, and refuse Cocoa to level down stays-on-top modal windows.
Diffstat (limited to 'src/gui/kernel/qwidget_mac.mm')
-rw-r--r--src/gui/kernel/qwidget_mac.mm30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 7105d23..0f4abfa 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -2794,14 +2794,18 @@ void QWidgetPrivate::transferChildren()
#ifdef QT_MAC_USE_COCOA
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:
+ 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
- // its parent (expecially if both windows are modal, and the child blocks input to
- // the parent while at the same time hiding behind it). Unfortunatly is turns out
- // that [NSWindow addChildWindow] has
+ // its parent. Unfortunatly is turns out that [NSWindow addChildWindow] has
// several unwanted side-effects, one of them being the moving of a child when
- // moving the parent, which we choose to accept (if this is unacceptable, consider
- // using Qt::WA_MacNoCocoaChildWindow). A way tougher side-effect is
+ // moving the parent, which we choose to accept. A way tougher side-effect is
// that Cocoa will hide the parent if you hide the child. And in the case of
// a tool window, since it will normally hide when you deactivate the
// application, Cocoa will hide the parent upon deactivate as well. The result often
@@ -2824,14 +2828,12 @@ void QWidgetPrivate::setSubWindowStacking(bool set)
if (QWidget *parent = q->parentWidget()) {
if (NSWindow *pwin = [qt_mac_nativeview_for(parent) window]) {
if (set) {
- if (!q->testAttribute(Qt::WA_MacNoCocoaChildWindow)) {
- Qt::WindowType ptype = parent->window()->windowType();
- if ([pwin isVisible] && (ptype == Qt::Window || ptype == Qt::Dialog) && ![qwin parentWindow]) {
- NSInteger level = [qwin level];
- [pwin addChildWindow:qwin ordered:NSWindowAbove];
- if ([qwin level] < level)
- [qwin setLevel:level];
- }
+ Qt::WindowType ptype = parent->window()->windowType();
+ if ([pwin isVisible] && (ptype == Qt::Window || ptype == Qt::Dialog) && ![qwin parentWindow]) {
+ NSInteger level = [qwin level];
+ [pwin addChildWindow:qwin ordered:NSWindowAbove];
+ if ([qwin level] < level)
+ [qwin setLevel:level];
}
} else {
[pwin removeChildWindow:qwin];
@@ -2845,8 +2847,6 @@ void QWidgetPrivate::setSubWindowStacking(bool set)
if (child && child->isWindow()) {
if (NSWindow *cwin = [qt_mac_nativeview_for(child) window]) {
if (set) {
- if (child->testAttribute(Qt::WA_MacNoCocoaChildWindow))
- continue;
Qt::WindowType ctype = child->window()->windowType();
if ([cwin isVisible] && (ctype == Qt::Window || ctype == Qt::Dialog) && ![cwin parentWindow]) {
NSInteger level = [cwin level];