Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.2
Description
I've been trying to get to the bottom of a bug we encountered when a user un-plugs a monitor, forcing the main window to move to the other screen.
Setup:
Basic test application with a QMainWindow
Windows 11
2 Monitors
Primary monitor ("Make this my main display" is ticked)
Resolution: 1920x1080
DPI: 150%
Secondary Monitor
Resolution: 3840x2160
DPI: 100%
Reproducible steps:
- Maximize your test application on the secondary monitor.
- Make sure it is active/has focus.
- Unplug the secondary monitor.
The Window will move to the other screen, the elements will scale to the correct DPI.
But the window size is incorrect.
The root cause is that the WM_DPICHANGED events and windows geometry events always arrive before the WM_DISPLAYCHANGE.
The geometry is set using the old monitors DPI as QWindowsWindow::checkForScreenChanged()
fails inside QWindowsWindow::handleDpiChanged() or QWindowsWindow::handleGeometryChange()
It cannot find the new monitor, as again WM_DISPLAYCHANGE has not arrived and there are two old monitors in the list at this point.
Once WM_DISPLAYCHANGE arrives, qt updates the correct screen of the window and its elements scale correctly.
But the geometry has not changed at this point, and no resizing of the actual window will occur. (unless manually done so)
I believe I have a fix and would like to open a PR, but first would like track the issue here
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-119851 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
559448,3 | Windows: Compare screens by name if hMonitor is stale | dev | qt/qtbase | Status: NEW | 0 | 0 |