From 2a51fb86e2a123ff9e810a0b4105c9fe5f85e3ae Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Fri, 30 Jan 2026 09:39:00 +0200 Subject: Fix a real regression: dynamic-mode windows lost their shadow via toggle_floating The tiled-shadow-tint fix earlier today gated the shadow on Window::floating alone. arrange_workspace only reads floating under the "tiling" layout, so every window on this project's own default "dynamic" layout starts, and stays, floating: false - the gate misread that as "tiled, no shadow" regardless of which layout was actually running, so shadows silently vanished under dynamic mode entirely, recoverable only by pressing Super+S (toggle_floating), which then looked like that key toggles a tint rather than floating. Fixed by checking the workspace's own layout name first: a window is only "currently tiled" when its workspace runs "tiling" AND it hasn't opted out via floating. DecorationSignature's floating field is now currently_tiled, since a layout switch changes this for every window on a workspace without touching any of their own floating fields. Also disabled general.shadows in the user's own config per direct request - never asked for, on by default, and a real problem for color-accuracy work regardless of how correctly it renders otherwise. Also fixed both context menus (titlebar and desktop) silently truncating labels past a fixed 170px width with no indication - widened dynamically to each menu's own real widest label via a new measure_text_width helper. --- crates/wayland/src/decoration/font.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/wayland/src/decoration') diff --git a/crates/wayland/src/decoration/font.rs b/crates/wayland/src/decoration/font.rs index 27df347..6a2a312 100644 --- a/crates/wayland/src/decoration/font.rs +++ b/crates/wayland/src/decoration/font.rs @@ -19,6 +19,18 @@ pub(crate) fn find_system_font() -> Option { FONT.get_or_init(load_any_monospace_font).clone() } +/// The real rendered pixel width of `text` at `size`, in this font - the +/// same two-pass "sum every glyph's own advance width" measurement `render_ +/// header_box`'s `draw_centered` already does inline, pulled out here so a +/// caller that needs to *size a box* around text (not just draw it) has one +/// place to ask, rather than repeating the sum. Returns `0.0` with no +/// system font found, matching every other text-rendering path's own +/// "solid colour only, no text at all" fallback in that case. +pub(crate) fn measure_text_width(font: &Option, text: &str, size: f32) -> f32 { + let Some(font) = font else { return 0.0 }; + text.chars().filter(|c| !c.is_control()).map(|ch| font.rasterize(ch, size).0.advance_width).sum() +} + fn load_any_monospace_font() -> Option { let roots = ["/usr/share/fonts", "/usr/local/share/fonts"]; let mut home_roots = Vec::new(); -- cgit v1.2.3