diff --git a/examples/worf-warden/Readme.md b/examples/worf-warden/Readme.md index 876e8a7..4e83a1e 100644 --- a/examples/worf-warden/Readme.md +++ b/examples/worf-warden/Readme.md @@ -2,6 +2,7 @@ Simple password manager build upon these additional tools aside worf * [rbw](https://github.com/doy/rbw) +* * [pinentry](https://www.gnupg.org/related_software/pinentry/index.en.html) is required to show a dialog show password entry * As worf warden * [ydotool](https://github.com/ReimuNotMoe/ydotool) diff --git a/worf/src/lib/config.rs b/worf/src/lib/config.rs index 324c208..ab4a0fa 100644 --- a/worf/src/lib/config.rs +++ b/worf/src/lib/config.rs @@ -471,6 +471,9 @@ pub struct Config { #[clap(short = 'm', long = "allow-markup")] allow_markup: Option, + /// If set to a value a custom cache file will be used + /// instead the default one associated with the selected mode. + /// May also be for usage in the api #[clap(short = 'k', long = "cache-file")] cache_file: Option, diff --git a/worf/src/lib/gui.rs b/worf/src/lib/gui.rs index 6a6802a..4375c6b 100644 --- a/worf/src/lib/gui.rs +++ b/worf/src/lib/gui.rs @@ -654,15 +654,22 @@ fn create_background(config: &Config) -> Option { .decorated(false) .resizable(false) .fullscreened(config.blurred_background_fullscreen()) - // arbitrary huge window so it fills the whole screen - .default_width(100_000) - .default_height(100_000) + .default_width(100) + .default_height(100) .build(); if !config.normal_window() { background.set_layer(config.layer().into()); } background.set_widget_name("background"); background.set_namespace(Some("worf")); + background.connect_is_active_notify(move |window| { + let Some(geometry) = get_monitor_geometry(window.surface().as_ref()) else { + return; + }; + window.set_height_request(geometry.height()); + window.set_width_request(geometry.width()); + }); + Some(background) } else { None @@ -1045,7 +1052,7 @@ where select_first_visible_child(&*lock, &ui.main_box); drop(lock); if meta.config.dynamic_lines() { - if let Some(geometry) = get_monitor_geometry(ui) { + if let Some(geometry) = get_monitor_geometry(ui.window.surface().as_ref()) { let height = calculate_dynamic_lines_window_height(&meta.config, ui, geometry); ui.window.set_height_request(height); } @@ -1195,7 +1202,7 @@ fn sort_menu_items_by_score( } fn window_show_resize(config: &Config, ui: &Rc>) { - let Some(geometry) = get_monitor_geometry(ui) else { + let Some(geometry) = get_monitor_geometry(ui.window.surface().as_ref()) else { return; }; @@ -1238,14 +1245,13 @@ fn calculate_dynamic_lines_window_height( } } -fn get_monitor_geometry(ui: &UiElements) -> Option { - // Get the surface and associated monitor geometry - let surface = ui.window.surface()?; - - let display = surface.display(); - let monitor = display.monitor_at_surface(&surface)?; - let geometry = monitor.geometry(); - Some(geometry) +fn get_monitor_geometry(surface: Option<&gdk4::Surface>) -> Option { + surface + .and_then(|surface| { + let display = surface.display(); + display.monitor_at_surface(surface) + }) + .map(|monitor| monitor.geometry()) } #[allow(clippy::cast_possible_truncation)] // does not matter for calculating height