fix sometimes broken line flag

This commit is contained in:
Alexander Mohr 2025-05-25 13:18:11 +02:00
parent 818cc41aac
commit 3749a10137
3 changed files with 10 additions and 35 deletions

5
Cargo.lock generated
View file

@ -619,8 +619,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "freedesktop-file-parser"
version = "0.1.3"
source = "git+https://github.com/alexmohr/desktop_file_parser?branch=fix-format-and-clippy#2c42c2ce28f474b7b663037b344b2bee9be21ef1"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9874624824ee3ca96cf728451815bd93ae3978cdcd715c1d098edef7130fb0da"
dependencies = [
"freedesktop-icons",
"thiserror 2.0.12",

View file

@ -41,8 +41,7 @@ toml = "0.8.20"
serde_json = "1.0.140"
crossbeam = "0.8.4"
libc = "0.2.171"
freedesktop-file-parser = { git = "https://github.com/alexmohr/desktop_file_parser", branch = "fix-format-and-clippy" }
# freedesktop-file-parser = "0.1.3"
freedesktop-file-parser = "0.2.0"
strsim = "0.11.1"
dirs = "6.0.0"
which = "7.0.3"

View file

@ -1144,42 +1144,17 @@ fn window_show_resize<T: Clone + 'static>(config: &Config, ui: &Rc<UiElements<T>
return;
};
// Calculate target height based on either lines or absolute height
let target_height = if let Some(lines) = config.lines() {
let (_, _, _, height_search) = ui.search.measure(Orientation::Vertical, 10_000);
let widget = {
let height = {
let lock = ui.menu_rows.read().unwrap();
lock.iter().next().map(|(w, _)| w.clone())
lock.iter().find_map(|(fb, _)| {
let (_, _, _, baseline) = fb.measure(Orientation::Vertical, 10_000);
if baseline > 0 { Some(baseline) } else { None }
})
};
if let Some(widget) = widget {
log::debug!(
"widget, mapped: {}, realized {}, visible {}, has child {}, baseline {}, pref size {:#?}",
widget.is_mapped(),
widget.is_realized(),
widget.is_visible(),
widget.child().is_some(),
widget.allocated_baseline(),
widget.preferred_size()
);
if !widget.is_mapped() {
let c_clone = config.clone();
let ui_clone = Rc::clone(ui);
widget.connect_realize(move |_| {
window_show_resize(&c_clone, &Rc::clone(&ui_clone));
});
return;
}
let (_, nat, _, baseline) = widget.measure(Orientation::Vertical, 10_000);
log::debug!("natural height base {baseline}, nat {nat}");
// todo fix this eventually properly, so baseline is always set and not only in 85% of cases.
let height = if baseline > 0 {
baseline
} else {
nat // for my configuration way bigger than baseline
};
if let Some(height) = height {
Some((height_search + height) * lines + config.lines_additional_space())
} else {
log::warn!("No widget for height calculation available");