From 2787e63d8ecd0f4578ab47c6ca5cf73c0bce1844 Mon Sep 17 00:00:00 2001 From: Nirusu Date: Fri, 12 Feb 2021 21:50:40 +0100 Subject: [PATCH] UI: Fix screen resolution for canvas size In #3988, @RytoEx mentioned that the recent Qt upgrade to 5.15.2 introduced a regression in which Qt begins returning DPI/scaling aware resolutions for each screen. While this was fixed for new profiles, this was not reflected in the choice for the Canvas (Base) Resolution in the Settings screen yet. This commits fixes this issue, and calculates the correct physical screen size again, respecting per-screen DPI scaling. --- UI/window-basic-settings.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index efcf1bab1..a377a1121 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -1563,7 +1563,15 @@ void OBSBasicSettings::LoadResolutionLists() for (QScreen *screen : QGuiApplication::screens()) { QSize as = screen->size(); - addRes(as.width(), as.height()); + uint32_t as_width = as.width(); + uint32_t as_height = as.height(); + + // Calculate physical screen resolution based on the virtual screen resolution + // They might differ if scaling is enabled, e.g. for HiDPI screens + as_width = round(as_width * screen->devicePixelRatio()); + as_height = round(as_height * screen->devicePixelRatio()); + + addRes(as_width, as_height); } addRes(1920, 1080);