qt: do not assume that the interface window is in the primary monitor in `CSDWin32EventHandler`
- `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
parent
7e31157b
No related branches found
No related tags found