diff --git a/src/citron/main.cpp b/src/citron/main.cpp index 3c8c77d99..eb4b6e52d 100644 --- a/src/citron/main.cpp +++ b/src/citron/main.cpp @@ -95,6 +95,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include #include #include +#include #include #include #include @@ -855,15 +856,13 @@ void GMainWindow::SoftwareKeyboardShowNormal() { } const auto& layout = render_window->GetFramebufferLayout(); - const auto x = layout.screen.left; const auto y = layout.screen.top; const auto w = layout.screen.GetWidth(); const auto h = layout.screen.GetHeight(); - const auto scale_ratio = devicePixelRatioF(); - software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y) / scale_ratio), - QSize(w, h) / scale_ratio); + software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y)), + QSize(w, h)); } void GMainWindow::SoftwareKeyboardShowTextCheck( @@ -896,11 +895,10 @@ void GMainWindow::SoftwareKeyboardShowInline( (1.0f - appear_parameters.key_top_scale_y)))); const auto w = static_cast(layout.screen.GetWidth() * appear_parameters.key_top_scale_x); const auto h = static_cast(layout.screen.GetHeight() * appear_parameters.key_top_scale_y); - const auto scale_ratio = devicePixelRatioF(); software_keyboard->ShowInlineKeyboard(std::move(appear_parameters), - render_window->mapToGlobal(QPoint(x, y) / scale_ratio), - QSize(w, h) / scale_ratio); + render_window->mapToGlobal(QPoint(x, y)), + QSize(w, h)); } void GMainWindow::SoftwareKeyboardHideInline() { @@ -980,13 +978,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url, } const auto& layout = render_window->GetFramebufferLayout(); - const auto scale_ratio = devicePixelRatioF(); - web_applet->resize(layout.screen.GetWidth() / scale_ratio, - layout.screen.GetHeight() / scale_ratio); - web_applet->move(layout.screen.left / scale_ratio, - (layout.screen.top / scale_ratio) + menuBar()->height()); - web_applet->setZoomFactor(static_cast(layout.screen.GetWidth() / scale_ratio) / - static_cast(Layout::ScreenUndocked::Width)); + web_applet->resize(layout.screen.GetWidth(), layout.screen.GetHeight()); + web_applet->move(layout.screen.left, + (layout.screen.top) + menuBar()->height()); + web_applet->setZoomFactor(static_cast(layout.screen.GetWidth()) / + static_cast(Layout::ScreenUndocked::Width)); web_applet->setFocus(); web_applet->show(); @@ -6111,15 +6107,11 @@ static void SetHighDPIAttributes() { FreeLibrary(shcore); } #else - if (is_gamescope) { - // Force 1:1 pixel mapping for Steam Deck to prevent bloated windows. - QGuiApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::Floor); - } else { - // Standard Linux desktops handle fractional scaling better via PassThrough - QGuiApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); - } +if (is_gamescope) { + // PassThrough prevents Qt6 from recursively expanding layouts to fit rounded DPIs + QGuiApplication::setHighDpiScaleFactorRoundingPolicy( + Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); +} #endif } @@ -6130,19 +6122,20 @@ int main(int argc, char* argv[]) { !qgetenv("STEAM_DECK").isEmpty(); if (is_gamescope) { - // Kill the SteamOS scaling requests before they can bloat the UI - QGuiApplication::setDesktopSettingsAware(false); - - // Force 1:1 pixel ratio + // 1. Kill the scaling system entirely qputenv("QT_ENABLE_HIGHDPI_SCALING", "0"); qputenv("QT_SCALE_FACTOR", "1"); - qputenv("QT_SCREEN_SCALE_FACTORS", "1"); qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "0"); - // Steam Deck has a high physical DPI. Hard-coding 96 DPI prevents text - // from being oversized in dialogs like "About" or "Updater". + // 2. Force font DPI to standard qputenv("QT_FONT_DPI", "96"); + // 3. Stop Qt from querying physical hardware DPI for text/widgets + qputenv("QT_USE_PHYSICAL_DPI", "0"); + + // 4. Force the legacy coordinate system for X11/XCB + qputenv("QT_SCREEN_SCALE_FACTORS", "1"); + // FORCE X11 backend: Qt 6 scaling overrides are reliably respected under XCB in Gamescope. // Wayland mode in Gamescope often ignores scaling overrides for child windows. qputenv("QT_QPA_PLATFORM", "xcb"); @@ -6216,6 +6209,19 @@ int main(int argc, char* argv[]) { QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); QApplication app(argc, argv); + if (is_gamescope) { + app.setStyleSheet(app.styleSheet().append(QStringLiteral( + "QDialog { " + " font-size: 10pt; " + " margin: 0px; " + " padding: 0px; " + "}" + "QLabel { font-size: 10pt; }" + ))); + + app.setStyle(QStyleFactory::create(QStringLiteral("Fusion"))); + } + #ifdef __linux__ if (QGuiApplication::platformName().startsWith(QStringLiteral("wayland"))) { Settings::values.is_wayland_platform.SetValue(true); @@ -6223,7 +6229,6 @@ int main(int argc, char* argv[]) { #endif #ifdef CITRON_USE_AUTO_UPDATER - // Check for and apply staged updates before starting the main application std::filesystem::path app_dir = std::filesystem::path(QCoreApplication::applicationDirPath().toStdString()); #ifdef _WIN32 @@ -6235,7 +6240,6 @@ int main(int argc, char* argv[]) { } catch (...) {} } #else - // On Linux, apply staged updates at startup if (Updater::UpdaterService::HasStagedUpdate(app_dir)) { if (Updater::UpdaterService::ApplyStagedUpdate(app_dir)) { QMessageBox::information(nullptr, QObject::tr("Update Applied"), @@ -6245,19 +6249,6 @@ int main(int argc, char* argv[]) { #endif #endif -#ifdef _WIN32 - OverrideWindowsFont(); -#endif - - - // Workaround for QTBUG-85409 -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - const QLocale locale = QLocale::system(); - if (QStringLiteral("\u3008") == locale.toString(1)) { - QLocale::setDefault(QLocale::system().name()); - } -#endif - setlocale(LC_ALL, "C"); GMainWindow main_window{std::move(config), has_broken_vulkan}; @@ -6268,11 +6259,9 @@ int main(int argc, char* argv[]) { if (is_gamescope) { QTimer::singleShot(200, &main_window, [&main_window]() { main_window.showMaximized(); - if (main_window.layout()) { main_window.layout()->activate(); } - main_window.update(); main_window.raise(); main_window.activateWindow(); @@ -6655,3 +6644,4 @@ void GMainWindow::OnRunAutoloaderFromGameList() { ConfigureFilesystem fs_logic(this); fs_logic.OnRunAutoloader(true); } +