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.
This commit is contained in:
Nirusu 2021-03-26 01:24:42 +01:00 committed by Jim
parent b98bad1f30
commit a52012e8c5

View File

@ -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);
}