summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar liamwhite2023-02-14 09:11:15 -0500
committerGravatar GitHub2023-02-14 09:11:15 -0500
commitd87db919f908ce7b8d883ea9a9442f1de5d2c1e8 (patch)
treebbf26b639360d3e97be69cb090c25d82e13ae47b /src
parentMerge pull request #9784 from m-HD/master (diff)
parentmain: Fix borderless fullscreen for high dpi scaled displays (diff)
downloadyuzu-d87db919f908ce7b8d883ea9a9442f1de5d2c1e8.tar.gz
yuzu-d87db919f908ce7b8d883ea9a9442f1de5d2c1e8.tar.xz
yuzu-d87db919f908ce7b8d883ea9a9442f1de5d2c1e8.zip
Merge pull request #9793 from Morph1984/borderless-hidpi
main: Fix borderless fullscreen for high dpi scaled displays
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/main.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index c278d8dab..62dfc526a 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -3167,8 +3167,20 @@ void GMainWindow::ShowFullscreen() {
3167 window->hide(); 3167 window->hide();
3168 window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint); 3168 window->setWindowFlags(window->windowFlags() | Qt::FramelessWindowHint);
3169 const auto screen_geometry = GuessCurrentScreen(window)->geometry(); 3169 const auto screen_geometry = GuessCurrentScreen(window)->geometry();
3170 // NB: On Windows, a borderless window will be treated the same as exclusive fullscreen
3171 // when the window geometry matches the physical dimensions of the screen.
3172 // However, with High DPI scaling, when the devicePixelRatioF() is > 1, the borderless
3173 // window apparently is not treated as exclusive fullscreen and functions correctly.
3174 // One can verify and replicate this behavior by using a high resolution (4K) display,
3175 // and switching between 100% and 200% scaling in Windows' display settings.
3176 // At 100%, without the addition of 1, it is treated as exclusive fullscreen.
3177 // At 200%, with or without the addition of 1, it is treated as borderless windowed.
3178 // Therefore, we can use (read: abuse) this difference in behavior to fix this issue for
3179 // those with higher resolution displays when the Qt scaling ratio is > 1.
3180 // Should this behavior be changed in the future, please revisit this workaround.
3181 const bool must_add_one = devicePixelRatioF() == 1.0f;
3170 window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(), 3182 window->setGeometry(screen_geometry.x(), screen_geometry.y(), screen_geometry.width(),
3171 screen_geometry.height() + 1); 3183 screen_geometry.height() + (must_add_one ? 1 : 0));
3172 window->raise(); 3184 window->raise();
3173 window->showNormal(); 3185 window->showNormal();
3174 }; 3186 };