blurred background now only fills active monitor

This commit is contained in:
Alexander Mohr 2025-06-18 20:12:57 +02:00
parent 8770a31971
commit 3c8fafb50e
3 changed files with 23 additions and 13 deletions

View file

@ -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)

View file

@ -471,6 +471,9 @@ pub struct Config {
#[clap(short = 'm', long = "allow-markup")]
allow_markup: Option<bool>,
/// 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<String>,

View file

@ -654,15 +654,22 @@ fn create_background(config: &Config) -> Option<ApplicationWindow> {
.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<T: Clone>(
}
fn window_show_resize<T: Clone + 'static>(config: &Config, ui: &Rc<UiElements<T>>) {
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<T: Clone + 'static>(
}
}
fn get_monitor_geometry<T: Clone>(ui: &UiElements<T>) -> Option<Rectangle> {
// Get the surface and associated monitor geometry
let surface = ui.window.surface()?;
fn get_monitor_geometry(surface: Option<&gdk4::Surface>) -> Option<Rectangle> {
surface
.and_then(|surface| {
let display = surface.display();
let monitor = display.monitor_at_surface(&surface)?;
let geometry = monitor.geometry();
Some(geometry)
display.monitor_at_surface(surface)
})
.map(|monitor| monitor.geometry())
}
#[allow(clippy::cast_possible_truncation)] // does not matter for calculating height