Windows: Don't cover the taskbar when maximizing frameless windows
Brings Windows QPA on par with other platforms. [ChangeLog][Windows] Don't cover the taskbar when maximizing frameless windows. Task-number: QTBUG-8361 Change-Id: Iba35132f697cb7379650a4c883b616c5c2023d4c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>bb10
parent
862e11cd19
commit
0c936ca83c
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@ public:
|
|||
TouchRegistered = 0x4000,
|
||||
AlertState = 0x8000,
|
||||
Exposed = 0x10000,
|
||||
WithinCreate = 0x20000
|
||||
WithinCreate = 0x20000,
|
||||
WithinMaximize = 0x40000
|
||||
};
|
||||
|
||||
struct WindowData
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue