From 5a08118c877efb5407a08f48cf31865faf813d7c Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 27 Dec 2023 21:28:03 +0100 Subject: sfjsh --- qt-wayland-scale-hack.patch | 80 ++++++++++++++++++++++++++++++++++++++++++++ src/frontend/qt_sdl/Screen.h | 2 ++ 2 files changed, 82 insertions(+) create mode 100644 qt-wayland-scale-hack.patch diff --git a/qt-wayland-scale-hack.patch b/qt-wayland-scale-hack.patch new file mode 100644 index 0000000..a874035 --- /dev/null +++ b/qt-wayland-scale-hack.patch @@ -0,0 +1,80 @@ +diff --git a/src/frontend/qt_sdl/Screen.cpp b/src/frontend/qt_sdl/Screen.cpp +index d8af6624..019ce246 100644 +--- a/src/frontend/qt_sdl/Screen.cpp ++++ b/src/frontend/qt_sdl/Screen.cpp +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + #ifndef _WIN32 + #ifndef APPLE + #include +@@ -596,23 +597,20 @@ void ScreenPanelGL::drawScreenGL() + glContext->SwapBuffers(); + } + +-qreal ScreenPanelGL::devicePixelRatioFromScreen() const ++qreal ScreenPanelGL::devicePixelRatioFromWindow() const + { +- const QScreen* screen_for_ratio = window()->windowHandle()->screen(); +- if (!screen_for_ratio) +- screen_for_ratio = QGuiApplication::primaryScreen(); +- +- return screen_for_ratio ? screen_for_ratio->devicePixelRatio() : static_cast(1); ++ QWindow* window = windowHandle(); ++ return window->devicePixelRatio(); + } + + int ScreenPanelGL::scaledWindowWidth() const + { +- return std::max(static_cast(std::ceil(static_cast(width()) * devicePixelRatioFromScreen())), 1); ++ return std::max(static_cast(std::ceil(static_cast(width()) * devicePixelRatioFromWindow())), 1); + } + + int ScreenPanelGL::scaledWindowHeight() const + { +- return std::max(static_cast(std::ceil(static_cast(height()) * devicePixelRatioFromScreen())), 1); ++ return std::max(static_cast(std::ceil(static_cast(height()) * devicePixelRatioFromWindow())), 1); + } + + std::optional ScreenPanelGL::getWindowInfo() +@@ -644,6 +642,7 @@ std::optional ScreenPanelGL::getWindowInfo() + + wi.display_connection = pni->nativeResourceForWindow("display", handle); + wi.window_handle = pni->nativeResourceForWindow("surface", handle); ++ qApp->processEvents(); + } + else + { +@@ -654,7 +653,7 @@ std::optional ScreenPanelGL::getWindowInfo() + + wi.surface_width = static_cast(scaledWindowWidth()); + wi.surface_height = static_cast(scaledWindowHeight()); +- wi.surface_scale = static_cast(devicePixelRatioFromScreen()); ++ wi.surface_scale = static_cast(devicePixelRatioFromWindow()); + + return wi; + } +diff --git a/src/frontend/qt_sdl/Screen.h b/src/frontend/qt_sdl/Screen.h +index b11df29b..79889a3f 100644 +--- a/src/frontend/qt_sdl/Screen.h ++++ b/src/frontend/qt_sdl/Screen.h +@@ -23,6 +23,8 @@ + #include "FrontendUtil.h" + #include "duckstation/gl/context.h" + ++#include ++ + #include + #include + #include +@@ -133,7 +135,7 @@ public: + void transferLayout(); + protected: + +- qreal devicePixelRatioFromScreen() const; ++ qreal devicePixelRatioFromWindow() const; + int scaledWindowWidth() const; + int scaledWindowHeight() const; + diff --git a/src/frontend/qt_sdl/Screen.h b/src/frontend/qt_sdl/Screen.h index b11df29..4c031e6 100644 --- a/src/frontend/qt_sdl/Screen.h +++ b/src/frontend/qt_sdl/Screen.h @@ -19,6 +19,8 @@ #ifndef SCREEN_H #define SCREEN_H +#include + #include "glad/glad.h" #include "FrontendUtil.h" #include "duckstation/gl/context.h" -- cgit v1.2.3