Browse Source

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.
Nirusu 4 years ago
parent
commit
a52012e8c5
1 changed files with 10 additions and 3 deletions
  1. 10 3
      UI/window-basic-auto-config.cpp

+ 10 - 3
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);
 	}