From 487e59f7c26b96a58ccf5601f0681ddfb8ac8662 Mon Sep 17 00:00:00 2001 From: Luca Pattocchio Date: Mon, 30 Mar 2026 12:16:26 +0200 Subject: [PATCH] fix: store layout defaults to avoid stale widget reads on restart --- src/main.rs | 19 ++++++++++--------- src/ui/window.rs | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1bb37322..66e071c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,8 @@ use crate::protos::QueryResponseObject; use crate::protos::generated_proto::query::{QueryResponse, query_response}; use crate::providers::setup_providers; use crate::state::{ - get_last_query, get_parameter_height, get_parameter_max_height, get_parameter_max_width, + get_last_query, + get_parameter_height, get_parameter_max_height, get_parameter_max_width, get_parameter_min_height, get_parameter_min_width, get_parameter_width, get_placeholder, get_provider, get_theme, has_elephant, has_theme, is_connected, is_dmenu, is_dmenu_keep_open, is_emergency, is_input_only, is_no_hints, is_no_search, is_param_close, is_password_mode, @@ -712,42 +713,42 @@ fn apply_flag_logic() { } if let Some(val) = get_parameter_height() { - set_initial_height(Some(w.box_wrapper.height_request())); + set_initial_height(Some(w.default_box_height)); w.box_wrapper.set_height_request(val); } if let Some(val) = get_parameter_width() { - set_initial_width(Some(w.box_wrapper.width_request())); + set_initial_width(Some(w.default_box_width)); w.box_wrapper.set_width_request(val); } if let Some(val) = get_parameter_min_width() { - set_initial_min_width(Some(w.scroll.min_content_width())); + set_initial_min_width(Some(w.default_scroll_min_width)); w.scroll.set_min_content_width(val); } if let Some(val) = get_parameter_min_height() { - set_initial_min_height(Some(w.scroll.min_content_height())); + set_initial_min_height(Some(w.default_scroll_min_height)); w.scroll.set_min_content_height(val); } if let Some(val) = get_parameter_max_width() { - set_initial_max_width(Some(w.scroll.max_content_width())); + set_initial_max_width(Some(w.default_scroll_max_width)); w.scroll.set_max_content_width(val); } if let Some(val) = get_parameter_max_height() { - set_initial_max_height(Some(w.scroll.max_content_height())); + set_initial_max_height(Some(w.default_scroll_max_height)); w.scroll.set_max_content_height(val); } if get_parameter_min_width().is_some() || get_parameter_max_width().is_some() { - set_initial_width(Some(w.box_wrapper.width_request())); + set_initial_width(Some(w.default_box_width)); w.box_wrapper.set_width_request(-1); } if get_parameter_min_height().is_some() || get_parameter_max_height().is_some() { - set_initial_height(Some(w.box_wrapper.height_request())); + set_initial_height(Some(w.default_box_height)); w.box_wrapper.set_height_request(-1); } diff --git a/src/ui/window.rs b/src/ui/window.rs index 6d0f7d57..7b5d7a3b 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -112,6 +112,12 @@ pub struct WindowData { pub content_container: gtk4::Box, pub box_wrapper: gtk4::Box, pub error: gtk4::Label, + pub default_box_height: i32, + pub default_box_width: i32, + pub default_scroll_max_height: i32, + pub default_scroll_min_height: i32, + pub default_scroll_max_width: i32, + pub default_scroll_min_width: i32, } pub fn with_window(f: F) -> R @@ -339,8 +345,21 @@ pub fn setup_theme_window(app: &Application, val: &Theme) -> Result