Priority: P2: Important
Affects Version/s: 5.15.4
Fix Version/s: None
Component/s: GUI: High-DPI
Multiple monitor setup, when creating another window it will be displayed half off screen.
DisplayOne: 1920x1080 at 100% DPI (main) axis 0.0
DisplayTwo: 1920x1080 at 150% DPI and the axis 1920.0
User has the application with high DPI enabled running on DisplayTwo.
User clicks the button to open a new window.
The window is opened on DisplayOne but is also half off screen.
1. When a window is first created it's default axis is 0.0
2. New screen will be created on the same screen as the cursor, as this is the default behavior.
3. When a window doesn't fit the screen Qt doesn't center the rect of the new window.
When creating the new window this flow seems to happen:
In the method `QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const` the requested geometry will have the axis of (0.0) (DisplayOne) because the new window doesn't have a parent.
Then in the method `QScreen *effectiveScreen(const QWindow *window)`, `QCursor::pos()` is used to get the QScreen (DisplayTwo) for the new window.
Next in the method `QRect QPlatformWindow::initialGeometry` Qt doesn't center the rect from the availableGeometry of DisplayTwo because the rect is too big for that screen.
In `QRect QPlatformWindow::initialGeometry` Qt is returning the result of `QHighDpi::toNativePixels(rect, screen);` where `rect` still has the axis of (0.0) and `screen` is DisplayTwo.
And the result of `QHighDpi::toNativePixels` will be a axis with a negative value.
Qt will use this axis to display the new window.