srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/x11/src/platform/window.rs
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2025-08-25 11:47:00 +0200
committersrdusr <[email protected]>2025-08-25 11:47:00 +0200
commitbd7141718901c6f41511137e4b34a3bd9e2705b1 (patch)
tree672811318065eb97a822c1f7cec97b001a336900 /crates/x11/src/platform/window.rs
parent72e787a706d372c9a92e424e9b13ece929cb2bce (diff)
downloadsrdwm-bd7141718901c6f41511137e4b34a3bd9e2705b1.tar.gz
srdwm-bd7141718901c6f41511137e4b34a3bd9e2705b1.zip
X11 backend: right-click titlebar window menu, matching Wayland's own
Closes the one real gap an X11/Wayland feature-parity audit found this session (desktop icons, window-position memory, and static exclusive-zone reservation were already shared or Wayland-only by nature - see docs/TODO.md's own audit entry for the full breakdown). MenuAction/ContextMenu (row set, labels, row_at hit-testing) move from crates/wayland/src/context_menu.rs into crates/core/src/context_menu.rs -- pure state and geometry with nothing Wayland-specific in it, so X11 needing the same rows is shared data, not duplicated logic. The Wayland crate's own context_menu.rs is now a one-line re-export so every existing crate::context_menu::... call site keeps working unchanged. X11 has no compositor-level input dispatch to intercept every click the way Wayland's input/pointer.rs does, so the X11 side (crates/x11/src/platform/context_menu.rs, new) draws the menu into its own small override-redirect popup window and grabs the pointer for the duration so a click anywhere dismisses it, matching the Wayland backend's own convention. events.rs's ButtonPress handler now reads the real button number instead of hardcoding every press as a left click - a real latent bug (right-clicking a titlebar button would have silently performed its left-click action). Live-verified end to end in an isolated Xvfb + srdwm --x11 instance: full row set including the workspace picker, Minimize runs and closes the menu, a second window's menu dismisses cleanly on outside click, normal focus/click behaviour continues working afterward. See docs/TODO.md for the full investigation and verification narrative.
Diffstat (limited to 'crates/x11/src/platform/window.rs')
-rw-r--r--crates/x11/src/platform/window.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/x11/src/platform/window.rs b/crates/x11/src/platform/window.rs
index 997981f..bce71ca 100644
--- a/crates/x11/src/platform/window.rs
+++ b/crates/x11/src/platform/window.rs
@@ -156,6 +156,13 @@ impl X11Platform {
if let Some(frame) = self.frames.remove(&id) {
let _ = self.conn.destroy_window(frame.frame);
}
+ // A closed window's own context menu (opened right before, say, a
+ // client that immediately quits) would otherwise dangle - its
+ // `MenuAction::Close`/etc. would target a `WindowId` `remove_
+ // window` below has already forgotten.
+ if self.context_menu.as_ref().is_some_and(|(menu, _)| menu.window == id) {
+ let _ = self.close_context_menu();
+ }
self.wm.borrow_mut().remove_window(id);
let _ = self.conn.flush();
Some(Event::WindowDestroyed(id))