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

+41
View File
@@ -0,0 +1,41 @@
///| The dock drawn in a real frame, for a look at it: writes _build/dock_hover.png (an icon under
/// the pointer, magnified, with its name above) and _build/dock_menu.png (an app's right-click
/// menu). Uses the machine's own .desktop files and icon theme, so what it shows varies.
///|
test "dock screenshots: hover label and an app's menu" {
let socket_path = "/tmp/wayland-moon-dockshot-" + @sys.getpid().to_string() + ".sock"
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
assert_true(comp.shell.load_path("build/components/dock.wasm") is Some(_))
ignore(comp.compose_frame())
let slot = comp.shell.slots().filter(s => comp.shell.slot_module(s).contains("dock"))[0]
// Room for the dock's running apps on a 1280-wide screen.
for s in comp.shell.slots() {
let m = comp.shell.slot_module(s)
if m == "inspector" || m == "layout" || m == "screenshot" {
ignore(comp.shell.unload_slot(s))
}
}
comp.shell.set_module_setting(
slot, "pinned", "libreoffice-writer;libreoffice-calc;libreoffice-impress;debian-xterm;vim",
)
let _a = open_and_configure_client(comp, socket_path, "Report.odt", "libreoffice-writer")
let _b = open_and_configure_client(comp, socket_path, "Notes.odt", "libreoffice-writer")
let _c = open_and_configure_client(comp, socket_path, "Terminal", "xterm")
let _e = open_and_configure_client(comp, socket_path, "Notes 2", "org.example.Notes")
let _d = open_and_configure_client(comp, socket_path, "Notes", "org.example.Notes")
ignore(comp.compose_frame())
ignore(comp.compose_frame())
let r = comp.shell.slot_rect(slot)
let cy = r.y + r.h / 2
// Hover the second icon (Calc).
comp.handle_input(@nested.InputEvent::PointerMove((r.x + 6 + 30 + 12).to_double(), cy.to_double()), 1U)
let frame = comp.compose_frame()
assert_true(comp.shell.dock_hover_name().length() > 0)
ignore(@sys.write_file_bytes("_build/dock_hover.png", @renderer.encode_png(frame)))
// Right-click the first (Writer, two windows).
click_at(comp, r.x + 6 + 12, cy, 10U, btn=273U)
assert_true(comp.shell.menu_open)
assert_true(comp.shell.menu_rows.map(m => m.label).contains("Close 2 windows"))
ignore(@sys.write_file_bytes("_build/dock_menu.png", @renderer.encode_png(comp.compose_frame())))
}