diff options
| author | srdusr <[email protected]> | 2026-01-30 09:39:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2026-01-30 09:39:00 +0200 |
| commit | 2a51fb86e2a123ff9e810a0b4105c9fe5f85e3ae (patch) | |
| tree | 7a1fc6b2b87cd0bf82bc8953ba0a2a9e65c9e7cf /crates/wayland/src/state/menu.rs | |
| parent | d16f7dab25bd9508271017bc6dc15024c30cbf71 (diff) | |
| download | srdwm-2a51fb86e2a123ff9e810a0b4105c9fe5f85e3ae.tar.gz srdwm-2a51fb86e2a123ff9e810a0b4105c9fe5f85e3ae.zip | |
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.
Diffstat (limited to 'crates/wayland/src/state/menu.rs')
| -rw-r--r-- | crates/wayland/src/state/menu.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/wayland/src/state/menu.rs b/crates/wayland/src/state/menu.rs index b0b0a6e..82e4434 100644 --- a/crates/wayland/src/state/menu.rs +++ b/crates/wayland/src/state/menu.rs @@ -7,12 +7,28 @@ impl CompState { /// and caches the rasterised buffer once here rather than per frame -- /// same reasoning as `redraw_decoration_buffer`. pub(crate) fn open_context_menu(&mut self, window: WindowId, pos: (i32, i32)) { - let Some(menu) = ({ + let Some(mut menu) = ({ let wm = self.wm.borrow(); crate::context_menu::ContextMenu::open(&wm, window, pos) }) else { return; }; + // `ContextMenu::width` is a backend-agnostic placeholder - `core` + // has no font of its own to measure real text against, so it can + // only ever pick a fixed guess. Widened here to whatever this + // menu's own widest real label actually needs, or reported live + // as "text goes out of view": the old fixed width comfortably fit + // every label back when this menu only listed short ones + // ("Minimize", "Close"), but a longer one added since ("Button + // Style: Traffic Lights", or a user-configurable workspace name) + // just ran past the panel's own right edge, silently cut off + // mid-character by `render_context_menu`'s own overflow guard. + // Only ever grows the width, never shrinks it below the built-in + // minimum `ContextMenu::open` already picked. + let font = decoration::find_system_font(); + let widest_label = menu.items.iter().map(|&(label, _)| decoration::measure_text_width(&font, label, decoration::FONT_PIXELS)).fold(0.0_f32, f32::max); + let content_width = (widest_label + decoration::TEXT_LEFT_PADDING * 2.0).ceil() as u32; + menu.width = menu.width.max(content_width); let theme = self.wm.borrow().theme; let rows: Vec<(&str, bool, u32, decoration::MenuRowKind)> = menu .items |