From e576779a537e5e60d1495b6d690561cce8f4cb3b Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 8 Jul 2013 09:53:00 +0200 Subject: 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 Reviewed-by: Gabriel de Dietrich --- src/gui/kernel/qwidget_mac.mm | 9 ++++++++- tests/auto/qwidget/tst_qwidget.cpp | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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() -- cgit v0.12