srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/wayland/src/winit
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2025-08-15 23:22:00 +0200
committersrdusr <[email protected]>2025-08-15 23:22:00 +0200
commitcc22fe69a68e0fff027d833029aea850976488c8 (patch)
treeeb1350c24c61b5d4b30d763d64149a5c6504a925 /crates/wayland/src/winit
parent6694a2d9946d98d5752d84b22c45879cab5c9abe (diff)
downloadsrdwm-cc22fe69a68e0fff027d833029aea850976488c8.tar.gz
srdwm-cc22fe69a68e0fff027d833029aea850976488c8.zip
Add real desktop icons plus right-click desktop/icon context menus
Closes "right-click on bare desktop" - previously a true no-op, nothing rendered above the wallpaper at all. Requested directly: a real desktop "just like windows does" - Home/Computer/Trash plus one icon per real ~/Desktop entry, individually draggable with persisted grid positions, double-click to open, right-click menus (per-icon "Open" plus "Set as Wallpaper" for image files when general.wallpaper_command is set; bare desktop "New Folder"/"Refresh"). Architecture mirrors the existing context_menu.rs/snap_flyout.rs "compositor-owned floating UI" pattern: desktop_icons.rs (data model, grid layout, filesystem scan, hit-test), desktop_icons_state.rs (JSON persistence, same shape as monitor_layout.rs), desktop_menu.rs (the new right-click menu, reusing decoration::render_context_menu's existing rasterizer), state/desktop_icons.rs (CompState glue: rescan/select/drag/ open/persist), and a new decoration::render_desktop_icon rasterizer -- hand-drawn glyphs, since no PNG/SVG decoding capability exists anywhere in this workspace. Wired into both render loops (udev and winit) above the wallpaper and below every window, and into input/pointer.rs's button/ motion handlers for selection, drag, double-click, and both menus. Four new config keys: general.desktop_icons (default true - a directly requested, purely visual feature, unlike the opt-in-while-experimental general.gpu), general.file_manager, general.desktop_icon_single_click, general.wallpaper_command (all default off/empty). Deliberately out of scope for this pass, stated up front: move-to-trash and "Empty Trash" (destructive, no confirmation-dialog primitive to gate them on yet), filesystem watching, multi-select, per-mimetype icon art, icons on any monitor but the primary one. 124 wayland-crate tests (up from 106), full workspace build and clippy clean.
Diffstat (limited to 'crates/wayland/src/winit')
-rw-r--r--crates/wayland/src/winit/connect.rs6
-rw-r--r--crates/wayland/src/winit/render.rs22
2 files changed, 28 insertions, 0 deletions
diff --git a/crates/wayland/src/winit/connect.rs b/crates/wayland/src/winit/connect.rs
index 30eaaf8..227cf33 100644
--- a/crates/wayland/src/winit/connect.rs
+++ b/crates/wayland/src/winit/connect.rs
@@ -151,6 +151,12 @@ impl WaylandPlatform {
context_menu_buffer: None,
snap_flyout: None,
snap_flyout_buffer: None,
+ desktop_icons: None,
+ desktop_icon_buffers: HashMap::new(),
+ desktop_icon_drag: None,
+ desktop_menu: None,
+ desktop_menu_buffer: None,
+ last_icon_click: None,
wm: wm.clone(),
surface_to_id: HashMap::new(),
id_to_window: HashMap::new(),
diff --git a/crates/wayland/src/winit/render.rs b/crates/wayland/src/winit/render.rs
index 345d40c..03fff3d 100644
--- a/crates/wayland/src/winit/render.rs
+++ b/crates/wayland/src/winit/render.rs
@@ -56,6 +56,8 @@ impl WaylandPlatform {
// trade against silently wrong pixels persisting on screen.
let age = 0;
let (renderer, mut framebuffer) = self.backend.bind().map_err(err)?;
+ self.state.ensure_desktop_icons();
+ let desktop_icon_render_list = self.state.desktop_icon_render_list();
// Locked: srdwm's own native lock UI, or an external locker's
// surface, over an opaque black clear - nothing else, no windows,
@@ -129,6 +131,15 @@ impl WaylandPlatform {
Err(e) => log::warn!("failed to import snap flyout buffer: {e}"),
}
}
+ // The desktop-icon/bare-desktop right-click menu, if open - same
+ // topmost placement.
+ if let (Some(menu), Some(buffer)) = (self.state.desktop_menu.as_ref(), self.state.desktop_menu_buffer.as_ref()) {
+ let pos = (menu.pos.0 as f64, menu.pos.1 as f64);
+ match MemoryRenderBufferRenderElement::from_buffer(renderer, pos, buffer, None, None, None, Kind::Unspecified) {
+ Ok(elem) => custom_elements.push(crate::rounded_corners::WinitElement::Base(crate::elements::OverlayElement::Memory(elem))),
+ Err(e) => log::warn!("failed to import desktop menu buffer: {e}"),
+ }
+ }
// Content now renders here too, one window at a time, not through
// `render_output`'s own `spaces` argument - see this function's
// own call to `damage_tracker.render_output` further down for why,
@@ -441,6 +452,17 @@ impl WaylandPlatform {
}
occluders.push(frame);
}
+ // Real desktop icons - above the wallpaper, below every window.
+ // See `udev/render.rs`'s matching push site for the full ordering
+ // reasoning; `desktop_icon_render_list` was already captured
+ // right after `self.backend.bind()`, well before this point.
+ for (pos, buffer) in &desktop_icon_render_list {
+ let pos = (pos.0 as f64, pos.1 as f64);
+ match MemoryRenderBufferRenderElement::from_buffer(renderer, pos, buffer, None, None, None, Kind::Unspecified) {
+ Ok(elem) => custom_elements.push(crate::rounded_corners::WinitElement::Base(crate::elements::OverlayElement::Memory(elem))),
+ Err(e) => log::warn!("failed to import desktop icon buffer: {e}"),
+ }
+ }
// Background/bottom layer-shell (wallpaper engines) last --
// bottommost, matching smithay's own `space_render_elements`
// ordering, which this whole custom loop now replaces.