Skip to content

qt: do not assume that the interface window is in the primary monitor with csd on Windows

Fatih Uzunoğlu requested to merge fuzun/vlc:qt/win32careaboutdpichange into master
  • GetSystemMetrics() function already scales most of the metrics for the primary monitor [1], evidently because Qt makes the application DPI aware.
  • Currently by multiplying the GetSystemMetrics() result with windowDpi / screenDpi, we apply the window's DPI which is what is wanted here.
  • If the window is in the primary monitor, there is no problem. If there are multiple monitors but they share the same DPI, there should also be no problem. But if there are multiple monitors that have different DPIs, in that case dragging would be problematic.
  • The solution that Windows recommends [2] is using GetSystemMetricsForDpi and GetDpiForWindow. Unfortunately these are only available on Windows 10, so I dynamically load the necessary library and resolve the symbols.
  • Handling WM_DPICHANGED and calling SetWindowPos() should not be necessary, because Qt already calls it to resize the window according to the new dpi.

[1] https://learn.microsoft.com/en-us/windows/win32/gdi/multiple-monitor-system-metrics

[2] https://learn.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows#updating-existing-applications

All assumptions here are theoretical, as I have no means checking how is the behavior currently when the window is moved to a different screen with different DPI. I have checked if this would cause regressions (Windows 11, 10, 7) for single monitor case, and I could not find.

Request review @chub.

Merge request reports

Loading