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

+97 -1
View File
@@ -907,7 +907,7 @@ test "the dock module magnifies the tile under the pointer and shows nothing whe
let comp = new_comp("dock")
assert_true(comp.shell.load_path("build/components/dock.wasm") is Some(_))
ignore(comp.compose_frame())
let slot = comp.shell.slots()[comp.shell.slots().length() - 1]
let slot = comp.shell.slots().filter(s => comp.shell.slot_module(s).contains("dock"))[0]
let r = comp.shell.slot_rect(slot)
assert_true(r.w > 0)
let frame = fn() {
@@ -922,6 +922,102 @@ test "the dock module magnifies the tile under the pointer and shows nothing whe
assert_eq(comp.shell.hover_slot, "")
}
///|
test "the dock: pinned and running apps, window dots, the hover label and the per-app menu" {
let socket_path = "/tmp/wayland-moon-dock2-" + @sys.getpid().to_string() + ".sock"
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
// A known catalog instead of whatever this machine has installed.
comp.shell.apps.clear()
for id in ["foot", "firefox", "gimp"] {
comp.shell.apps.push({ id, name: id.to_upper(), comment: "", category: "", glyph: "x" })
}
comp.shell.apps_dirty = true
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]
let pinned = fn() {
comp.shell.slot_config(slot).filter(it => it.key == "pinned")[0].value
}
// Nothing chosen yet: the catalog's first apps, saved so launches don't reorder them.
assert_eq(pinned(), "foot;firefox;gimp")
// The pinned list isn't a row of the dock's settings menu.
let w0 = comp.shell.slot_rect(slot).w
// A foot window joins foot's icon; an unknown app gets its own icon after the pinned ones.
let _a = open_and_configure_client(comp, socket_path, "Term", "foot")
let _b = open_and_configure_client(comp, socket_path, "Other", "zzz")
ignore(comp.compose_frame())
ignore(comp.compose_frame())
let r = comp.shell.slot_rect(slot)
assert_true(r.w > w0) // the dock grew for the running app
let cy = r.y + r.h / 2
let pitch = 24 + 6 // medium icons
let x_of = fn(i : Int) { r.x + 6 + i * pitch + 12 + (if i >= 3 { 11 } else { 0 }) }
// Hovering an icon shows its name above it.
comp.handle_input(@nested.InputEvent::PointerMove(x_of(1).to_double(), cy.to_double()), 1U)
ignore(comp.compose_frame())
assert_eq(comp.shell.dock_hover_name(), "FIREFOX")
comp.handle_input(@nested.InputEvent::PointerMove(x_of(3).to_double(), cy.to_double()), 2U)
assert_eq(comp.shell.dock_hover_name(), "zzz")
let labels = fn() { comp.shell.menu_rows.map(r => r.label) }
let pick = fn(label : String, t : UInt) raise {
let i = labels().search(label).unwrap()
let m = comp.shell.menu_rect
click_at(comp, m.x + m.w / 2, m.y + 26 + 28 * i + 14, t)
}
// Right-click foot: it runs, it's pinned first.
click_at(comp, x_of(0), cy, 10U, btn=273U)
assert_true(comp.shell.menu_open)
assert_eq(comp.shell.menu_title, "FOOT")
assert_eq(labels(), ["New window", "Unpin from dock", "Move right", "Quit", "Dock settings..."])
assert_eq(comp.shell.dock_hover_name(), "") // no label over the menu
pick("Move right", 20U)
assert_eq(pinned(), "firefox;foot;gimp")
// Firefox (now first) isn't running.
click_at(comp, x_of(0), cy, 30U, btn=273U)
assert_eq(labels(), ["Open", "Unpin from dock", "Move right", "Dock settings..."])
pick("Unpin from dock", 40U)
assert_eq(pinned(), "foot;gimp")
// The running app: pin it.
ignore(comp.compose_frame())
let r = comp.shell.slot_rect(slot)
let x2 = r.x + 6 + 2 * pitch + 11 + 12
click_at(comp, x2, cy, 50U, btn=273U)
assert_eq(comp.shell.menu_title, "zzz")
assert_eq(labels(), ["New window", "Pin to dock", "Quit", "Dock settings..."])
pick("Pin to dock", 60U)
assert_eq(pinned(), "foot;gimp;zzz")
// Dock settings: the visible settings only.
ignore(comp.compose_frame())
let r = comp.shell.slot_rect(slot)
click_at(comp, r.x + 6 + 12, cy, 70U, btn=273U)
pick("Dock settings...", 80U)
assert_eq(comp.shell.menu_title, "Dock settings")
assert_true(labels().contains("Icon size"))
assert_true(labels().contains("Large"))
assert_false(labels().contains(""))
pick("Large", 90U)
comp.handle_input(@nested.InputEvent::Key(1U, true), 95U) // Escape
ignore(comp.compose_frame())
assert_true(comp.shell.slot_rect(slot).w > r.w) // bigger icons, wider dock
// A left click on a running app's icon focuses its window.
let focused = fn() {
let mut f = 0UL
for id, w in comp.windows {
if w.focused {
f = id
}
}
f
}
let r = comp.shell.slot_rect(slot)
click_at(comp, r.x + 6 + 2 * 34 + 14, cy, 100U) // zzz, the third icon
ignore(comp.compose_frame())
assert_eq(focused(), 2UL)
click_at(comp, r.x + 6 + 14, cy, 110U) // foot, the first
ignore(comp.compose_frame())
assert_eq(focused(), 1UL) // foot's window, opened first
}
///| Bind wl_data_device_manager and get a data device; returns (manager, device).
fn data_device_for(c : TestWaylandClient) -> (UInt, UInt) {
let mgr = bind_global(c, 2U, "wl_data_device_manager", 3U)