summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@digia.com>2013-07-08 07:53:00 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-07-08 17:40:26 (GMT)
commite576779a537e5e60d1495b6d690561cce8f4cb3b (patch)
treee2195561225d7fba24f07c7b4eec06b1fd18bc02
parent7b7c321d5f35b6ee70db5a72d5d37e19e125d7cf (diff)
downloadQt-e576779a537e5e60d1495b6d690561cce8f4cb3b.zip
Qt-e576779a537e5e60d1495b6d690561cce8f4cb3b.tar.gz
Qt-e576779a537e5e60d1495b6d690561cce8f4cb3b.tar.bz2
Mac: Handle the maximizing of the window ourselves when it is frameless
On Mac we need to make a frameless window appear maximized manually rather than letting the underlying Cocoa API deal with it because it would overwise not appear correctly. The test is only done for Mac due to the fact that it is not giving reliable results on other platforms and the source code change is Mac specific anyway. Change-Id: Id48a67ba70bfb4bdc921256f1a80328615c98a6b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
-rw-r--r--src/gui/kernel/qwidget_mac.mm9
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp9
2 files changed, 17 insertions, 1 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 702a56b..2fe1f06 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3866,7 +3866,14 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
d->updateFrameStrut(); // In theory the dirty would work, but it's optimized out if the window is not visible :(
}
// Everything should be handled by Cocoa.
- [window zoom:window];
+ if (!windowFlags() & Qt::FramelessWindowHint) {
+ [window zoom:window];
+ } else {
+ QDesktopWidget *dsk = QApplication::desktop();
+ QRect avail = dsk->availableGeometry(dsk->screenNumber(this));
+ setGeometry(avail);
+ }
+
#endif
needSendStateChange = oldstate == windowState(); // Zoom didn't change flags.
} else if(oldstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen)) {
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 9cd257f..0dc7441 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -2052,6 +2052,15 @@ void tst_QWidget::showMaximized()
}
#endif
#endif // QT3_SUPPORT
+#ifdef Q_WS_MAC // Only do this on Mac because it's still not getting accurate results elsewhere
+ {
+ QWidget w;
+ w.setWindowFlags(Qt::FramelessWindowHint);
+ w.showMaximized();
+ QTest::qWaitForWindowShown(&w);
+ QCOMPARE(w.geometry(), QApplication::desktop()->availableGeometry(&w));
+ }
+#endif
}
void tst_QWidget::showFullScreen()