blurred background now only fills active monitor
This commit is contained in:
parent
8770a31971
commit
3c8fafb50e
3 changed files with 23 additions and 13 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Simple password manager build upon these additional tools aside worf
|
Simple password manager build upon these additional tools aside worf
|
||||||
* [rbw](https://github.com/doy/rbw)
|
* [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
|
* [pinentry](https://www.gnupg.org/related_software/pinentry/index.en.html) is required to show a dialog show password entry
|
||||||
* As worf warden
|
* As worf warden
|
||||||
* [ydotool](https://github.com/ReimuNotMoe/ydotool)
|
* [ydotool](https://github.com/ReimuNotMoe/ydotool)
|
||||||
|
|
|
@ -471,6 +471,9 @@ pub struct Config {
|
||||||
#[clap(short = 'm', long = "allow-markup")]
|
#[clap(short = 'm', long = "allow-markup")]
|
||||||
allow_markup: Option<bool>,
|
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")]
|
#[clap(short = 'k', long = "cache-file")]
|
||||||
cache_file: Option<String>,
|
cache_file: Option<String>,
|
||||||
|
|
||||||
|
|
|
@ -654,15 +654,22 @@ fn create_background(config: &Config) -> Option<ApplicationWindow> {
|
||||||
.decorated(false)
|
.decorated(false)
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.fullscreened(config.blurred_background_fullscreen())
|
.fullscreened(config.blurred_background_fullscreen())
|
||||||
// arbitrary huge window so it fills the whole screen
|
.default_width(100)
|
||||||
.default_width(100_000)
|
.default_height(100)
|
||||||
.default_height(100_000)
|
|
||||||
.build();
|
.build();
|
||||||
if !config.normal_window() {
|
if !config.normal_window() {
|
||||||
background.set_layer(config.layer().into());
|
background.set_layer(config.layer().into());
|
||||||
}
|
}
|
||||||
background.set_widget_name("background");
|
background.set_widget_name("background");
|
||||||
background.set_namespace(Some("worf"));
|
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)
|
Some(background)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -1045,7 +1052,7 @@ where
|
||||||
select_first_visible_child(&*lock, &ui.main_box);
|
select_first_visible_child(&*lock, &ui.main_box);
|
||||||
drop(lock);
|
drop(lock);
|
||||||
if meta.config.dynamic_lines() {
|
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);
|
let height = calculate_dynamic_lines_window_height(&meta.config, ui, geometry);
|
||||||
ui.window.set_height_request(height);
|
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>>) {
|
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;
|
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> {
|
fn get_monitor_geometry(surface: Option<&gdk4::Surface>) -> Option<Rectangle> {
|
||||||
// Get the surface and associated monitor geometry
|
surface
|
||||||
let surface = ui.window.surface()?;
|
.and_then(|surface| {
|
||||||
|
let display = surface.display();
|
||||||
let display = surface.display();
|
display.monitor_at_surface(surface)
|
||||||
let monitor = display.monitor_at_surface(&surface)?;
|
})
|
||||||
let geometry = monitor.geometry();
|
.map(|monitor| monitor.geometry())
|
||||||
Some(geometry)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::cast_possible_truncation)] // does not matter for calculating height
|
#[allow(clippy::cast_possible_truncation)] // does not matter for calculating height
|
||||||
|
|
Loading…
Add table
Reference in a new issue