fix(overhaul): UI and resolution bugs for Steam Deck (Gamescope)

Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
Collecting
2026-01-04 18:43:43 +00:00
parent be95703bce
commit c91d9ac534

View File

@@ -29,18 +29,18 @@
namespace {
bool IsGamescope() {
static bool gamescope = qgetenv("XDG_CURRENT_DESKTOP") == "gamescope" ||
!qgetenv("GAMESCOPE_WIDTH").isEmpty();
static bool gamescope = qgetenv("XDG_CURRENT_DESKTOP") == "gamescope";
return gamescope;
}
}
VramOverlay::VramOverlay(QWidget* parent) : QWidget(parent) {
// Cast the parent (which is now 'this' from main.cpp) to get our data source
main_window = qobject_cast<GMainWindow*>(parent);
VramOverlay::VramOverlay(QWidget* parent) : QWidget(IsGamescope() ? nullptr : parent) {
if (parent) {
main_window = qobject_cast<GMainWindow*>(parent);
}
if (IsGamescope()) {
setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus);
setAttribute(Qt::WA_ShowWithoutActivating);
} else {
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
@@ -48,6 +48,7 @@ VramOverlay::VramOverlay(QWidget* parent) : QWidget(parent) {
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_WState_ExplicitShowHide);
// Branching Typography and Sizing
if (IsGamescope()) {
@@ -90,14 +91,15 @@ VramOverlay::VramOverlay(QWidget* parent) : QWidget(parent) {
VramOverlay::~VramOverlay() = default;
void VramOverlay::SetVisible(bool visible) {
if (is_visible == visible) return;
is_visible = visible;
is_enabled = visible;
is_visible = visible; // Properly sync the internal state
if (visible) {
show();
update_timer.start(1000);
} else {
update_timer.stop(); // Ensure the background loop stops updating
hide();
update_timer.stop();
}
}
@@ -260,25 +262,37 @@ void VramOverlay::mouseReleaseEvent(QMouseEvent* event) {
}
void VramOverlay::UpdateVramStats() {
if (!main_window) return;
if (!main_window || !is_enabled) return;
if (IsGamescope()) {
bool sub_window_visible = false;
for (QWidget* w : QApplication::topLevelWidgets()) {
if (w->isWindow() && w->isVisible() && w != main_window && w != this &&
!w->inherits("GRenderWindow") && !w->inherits("PerformanceOverlay") && !w->inherits("ControllerOverlay")) {
sub_window_visible = true;
bool ui_active = (QApplication::activePopupWidget() != nullptr);
if (!ui_active) {
for (QWidget* w : QApplication::topLevelWidgets()) {
if (w->isVisible() && w != main_window && w != this &&
!w->inherits("GRenderWindow") &&
!w->inherits("PerformanceOverlay") &&
!w->inherits("ControllerOverlay") &&
!w->inherits("VramOverlay")) {
ui_active = true;
break;
}
}
}
if (sub_window_visible) {
if (ui_active) {
if (!this->isHidden()) this->hide();
return;
}
}
if (is_visible && this->isHidden()) {
this->show();
if (this->isHidden()) {
this->show();
}
} else {
// Desktop: Respect the menu toggle strictly
if (is_enabled && this->isHidden()) {
this->show();
}
}
try {