From 923110602c653ae9df9d562e19ef92666a6f8867 Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Tue, 4 May 2010 11:57:18 +0200 Subject: Suggestions' widget on another space The problem here arises from the fact that when a window is raisen we didn't check the current space. This patch fixes that and adds a simple logic so the window is raisen in the right space. Task-number: QTCREATORBUG-827 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index e29b755..81dd746 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3824,9 +3824,28 @@ void QWidgetPrivate::raise_sys() #if QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; if (isRealWindow()) { - // Calling orderFront shows the window on Cocoa too. + // With the introduction of spaces it is not as simple as just raising the window. + // First we need to check if we are in the right space. If we are, then we just continue + // as usual. The problem comes when we are not in the active space. There are two main cases: + // 1. Our parent was moved to a new space. In this case we want the window to be raised + // in the same space as its parent. + // 2. We don't have a parent. For this case we will just raise the window and let Cocoa + // switch to the corresponding space. + // NOTICE: There are a lot of corner cases here. We are keeping this simple for now, if + // required we will introduce special handling for some of them. if (!q->testAttribute(Qt::WA_DontShowOnScreen) && q->isVisible()) { - [qt_mac_window_for(q) orderFront:qt_mac_window_for(q)]; + OSWindowRef window = qt_mac_window_for(q); + if(![window isOnActiveSpace]) { + QWidget *parentWidget = q->parentWidget(); + if(parentWidget) { + OSWindowRef parentWindow = qt_mac_window_for(parentWidget); + if(parentWindow && [parentWindow isOnActiveSpace]) { + recreateMacWindow(); + window = qt_mac_window_for(q); + } + } + } + [window orderFront:window]; } if (qt_mac_raise_process) { //we get to be the active process now ProcessSerialNumber psn; -- cgit v0.12