Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.0
-
None
-
Arch Linux, Qt 5.15.0
Description
If a second monitor is added or removed before starting a Qt application (e.g. when a laptop is docked or undocked), QWidget::restoreGeometry() no longer restores the size of the application on startup. The behavior is reproducible with Qt 5 applications such as KeePassXC and Audacious.
I believe the culprit is this code:
// Sanity check bailing out when large variations of screen sizes occur due to // high DPI scaling or different levels of DPI awareness. if (restoredScreenWidth) { const qreal factor = qreal(restoredScreenWidth) / screenWidthF; if (factor < 0.8 || factor > 1.25) return false;
Note that restoredScreenWidth is actually the total desktop width (all monitors). It does not seem like a good idea to assume that DPI has changed every time the desktop width changes, since the width can change for other reasons as well.