From cc22fe69a68e0fff027d833029aea850976488c8 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Fri, 15 Aug 2025 23:22:00 +0200 Subject: 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. --- docs/DEFAULTS.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'docs/DEFAULTS.md') diff --git a/docs/DEFAULTS.md b/docs/DEFAULTS.md index 7e712c5..5f99446 100644 --- a/docs/DEFAULTS.md +++ b/docs/DEFAULTS.md @@ -17,6 +17,10 @@ srd.set("general.rounded_corners", true) -- Default: true on GLES/ srd.set("general.focus_follows_mouse", false) -- Default: false - hover a window to focus it, no click needed srd.set("general.auto_raise", false) -- Default: false - also raise on hover-focus, not just focus srd.set("general.gpu", false) -- Default: false - udev backend only, see "GPU rendering" below +srd.set("general.desktop_icons", true) -- Default: true - see "Desktop icons" below +srd.set("general.file_manager", "") -- Default: "" - empty means dispatch via `xdg-open` +srd.set("general.desktop_icon_single_click", false) -- Default: false - double-click opens an icon +srd.set("general.wallpaper_command", "") -- Default: "" - empty hides "Set as Wallpaper" entirely ``` `general.smart_placement`/`general.border_width` are not listed: neither is implemented - new-window placement always uses smart placement @@ -54,6 +58,45 @@ separate, lower-level override for testing without touching config -- either it or `general.gpu` being set is enough to attempt GPU rendering. +#### Desktop icons (`general.desktop_icons`) + +Real, individually-draggable desktop icons rendered above the wallpaper +and below every window, on the primary monitor only: fixed **Home** +(`$HOME`), **Computer** (`/`), and **Trash** (`~/.local/share/Trash/files`, +or `$XDG_DATA_HOME/Trash/files` if set) icons, plus one per real, +non-hidden entry of `~/Desktop` (created if it doesn't exist yet). On by +default - unlike `general.gpu`, this is a purely visual, directly +requested feature with no hardware-support question to hedge against. + +Hand-drawn glyphs, not real icon-theme artwork - no PNG/SVG decoding +capability exists anywhere in this codebase, so folder/computer/trash/file +icons are simple flat shapes, the same technique the titlebar's own +buttons use. + +Double-click (or a single click when `general.desktop_icon_single_click` +is `true`) opens an icon: `$general.file_manager ` if that key is +set, otherwise `xdg-open `. Dragging an icon snaps it to the nearest +free grid cell on release and persists that cell to +`$XDG_STATE_HOME/srd/desktop-icons.json` (else `~/.local/state/srd/...`) -- +only icons the user has actually moved get an entry there; everything +else keeps recomputing its default slot on every rescan. + +Right-click an icon: "Open", plus "Set as Wallpaper" when it's an image +file (`.png`/`.jpg`/`.jpeg`/`.webp`/`.bmp`/`.gif`) and `general. +wallpaper_command` is set - shells out to ` `. +srdwm never draws the wallpaper itself (an external layer-shell client's +job - `swww`, `awww`, or similar), so there is no universal default to +guess here the way `xdg-open` covers `file_manager`; this action simply +doesn't appear when the key is empty. Right-click bare desktop: "New +Folder" (creates `~/Desktop/New Folder`, de-duplicated as `New Folder +(2)`, `(3)`, ...) and "Refresh" (re-scans `~/Desktop`). + +Not implemented in this first pass, deliberately: moving a file to trash, +emptying the trash, filesystem watching (a file added to `~/Desktop` by +another program needs "Refresh" or a restart to appear), multi-select, +and per-mimetype icon art. The first two are destructive/hard-to-reverse +actions with no confirmation-dialog primitive to gate them on yet. + ### Monitor Settings (`monitor.*`) ```lua srd.set("monitor.primary_layout", "dynamic") -- Default: "dynamic" -- cgit v1.2.3