Dock: pinned and running apps with real icons, window dots, hover names and a per-app menu
CI / test (push) Failing after 17s

The dock showed the first eight catalog apps as letter tiles, and that list reshuffled after
every launch (the catalog puts recent apps first). Now:

- Pinned apps first, in the order you set, then the other running apps after a thin divider
  (like macOS). Windows find their app by desktop id, case, the last dotted part, or the app's
  name (xterm -> debian-xterm.desktop "XTerm"); windows without an app id stay out.
- Real icons from the icon theme (the `icons` capability, as in the task manager), with the
  letter tile as fallback. The shell publishes icons for pinned apps that aren't running too.
- A dot under an icon per open window (up to three), a longer accent bar when the app has focus.
- Click: start the app if it isn't running, otherwise bring its newest window forward
  (restoring it if minimized); click a focused app again to step through its windows.
- Hover: the icon grows (neighbours a little) on a light highlight, and the shell draws the app's
  name in a label above it.
- Right-click an icon (drawn by the shell, like the task manager's window menu): Open / New
  window, Pin to dock / Unpin from dock, Move left / Move right, Quit or Close N windows, and
  Dock settings.
- Dock settings (module-config): Icon size (Small/Medium/Large), Magnify icons under the
  pointer, Show running apps that aren't pinned. The pinned list is a hidden setting (empty
  label: the shell's settings menu skips it), saved in state.edn's :module-config. Until it is
  set the dock pins the catalog's first five, and the shell saves that once so launches don't
  move them.
- The panel sizes the dock from its current items (a module's preferred width is read once).

Plumbing: new WIT world dock-widget (app-catalog, app-launch, windows, icons, exports
module-config); no new interfaces, so both hosts load it as is. lib/dock holds the items,
layout, hit-testing, drawing and pin edits, shared by the module and compositor/shell/dock.mbt.
The shell's Launch handling moved into launch_catalog_app so the menu can use it.
Also: DesktopShell::pointer_move delivered every hover move twice (a duplicated block).

Tests: lib/dock (settings round trip, app matching, item order, hit-testing with the divider,
clicks and window cycling, drawing, pin edits), compositor/host input_test (the dock in a real
compositor: saved default pins, growing for running apps, hover label, the menu's rows and
actions, settings menu without the pinned row, focusing by click), dock_test (screenshots in
_build/dock_hover.png and dock_menu.png).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkmB8pJF5ckPeecFxL
This commit is contained in:
Claude committed 2026-11-25 22:15:01 +00:00
1 parent 0ce0de0356
commit c45e0ef431
29 files changed
+1497 -176

No files matched your search

+25 -13
View File
@@ -188,7 +188,7 @@ fn DesktopShell::panel_slots(self : DesktopShell) -> Array[@panel.SlotIn] {
let w = self.widgets[i]
out.push({
id: w.slot,
pref_w: w.pl.pref_w,
pref_w: self.dock_width(w).unwrap_or(w.pl.pref_w),
pref_h: w.pl.pref_h,
min_w: w.pl.min_w,
stretch: w.pl.stretch,
@@ -753,23 +753,26 @@ pub fn DesktopShell::set_power_timeouts(self : DesktopShell, screen_off : Int, s
self.save_state()
}
///| Start the catalog app `id` (a desktop file id) and remember it as the latest launch.
fn DesktopShell::launch_catalog_app(self : DesktopShell, id : String) -> Unit {
match self.command_for(id) {
Some(bin) =>
if @sys.spawn(bin, self.display) {
self.note_recent(id)
self.apps_dirty = true
} else {
self.say("Could not start " + bin)
}
None => self.say("No executable for " + id)
}
}
///| Carry out what modules asked of the host during their last calls.
fn DesktopShell::process_requests(self : DesktopShell) -> Unit {
while true {
match @wasm.next_request() {
None => break
Some(Launch(id)) => {
match self.command_for(id) {
Some(bin) =>
if @sys.spawn(bin, self.display) {
self.note_recent(id)
self.apps_dirty = true
} else {
self.say("Could not start " + bin)
}
None => self.say("No executable for " + id)
}
}
Some(Launch(id)) => self.launch_catalog_app(id)
Some(FocusWindow(n)) => self.actions.push(FocusWindow(n.to_int64().to_uint64()))
Some(SetLayout(m)) => self.actions.push(SetLayout(m))
Some(Logout) => self.actions.push(Logout)
@@ -958,6 +961,10 @@ pub fn DesktopShell::right_click(self : DesktopShell, x : Int, y : Int) -> Bool
self.open_window_menu(win, x)
true
}
Some(w) if self.dock_item_at(w, x, y) is Some((items, i)) => {
self.open_dock_menu(w, items, i, x)
true
}
Some(w) => {
self.name_catalog()
let rows : Array[MenuRow] = []
@@ -1037,6 +1044,10 @@ fn DesktopShell::open_window_menu(self : DesktopShell, win : WinInfo, x : Int) -
fn config_rows(items : Array[@wasm.ConfigItem]) -> Array[MenuRow] {
let rows : Array[MenuRow] = []
for it in items {
if it.label.length() == 0 {
// Kept by the module (e.g. the dock's pinned apps) but not a menu choice.
continue
}
if it.choices.length() == 0 {
let on = it.value == "on"
rows.push({ ..menu_row(it.label, 4, arg=it.key), value: if on { "off" } else { "on" }, ticked: on })
@@ -1141,6 +1152,7 @@ fn DesktopShell::menu_pointer_down(self : DesktopShell, x : Int, y : Int) -> Boo
3 => self.open_module_settings(slot)
4 => self.choose_module_setting(slot, row.arg, row.value)
6 => self.actions.push(Window(row.window_id, row.window_cmd))
7 | 8 | 9 | 10 => self.dock_menu_choice(slot, row)
// A heading: the menu stays open.
_ => self.menu_open = true
}