mirror of
https://git.citron-emu.org/citron/emulator
synced 2026-01-30 06:23:29 +00:00
revert 7fec665c00
revert fix(gamescope): Remove scale_ratio & add QStyleFactory Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
@@ -95,7 +95,6 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||
#include <QStandardPaths>
|
||||
#include <QStatusBar>
|
||||
#include <QString>
|
||||
#include <QStyleFactory>
|
||||
#include <QSysInfo>
|
||||
#include <QUrl>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
@@ -856,13 +855,15 @@ 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)),
|
||||
QSize(w, h));
|
||||
software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y) / scale_ratio),
|
||||
QSize(w, h) / scale_ratio);
|
||||
}
|
||||
|
||||
void GMainWindow::SoftwareKeyboardShowTextCheck(
|
||||
@@ -895,10 +896,11 @@ void GMainWindow::SoftwareKeyboardShowInline(
|
||||
(1.0f - appear_parameters.key_top_scale_y))));
|
||||
const auto w = static_cast<int>(layout.screen.GetWidth() * appear_parameters.key_top_scale_x);
|
||||
const auto h = static_cast<int>(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)),
|
||||
QSize(w, h));
|
||||
render_window->mapToGlobal(QPoint(x, y) / scale_ratio),
|
||||
QSize(w, h) / scale_ratio);
|
||||
}
|
||||
|
||||
void GMainWindow::SoftwareKeyboardHideInline() {
|
||||
@@ -978,11 +980,13 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
|
||||
}
|
||||
|
||||
const auto& layout = render_window->GetFramebufferLayout();
|
||||
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<qreal>(layout.screen.GetWidth()) /
|
||||
static_cast<qreal>(Layout::ScreenUndocked::Width));
|
||||
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<qreal>(layout.screen.GetWidth() / scale_ratio) /
|
||||
static_cast<qreal>(Layout::ScreenUndocked::Width));
|
||||
|
||||
web_applet->setFocus();
|
||||
web_applet->show();
|
||||
@@ -6107,11 +6111,15 @@ static void SetHighDPIAttributes() {
|
||||
FreeLibrary(shcore);
|
||||
}
|
||||
#else
|
||||
if (is_gamescope) {
|
||||
// PassThrough prevents Qt6 from recursively expanding layouts to fit rounded DPIs
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
|
||||
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
}
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6122,20 +6130,19 @@ int main(int argc, char* argv[]) {
|
||||
!qgetenv("STEAM_DECK").isEmpty();
|
||||
|
||||
if (is_gamescope) {
|
||||
// 1. Kill the scaling system entirely
|
||||
// Kill the SteamOS scaling requests before they can bloat the UI
|
||||
QGuiApplication::setDesktopSettingsAware(false);
|
||||
|
||||
// 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");
|
||||
|
||||
// 2. Force font DPI to standard
|
||||
// Steam Deck has a high physical DPI. Hard-coding 96 DPI prevents text
|
||||
// from being oversized in dialogs like "About" or "Updater".
|
||||
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");
|
||||
@@ -6209,19 +6216,6 @@ 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);
|
||||
@@ -6229,6 +6223,7 @@ 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
|
||||
@@ -6240,6 +6235,7 @@ 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"),
|
||||
@@ -6249,6 +6245,19 @@ 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};
|
||||
@@ -6259,9 +6268,11 @@ 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();
|
||||
@@ -6644,4 +6655,3 @@ void GMainWindow::OnRunAutoloaderFromGameList() {
|
||||
ConfigureFilesystem fs_logic(this);
|
||||
fs_logic.OnRunAutoloader(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user