diff options
Diffstat (limited to 'src/gui/kernel/qcocoawindowdelegate_mac.mm')
-rw-r--r-- | src/gui/kernel/qcocoawindowdelegate_mac.mm | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm index 8cd97b9..fa325f4 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac.mm +++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm @@ -1,11 +1,11 @@ /**************************************************************************** - ** - ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) - ** - ** This file is part of the QtGui module of the Qt Toolkit. - ** - ** $QT_BEGIN_LICENSE:LGPL$ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions @@ -36,11 +36,11 @@ ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ - ** - ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - ** - ****************************************************************************/ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ #import "private/qcocoawindowdelegate_mac_p.h" #ifdef QT_MAC_USE_COCOA @@ -194,7 +194,6 @@ static void cleanupCocoaWindowDelegate() { NSWindow *window = [notification object]; QWidget *qwidget = m_windowHash->value(window); - // Just here to handle the is zoomed method. QWidgetData *widgetData = qt_qwidget_data(qwidget); if (!(qwidget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) && [window isZoomed]) { widgetData->window_state = widgetData->window_state | Qt::WindowMaximized; @@ -202,7 +201,6 @@ static void cleanupCocoaWindowDelegate() & ~Qt::WindowMaximized)); qt_sendSpontaneousEvent(qwidget, &e); } - [self checkForMove:[window frame] forWidget:qwidget]; NSRect rect = [[window contentView] frame]; const QSize newSize(rect.size.width, rect.size.height); const QSize &oldSize = widgetData->crect.size(); @@ -212,12 +210,18 @@ static void cleanupCocoaWindowDelegate() } } -- (void)checkForMove:(const NSRect &)newRect forWidget:(QWidget *)qwidget +- (void)windowDidMove:(NSNotification *)notification { - // newRect's origin is bottom left. + // The code underneath needs to translate the window location + // from bottom left (which is the origin used by Cocoa) to + // upper left (which is the origin used by Qt): + NSWindow *window = [notification object]; + NSRect newRect = [window frame]; + QWidget *qwidget = m_windowHash->value(window); QPoint qtPoint = flipPoint(NSMakePoint(newRect.origin.x, newRect.origin.y + newRect.size.height)).toPoint(); const QRect &oldRect = qwidget->frameGeometry(); + if (qtPoint.x() != oldRect.x() || qtPoint.y() != oldRect.y()) { QWidgetData *widgetData = qt_qwidget_data(qwidget); QRect oldCRect = widgetData->crect; @@ -233,11 +237,6 @@ static void cleanupCocoaWindowDelegate() } } -- (void)windowDidMove:(NSNotification *)notification -{ - [self windowDidResize:notification]; -} - -(BOOL)windowShouldClose:(id)windowThatWantsToClose { QWidget *qwidget = m_windowHash->value(windowThatWantsToClose); @@ -266,18 +265,18 @@ static void cleanupCocoaWindowDelegate() -(void)windowDidBecomeMain:(NSNotification*)notification { - NSWindow *window = [notification object]; - if ([window isKeyWindow]) - return; // Should have already got an activate notification from "become key." - QWidget *qwidget = m_windowHash->value([notification object]); + Q_ASSERT(qwidget); + if (qwidget->isActiveWindow()) + return; // Widget is already active, no need to go through re-activation. + onApplicationWindowChangedActivation(qwidget, true); } -(void)windowDidResignMain:(NSNotification*)notification { QWidget *qwidget = m_windowHash->value([notification object]); - + Q_ASSERT(qwidget); onApplicationWindowChangedActivation(qwidget, false); } @@ -285,11 +284,11 @@ static void cleanupCocoaWindowDelegate() // tiny difference between main and key windows. -(void)windowDidBecomeKey:(NSNotification*)notification { - NSWindow *window = [notification object]; - if ([window isMainWindow]) - return; // Should have already got an activate notification from "become main." + QWidget *qwidget = m_windowHash->value([notification object]); + Q_ASSERT(qwidget); + if (qwidget->isActiveWindow()) + return; // Widget is already active, no need to go through re-activation - QWidget *qwidget = m_windowHash->value(window); onApplicationWindowChangedActivation(qwidget, true); } @@ -297,6 +296,7 @@ static void cleanupCocoaWindowDelegate() -(void)windowDidResignKey:(NSNotification*)notification { QWidget *qwidget = m_windowHash->value([notification object]); + Q_ASSERT(qwidget); onApplicationWindowChangedActivation(qwidget, false); } |