diff options
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 28 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.h | 3 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 1 |
3 files changed, 29 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 58047124a1..89b5bdbf0e 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1170,8 +1170,13 @@ void QWindowsWindow::show_sys() const if (type == Qt::Popup || type == Qt::ToolTip || type == Qt::Tool) sm = SW_SHOWNOACTIVATE; + if (w->windowState() & Qt::WindowMaximized) + setFlag(WithinMaximize); // QTBUG-8361 + ShowWindow(m_data.hwnd, sm); + clearFlag(WithinMaximize); + if (fakedMaximize) { setStyle(style() & ~WS_MAXIMIZEBOX); SetWindowPos(m_data.hwnd, 0, 0, 0, 0, 0, @@ -1582,8 +1587,11 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState) setFlag(FrameDirty); if ((oldState == Qt::WindowMaximized) != (newState == Qt::WindowMaximized)) { - if (visible && !(newState == Qt::WindowMinimized)) + if (visible && !(newState == Qt::WindowMinimized)) { + setFlag(WithinMaximize); ShowWindow(m_data.hwnd, (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE); + clearFlag(WithinMaximize); + } } if ((oldState == Qt::WindowFullScreen) != (newState == Qt::WindowFullScreen)) { @@ -1903,6 +1911,24 @@ void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const { const QWindowsGeometryHint hint(window(), m_data.customMargins); hint.applyToMinMaxInfo(m_data.hwnd, mmi); + + if (testFlag(WithinMaximize) && (m_data.flags & Qt::FramelessWindowHint)) { + // This block fixes QTBUG-8361: Frameless windows shouldn't cover the + // taskbar when maximized + if (const QScreen *screen = effectiveScreen(window())) { + mmi->ptMaxSize.y = screen->availableGeometry().height(); + + // Width, because you can have the taskbar on the sides too. + mmi->ptMaxSize.x = screen->availableGeometry().width(); + + // If you have the taskbar on top, or on the left you don't want it at (0,0): + mmi->ptMaxPosition.x = screen->availableGeometry().x(); + mmi->ptMaxPosition.y = screen->availableGeometry().y(); + } else { + qWarning() << "Invalid screen"; + } + } + if (QWindowsContext::verboseWindows) qDebug() << __FUNCTION__ << window() << *mmi; } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index f055864482..61dc3e2dc2 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -136,7 +136,8 @@ public: TouchRegistered = 0x4000, AlertState = 0x8000, Exposed = 0x10000, - WithinCreate = 0x20000 + WithinCreate = 0x20000, + WithinMaximize = 0x40000 }; struct WindowData diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 36a3a8bad5..9090f97ce6 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4571,7 +4571,6 @@ void tst_QWidget::setGeometry_win() RECT rt; ::GetWindowRect(winHandleOf(&widget), &rt); QVERIFY(rt.left <= 0); - QEXPECT_FAIL("", "QTBUG-26424", Continue); QVERIFY(rt.top <= 0); } #endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) |