From a52012e8c586e1ff63bf7b79d8b27fb9af1cf31c Mon Sep 17 00:00:00 2001 From: Nirusu Date: Fri, 26 Mar 2021 01:24:42 +0100 Subject: [PATCH] UI: Fix canvas resolution in auto-config Fix the returned display resolution when scaling is enabled to determine the correct canvas resolution in the auto-config utility, using the same approach as in 2787e63. This fixes #4298. --- UI/window-basic-auto-config.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/UI/window-basic-auto-config.cpp b/UI/window-basic-auto-config.cpp index 39b341811..5c8102d85 100644 --- a/UI/window-basic-auto-config.cpp +++ b/UI/window-basic-auto-config.cpp @@ -157,13 +157,20 @@ AutoConfigVideoPage::AutoConfigVideoPage(QWidget *parent) for (int i = 0; i < screens.size(); i++) { QScreen *screen = screens[i]; QSize as = screen->size(); + int as_width = as.width(); + int as_height = as.height(); - encRes = int(as.width() << 16) | int(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()); + + encRes = as_width << 16 | as_height; QString str = QTStr(RES_USE_DISPLAY) .arg(QString::number(i + 1), - QString::number(as.width()), - QString::number(as.height())); + QString::number(as_width), + QString::number(as_height)); ui->canvasRes->addItem(str, encRes); }