summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Morph2023-01-25 21:16:04 -0500
committerGravatar Morph2023-01-25 21:16:04 -0500
commit5be85c556ed05cd9d751fb7b3f8a331800ee573d (patch)
tree68ae7ce7fbb70f74ae8939917f0f431c4e33ebc2
parentmain: Enable High DPI fixes for Qt >= 5.14 (diff)
downloadyuzu-5be85c556ed05cd9d751fb7b3f8a331800ee573d.tar.gz
yuzu-5be85c556ed05cd9d751fb7b3f8a331800ee573d.tar.xz
yuzu-5be85c556ed05cd9d751fb7b3f8a331800ee573d.zip
main: Use passthrough scaling for non-windows OSes
They should be better than windows when handling fractional scaling ratios.
-rw-r--r--src/yuzu/main.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 82e4adfe0..53249426c 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -4401,6 +4401,10 @@ void GMainWindow::changeEvent(QEvent* event) {
4401#endif 4401#endif
4402 4402
4403static void SetHighDPIAttributes() { 4403static void SetHighDPIAttributes() {
4404#ifdef _WIN32
4405 // For Windows, we want to avoid scaling artifacts on fractional scaling ratios.
4406 // This is done by setting the optimal scaling policy for the primary screen.
4407
4404 // Create a temporary QApplication. 4408 // Create a temporary QApplication.
4405 int temp_argc = 0; 4409 int temp_argc = 0;
4406 char** temp_argv = nullptr; 4410 char** temp_argv = nullptr;
@@ -4428,9 +4432,6 @@ static void SetHighDPIAttributes() {
4428 // Get the lower of the 2 ratios and truncate, this is the maximum integer scale. 4432 // Get the lower of the 2 ratios and truncate, this is the maximum integer scale.
4429 const float max_ratio = std::trunc(std::min(width_ratio, height_ratio)); 4433 const float max_ratio = std::trunc(std::min(width_ratio, height_ratio));
4430 4434
4431 QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
4432 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
4433
4434 if (max_ratio > real_ratio) { 4435 if (max_ratio > real_ratio) {
4435 QApplication::setHighDpiScaleFactorRoundingPolicy( 4436 QApplication::setHighDpiScaleFactorRoundingPolicy(
4436 Qt::HighDpiScaleFactorRoundingPolicy::Round); 4437 Qt::HighDpiScaleFactorRoundingPolicy::Round);
@@ -4438,6 +4439,14 @@ static void SetHighDPIAttributes() {
4438 QApplication::setHighDpiScaleFactorRoundingPolicy( 4439 QApplication::setHighDpiScaleFactorRoundingPolicy(
4439 Qt::HighDpiScaleFactorRoundingPolicy::Floor); 4440 Qt::HighDpiScaleFactorRoundingPolicy::Floor);
4440 } 4441 }
4442#else
4443 // Other OSes should be better than Windows at fractional scaling.
4444 QApplication::setHighDpiScaleFactorRoundingPolicy(
4445 Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
4446#endif
4447
4448 QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
4449 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
4441} 4450}
4442 4451
4443int main(int argc, char* argv[]) { 4452int main(int argc, char* argv[]) {