srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src/state/desktop_icons.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2026-01-28 14:20:00 +0200
committersrdusr <[email protected]>2026-01-28 14:20:00 +0200
commitd16f7dab25bd9508271017bc6dc15024c30cbf71 (patch)
tree86162f301d361cea5aced086e644707a7366c261 /crates/wayland/src/state/desktop_icons.rs
parent393f886eb9e275c3b7a9e3ef396092ba71297dfb (diff)
downloadsrdwm-d16f7dab25bd9508271017bc6dc15024c30cbf71.tar.gz
srdwm-d16f7dab25bd9508271017bc6dc15024c30cbf71.zip
Redesign the titlebar right-click menu: real separators/headers, live customization
Reported live: "looks very ugly currently and some of it doesn't make sense." Both were real. Every row, including a bare divider, took one full TITLEBAR_HEIGHT slot, so a separator was a 1px hairline in the middle of 32px of empty space; "Move to Workspace" faked a section caption by embedding box-drawing characters directly in an ordinary item's label, which rendered - and behaved, until the click-dispatch site's own special case - exactly like a clickable row that did nothing. Separately, "Floating" was always offered even though Window::floating only affects the "tiling" layout: toggling it under this project's own default "dynamic" layout visibly changes nothing, reading as a broken control rather than an inapplicable one. ContextMenu (crates/core/src/context_menu.rs) gained real Separator (9px) and Header (22px, non-interactive, dimmed) row kinds with their own small heights, replacing the label-hack outright. Both backends' rendering now sum each row's own real height instead of assuming one uniform value, so hit-testing and pixels can't disagree about where a row is. Floating is omitted entirely outside the tiling layout. New, in direct response to "allow customizing from there as well": a Customize section with live Button Style / Button Side toggles. Each flips the matching ThemeConfig field and immediately redraws every open window's titlebar - not routed through srd set's own path, which is scoped to windows created after the call for lack of a redraw hook it can reach; a menu action that didn't visibly change the titlebar you clicked would be its own "doesn't make sense" bug. Full workspace build/test/clippy clean (242 core tests, +8; 152 wayland, net-even after rewriting the old label-hack tests).
Diffstat (limited to 'crates/wayland/src/state/desktop_icons.rs')
-rw-r--r--crates/wayland/src/state/desktop_icons.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/wayland/src/state/desktop_icons.rs b/crates/wayland/src/state/desktop_icons.rs
index 8ed22a5..9d2dd91 100644
--- a/crates/wayland/src/state/desktop_icons.rs
+++ b/crates/wayland/src/state/desktop_icons.rs
@@ -593,8 +593,22 @@ impl CompState {
fn build_desktop_menu_buffer(&mut self, menu: DesktopMenu) {
let theme = self.wm.borrow().theme;
- let items: Vec<(&str, bool)> = menu.items.iter().map(|&(label, _)| (label, false)).collect();
- let data = decoration::render_context_menu(menu.width, menu.row_height, &items, theme.titlebar_bg, theme.titlebar_fg_focused, theme.titlebar_fg_unfocused, theme.default_border_color);
+ // Not redesigned the way the titlebar menu was (`srdwm_core::
+ // context_menu`'s own module doc comment) - this menu's rows are
+ // still all one uniform height, `Separator` included, matching
+ // its behaviour before `render_context_menu` grew a per-row
+ // height/kind. Every row here is real content or `DesktopMenuAction
+ // ::Separator`, never a non-interactive caption, so there is no
+ // `MenuRowKind::Header` case to map to.
+ let rows: Vec<(&str, bool, u32, decoration::MenuRowKind)> = menu
+ .items
+ .iter()
+ .map(|(label, action)| {
+ let kind = if matches!(action, crate::desktop_menu::DesktopMenuAction::Separator) { decoration::MenuRowKind::Separator } else { decoration::MenuRowKind::Item };
+ (*label, false, menu.row_height, kind)
+ })
+ .collect();
+ let data = decoration::render_context_menu(menu.width, &rows, theme.titlebar_bg, theme.titlebar_fg_focused, theme.titlebar_fg_unfocused, theme.default_border_color);
let buffer = MemoryRenderBuffer::from_slice(&data, Fourcc::Argb8888, (menu.width as i32, menu.height()), 1, Transform::Normal, None);
self.desktop_menu_buffer = Some(buffer);
self.desktop_menu = Some(menu);