mirror of
https://git.citron-emu.org/citron/emulator
synced 2026-02-02 23:53:36 +00:00
fix(gamescope): Set High DPI AFTER GameScope construction
Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
@@ -6155,7 +6155,30 @@ static void SetHighDPIAttributes() {
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Set environment variables for AppImage compatibility
|
||||
// 1. Detect Gamescope/Steam Deck hardware
|
||||
const bool is_gamescope = qgetenv("XDG_CURRENT_DESKTOP") == "gamescope" ||
|
||||
!qgetenv("GAMESCOPE_WIDTH").isEmpty() ||
|
||||
!qgetenv("STEAM_DECK").isEmpty();
|
||||
|
||||
if (is_gamescope) {
|
||||
// Kill the SteamOS scaling requests before they can bloat the UI
|
||||
QGuiApplication::setDesktopSettingsAware(false);
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
|
||||
|
||||
// Force 1:1 pixel ratio
|
||||
qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
|
||||
qputenv("QT_SCALE_FACTOR", "1");
|
||||
qputenv("QT_SCREEN_SCALE_FACTORS", "1");
|
||||
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "0");
|
||||
qputenv("QT_FONT_DPI", "96");
|
||||
|
||||
// Ensure Gamescope compositor handles Citron menus correctly
|
||||
QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
|
||||
QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
|
||||
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "xdg-shell");
|
||||
}
|
||||
|
||||
// 2. NOW setup AppImage environment
|
||||
const bool is_appimage = !qgetenv("APPIMAGE").isEmpty();
|
||||
if (is_appimage) {
|
||||
qputenv("QT_WAYLAND_DISABLE_EXPLICIT_SYNC", "1");
|
||||
@@ -6216,27 +6239,6 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity);
|
||||
|
||||
// Gamescope/Steam Deck detection
|
||||
const bool is_gamescope = qgetenv("XDG_CURRENT_DESKTOP") == "gamescope" ||
|
||||
!qgetenv("GAMESCOPE_WIDTH").isEmpty() ||
|
||||
!qgetenv("STEAM_DECK").isEmpty();
|
||||
|
||||
if (is_gamescope) {
|
||||
// 1. Force the scale factor to exactly 1.0
|
||||
qputenv("QT_SCALE_FACTOR", "1");
|
||||
qputenv("QT_SCREEN_SCALE_FACTORS", "1");
|
||||
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "0");
|
||||
qputenv("QT_FONT_DPI", "96");
|
||||
|
||||
// 2. This must be called BEFORE the QApplication object is created
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
|
||||
|
||||
// 3. Ensure windowing system plays nice with Gamescope
|
||||
QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
|
||||
QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
|
||||
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "xdg-shell");
|
||||
}
|
||||
|
||||
QApplication app(argc, argv);
|
||||
#ifdef __linux__
|
||||
if (QGuiApplication::platformName().startsWith(QStringLiteral("wayland"))) {
|
||||
|
||||
Reference in New Issue
Block a user