From abcc0eef0aeac58286177b7cef87092bd351d478 Mon Sep 17 00:00:00 2001 From: kunkundi Date: Wed, 11 Nov 2026 11:26:27 +0800 Subject: [PATCH] [fix] restore main window size after display resolution changes --- .../src/gui/application/gui_application.cpp | 4 ++-- .../gui/features/gallery/gallery_window_state.h | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/gui/application/gui_application.cpp b/apps/desktop/src/gui/application/gui_application.cpp index 994b4d31..aaef6084 100644 --- a/apps/desktop/src/gui/application/gui_application.cpp +++ b/apps/desktop/src/gui/application/gui_application.cpp @@ -6455,14 +6455,14 @@ void GuiApplication::SyncWindowGeometry(bool gallery_window) { const bool fullscreen = window.is_fullscreen(); const bool maximized = window.is_maximized(); #endif - if (!transitioning && placement.RecoverUndersized(wall_mode, window.position(), current_size, + if (!transitioning && placement.RecoverSizeMismatch(wall_mode, window.position(), current_size, window.scale_factor(), window.is_visible(), window.is_minimized(), fullscreen, maximized, compact_height, compact_width)) { ui_->restore_ticks[gallery_window] = 0; const auto target = placement.RestoreSize(wall_mode, window.scale_factor(), compact_height, compact_width); - LOG_WARN("DeskHub undersized window: wall={} client={}x{} scale={}; restoring={}x{}", + LOG_WARN("DeskHub window size mismatch: wall={} client={}x{} scale={}; restoring={}x{}", wall_mode, current_size.width, current_size.height, window.scale_factor(), target.width, target.height); } diff --git a/apps/desktop/src/gui/features/gallery/gallery_window_state.h b/apps/desktop/src/gui/features/gallery/gallery_window_state.h index c708da9d..58cea84b 100644 --- a/apps/desktop/src/gui/features/gallery/gallery_window_state.h +++ b/apps/desktop/src/gui/features/gallery/gallery_window_state.h @@ -45,7 +45,7 @@ struct WindowState { } } - bool RecoverUndersized(bool wall, slint::PhysicalPosition position, + bool RecoverSizeMismatch(bool wall, slint::PhysicalPosition position, slint::PhysicalSize size, float scale, bool visible, bool minimized, bool fullscreen, bool maximized, float compact_height = 486, @@ -53,8 +53,16 @@ struct WindowState { // Hidden/minimized/uninitialized windows can report temporary tiny bounds. // Leave those alone, and let an in-flight restoration retain its target. if (Restoring() || !visible || minimized || fullscreen || maximized || - size.width == 0 || size.height == 0 || - !IsUndersized(size, scale, compact_height, compact_width)) + size.width == 0 || size.height == 0) + return false; + // Display mode/DPI changes can enlarge the fixed connection window as + // well as shrink it. Restore both directions at the current scale; the + // resizable gallery only needs recovery below its minimum dimensions. + const bool mismatch = + wall ? IsUndersized(size, scale, compact_height, compact_width) + : !SameSize(size, RestoreSize(false, scale, compact_height, + compact_width)); + if (!mismatch) return false; if (wall) { wall_position = position;