Skip to content

Commit

Permalink
Windows QPA: Make frameless window respect WORKAREA
Browse files Browse the repository at this point in the history
Windows that have only set the WS_POPUP style do not take the WORKAREA
into account and maximize to fullscreen geometry. This patch maximizes a
WS_POPUP window to the size of the current working area, which can be
smaller than the screen geometry.

Fixes: QTBUG-129791
Fixes: QTBUG-130865
Pick-to: 6.5
Change-Id: I4c5beb0cd69c7ea4c585785a579a9d66bab12cc6
Reviewed-by: Oliver Wolff <[email protected]>
(cherry picked from commit 90be660)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
  • Loading branch information
Wladimir Leuschner authored and Qt Cherry-pick Bot committed Nov 7, 2024
1 parent 27ae8db commit 2c1a23f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/plugins/platforms/windows/qwindowswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2736,8 +2736,24 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowStates newState)
setFlag(WithinMaximize);
if (newState & Qt::WindowFullScreen)
setFlag(MaximizeToFullScreen);
ShowWindow(m_data.hwnd,
(newState & Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
if (m_data.flags & Qt::FramelessWindowHint) {
if (newState == Qt::WindowNoState) {
const QRect &rect = m_savedFrameGeometry;
MoveWindow(m_data.hwnd, rect.x(), rect.y(), rect.width(), rect.height(), true);
} else {
HMONITOR monitor = MonitorFromWindow(m_data.hwnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO monitorInfo = {};
monitorInfo.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(monitor, &monitorInfo);
const RECT &rect = monitorInfo.rcWork;
m_savedFrameGeometry = geometry();
MoveWindow(m_data.hwnd, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top, true);
}
} else {
ShowWindow(m_data.hwnd,
(newState & Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNOACTIVATE);
}
clearFlag(WithinMaximize);
clearFlag(MaximizeToFullScreen);
} else if (visible && (oldState & newState & Qt::WindowMinimized)) {
Expand Down

0 comments on commit 2c1a23f

Please sign in to comment.