Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
6.5.2, 6.6, 6.7, 6.8
-
None
-
Windows 10, Qt ^6.5.2
-
-
06fcb3dfe (dev), 5abc6e9cc (6.8)
Description
From Qt 6.5.2 onwards, maximizing and restoring a window moves it downwards (e.g. by pressing WIN + up/down). Doing that repeatedly will cause it to end up at the bottom of the screen.
This doesn't occur on 6.5.0. In 6.5.1 this doesn't happen either, but after maximizing and restoring the window for the first time, it doesn't shrink to the correct size, but remains at that size.
Example app:
#include <QApplication> #include <QLabel> int main(int argc, char **argv) { QApplication app(argc, argv); QLabel foo("Foo"); foo.show(); return app.exec(); }
This might be similar to QTBUG-124250 (i.e. something related to the window frame margins). Seems like it's 21e411687428d05655b8db2634466384fa35cc03 from QTBUG-112814.
The issue is (most likely) that the restoreGeometry is translated by the windowPlacementOffset (as a result of calling normalFrameGeometry), but it's not translated back when calling SetWindowPlacement (it's going from GetWindowPlacement -> translate -> SetWindowPlacement). The following patch resolved the issue for me. If that change looks reviewable, I can open a change on Gerrit.
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index e1b9cfdcda..572bcd3d1d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2076,6 +2076,16 @@ static QRect normalFrameGeometry(HWND hwnd) return QRect(); } +static QRect normalFrameGeometryUntranslated(HWND hwnd) +{ + WINDOWPLACEMENT wp; + wp.length = sizeof(WINDOWPLACEMENT); + if (GetWindowPlacement(hwnd, &wp)) { + return qrectFromRECT(wp.rcNormalPosition); + } + return QRect(); +} + QRect QWindowsWindow::normalGeometry() const { // Check for fake 'fullscreen' mode. @@ -2529,7 +2539,7 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state) void QWindowsWindow::updateRestoreGeometry() { - m_data.restoreGeometry = normalFrameGeometry(m_data.hwnd); + m_data.restoreGeometry = normalFrameGeometryUntranslated(m_data.hwnd); } void QWindowsWindow::setWindowState(Qt::WindowStates state)
Attachments
Issue Links
- relates to
-
QTBUG-129679 Windows 10: Maximized fixed-height window exceeds screen to the right when task bar is left
-
- Closed
-
-
QTBUG-123752 Unexpected offset of fixed-height top-level window when Windows Taskbar is on top
-
- Closed
-
For Gerrit Dashboard: QTBUG-129405 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
598483,1 | QWindowsWindow: Refactor corrections related to task bar on top / left | tqtc/lts-6.5 | qt/tqtc-qtbase | Status: NEW | 0 | 0 |