summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-04-28 09:33:56 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-04-28 11:33:36 (GMT)
commit8ec06f944915a56ef7ad3f1a9416b16271055fb9 (patch)
tree045e8041197219df30054c198759c3b86445c684 /src/gui/kernel
parentd851374c7894ac62367d885e7c24650d8635d2e8 (diff)
downloadQt-8ec06f944915a56ef7ad3f1a9416b16271055fb9.zip
Qt-8ec06f944915a56ef7ad3f1a9416b16271055fb9.tar.gz
Qt-8ec06f944915a56ef7ad3f1a9416b16271055fb9.tar.bz2
Cocoa: qwidget auto test fails (windowMoveResize)
The test fails because, in cocoa, when resizing a window to zero (either w or h), cocoa will also move the window up in the corner (!). So the fix is to issue an extra move back to it's true location after the resize. The faulty cocoa move is issued inside the resize callback, so we choose to not update the window location anymore from a pure resize callback. Task-number: 251895 Reviewed-by: Trenton Schulz
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qcocoawindowdelegate_mac.mm17
-rw-r--r--src/gui/kernel/qwidget_mac.mm25
2 files changed, 31 insertions, 11 deletions
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm
index 03b2fce..fa325f4 100644
--- a/src/gui/kernel/qcocoawindowdelegate_mac.mm
+++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm
@@ -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);
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index a00f969..5abaaf8 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -4039,7 +4039,11 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
QMacCocoaAutoReleasePool pool;
bool realWindow = isRealWindow();
- if (realWindow && !(w == 0 && h == 0) && !q->testAttribute(Qt::WA_DontShowOnScreen)) {
+ if (realWindow && !q->testAttribute(Qt::WA_DontShowOnScreen)
+#ifndef QT_MAC_USE_COCOA
+ && !(w == 0 && h == 0)
+#endif
+ ){
applyMaxAndMinSizeConstraints(w, h);
topData()->isSetGeometry = 1;
topData()->isMove = isMove;
@@ -4054,7 +4058,24 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
fStrut.top() + fStrut.bottom() + h));
NSRect cocoaFrameRect = NSMakeRect(frameRect.x(), flipYCoordinate(frameRect.bottom() + 1),
frameRect.width(), frameRect.height());
- [window setFrame:cocoaFrameRect display:NO];
+
+ QPoint currTopLeft = data.crect.topLeft();
+ if (currTopLeft.x() == x && currTopLeft.y() == y
+ && cocoaFrameRect.size.width != 0
+ && cocoaFrameRect.size.height != 0) {
+ [window setFrame:cocoaFrameRect display:NO];
+ } else {
+ // The window is moved and resized (or resized to zero).
+ // Since Cocoa usually only sends us a resize callback after
+ // setting a window frame, we issue an explicit move as
+ // well. To stop Cocoa from optimize away the move (since the move
+ // would have the same origin as the setFrame call) we shift the
+ // window back and forth inbetween.
+ cocoaFrameRect.origin.y += 1;
+ [window setFrame:cocoaFrameRect display:NO];
+ cocoaFrameRect.origin.y -= 1;
+ [window setFrameOrigin:cocoaFrameRect.origin];
+ }
#endif
topData()->isSetGeometry = 0;
} else {