diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-11-03 15:53:33 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-11-04 10:38:49 (GMT) |
commit | 4567799c51b4126c693746e7c5c963faddb40225 (patch) | |
tree | 041130dacc229f24659d77e813cb78000b83664d /src/gui/kernel | |
parent | 51c9b68425c1d3fe64a08e6ef0357fbd6bdd8f8a (diff) | |
download | Qt-4567799c51b4126c693746e7c5c963faddb40225.zip Qt-4567799c51b4126c693746e7c5c963faddb40225.tar.gz Qt-4567799c51b4126c693746e7c5c963faddb40225.tar.bz2 |
Save the normal geometry on mac before the window is maximized
Do the same as on Windows - before the window is maximized save its normal
geometry so that when the window is restored we set the geometry back.
Task-number: QTBUG-4418
Reviewed-by: Prasanth
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qcocoawindowdelegate_mac.mm | 12 | ||||
-rw-r--r-- | src/gui/kernel/qcocoawindowdelegate_mac_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 10 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm index 803a1b1..9fb674e 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac.mm +++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm @@ -307,6 +307,18 @@ static void cleanupCocoaWindowDelegate() return m_windowHash->value(window); } +- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame +{ + Q_UNUSED(newFrame); + // saving the current window geometry before the window is maximized + QWidget *qwidget = m_windowHash->value(window); + if (qwidget->isWindow() && !(qwidget->windowState() & Qt::WindowMaximized)) { + QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget); + widgetPrivate->topData()->normalGeometry = qwidget->geometry(); + } + return YES; +} + - (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame { NSRect frameToReturn = defaultFrame; diff --git a/src/gui/kernel/qcocoawindowdelegate_mac_p.h b/src/gui/kernel/qcocoawindowdelegate_mac_p.h index 3728002..243ba03 100644 --- a/src/gui/kernel/qcocoawindowdelegate_mac_p.h +++ b/src/gui/kernel/qcocoawindowdelegate_mac_p.h @@ -78,6 +78,7 @@ QT_FORWARD_DECLARE_CLASS(QWidgetData) - (void)windowDidResignKey:(NSNotification*)notification; - (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu; - (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard; +- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame; @end @protocol NSDrawerDelegate <NSObject> diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 9270220..e6dd0ee 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -730,6 +730,7 @@ static EventTypeSpec window_events[] = { { kEventClassWindow, kEventWindowClose }, { kEventClassWindow, kEventWindowExpanded }, { kEventClassWindow, kEventWindowHidden }, + { kEventClassWindow, kEventWindowZoom }, { kEventClassWindow, kEventWindowZoomed }, { kEventClassWindow, kEventWindowCollapsed }, { kEventClassWindow, kEventWindowToolbarSwitchMode }, @@ -812,6 +813,9 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event, QShowEvent qse; QApplication::sendSpontaneousEvent(widget, &qse); + } else if(ekind == kEventWindowZoom) { + widget->d_func()->topData()->normalGeometry = widget->geometry(); + handled_event = false; } else if(ekind == kEventWindowZoomed) { WindowPartCode windowPart; GetEventParameter(event, kEventParamWindowPartCode, @@ -3487,10 +3491,10 @@ void QWidget::setWindowState(Qt::WindowStates newstate) qt_mac_set_fullscreen_mode(true); } else { needShow = isVisible(); - setParent(parentWidget(), d->topData()->savedFlags); - setGeometry(d->topData()->normalGeometry); if(!qApp->desktop()->screenNumber(this)) qt_mac_set_fullscreen_mode(false); + setParent(parentWidget(), d->topData()->savedFlags); + setGeometry(d->topData()->normalGeometry); d->topData()->normalGeometry.setRect(0, 0, -1, -1); } } @@ -3592,7 +3596,7 @@ void QWidget::setWindowState(Qt::WindowStates newstate) [window zoom:window]; #endif needSendStateChange = oldstate == windowState(); // Zoom didn't change flags. - } else if(oldstate & Qt::WindowMaximized) { + } else if(oldstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen)) { #ifndef QT_MAC_USE_COCOA Point idealSize; ZoomWindowIdeal(window, inZoomIn, &idealSize); |