CI / test (push) Failing after 30s
The panel had a task list and, beside it, a dock showing the same running
apps again. They are now one module, the dock, in the task list's place:
- Pinned apps, then running ones; an app with windows is a pill with its
window's title (or name and window count) while there is room, an icon
when the panel is crowded ("Show window titles" in Dock settings).
- Its right-click menu has the task list's window commands (Minimize /
Restore, Maximize) for a single window, or the app's windows by title.
- It stretches like the task list did; new panels get it instead of
tasks. A saved panel's "tasks" becomes the dock (one dock, where the
task list was); pins are the dock's own setting, so they carry over.
- An empty dock shows a "+ Add apps" tile that opens the Applications
menu, where right-clicking an app offers Open and Pin to dock (adding a
dock to the panel if there is none).
- Super+1 .. Super+9 open the dock's first nine apps like a click
(shortcut "dock-apps", rebindable in Settings > Shortcuts).
- "New window" / "Open" only for apps the catalog can start.
The tasks component, lib/panel's pill geometry and the taskbar-widget
world are gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiPCFHRxaJQvwex6ry
134 lines
7.0 KiB
MoonBit
134 lines
7.0 KiB
MoonBit
///| 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()
|
|
ignore(comp.compose_frame())
|
|
let slot = comp.shell.slot_of("dock")
|
|
// 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",
|
|
)
|
|
// Icons only, to see the magnification (titles are the default).
|
|
comp.shell.set_module_setting(slot, "titles", "off")
|
|
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())))
|
|
}
|
|
|
|
///| Pick row `label` of the open right-click menu (rows: 26px title, then 28px each).
|
|
fn dock_pick(comp : @host.ChandraCompositor, label : String, t : UInt) -> Unit raise {
|
|
let i = comp.shell.menu_rows.map(r => r.label).search(label).unwrap()
|
|
let m = comp.shell.menu_rect
|
|
click_at(comp, m.x + m.w / 2, m.y + 26 + 28 * i + 14, t)
|
|
}
|
|
|
|
///| A key pressed and released with Super held (evdev codes).
|
|
fn super_key(comp : @host.ChandraCompositor, code : UInt, t : UInt) -> Unit {
|
|
comp.handle_input(@nested.InputEvent::Key(125U, true), t)
|
|
comp.handle_input(@nested.InputEvent::Key(code, true), t + 1U)
|
|
comp.handle_input(@nested.InputEvent::Key(code, false), t + 2U)
|
|
comp.handle_input(@nested.InputEvent::Key(125U, false), t + 3U)
|
|
ignore(comp.compose_frame())
|
|
}
|
|
|
|
///|
|
|
test "the dock is the panel's task manager: empty + opens Applications, pin from there, Super+number" {
|
|
let socket_path = "/tmp/wayland-moon-dockbar-" + @sys.getpid().to_string() + ".sock"
|
|
let comp = @host.ChandraCompositor::new(socket_path, @scene.ThemeTokens::moon_night(), 1280, 720).unwrap()
|
|
ignore(comp.compose_frame())
|
|
// A fresh panel has the dock where the task list was; the old id is an alias of it.
|
|
let slot = comp.shell.slot_of("dock")
|
|
assert_true(slot.length() > 0)
|
|
assert_eq(comp.shell.slot_of("tasks"), slot)
|
|
// It stretches: the clock still packs against the right edge.
|
|
let r = comp.shell.slot_rect(slot)
|
|
assert_true(r.w > 300)
|
|
let clock = comp.shell.slot_rect(comp.shell.slot_of("clock-digital"))
|
|
assert_true(clock.x > 900)
|
|
// Nothing pinned, nothing running: a "+" that opens the Applications menu.
|
|
comp.shell.set_module_setting(slot, "pinned", ";")
|
|
ignore(comp.compose_frame())
|
|
comp.handle_input(@nested.InputEvent::PointerMove((r.x + 14).to_double(), (r.y + r.h / 2).to_double()), 8U)
|
|
ignore(@sys.write_file_bytes("_build/dock_empty.png", @renderer.encode_png(comp.compose_frame())))
|
|
click_at(comp, r.x + 14, r.y + r.h / 2, 10U)
|
|
let launcher = comp.shell.slot_of("launcher")
|
|
let pr = comp.shell.slot_popup_rect(launcher)
|
|
assert_true(pr.w > 0)
|
|
// Right-click the first app there: Open, Pin to dock. Pinning keeps the menu open.
|
|
click_at(comp, pr.x + 40, pr.y + 60, 20U, btn=273U)
|
|
assert_true(comp.shell.menu_open)
|
|
assert_eq(comp.shell.menu_rows.map(r => r.label), ["Open", "Pin to dock"])
|
|
let first = comp.shell.menu_title
|
|
ignore(@sys.write_file_bytes("_build/dock_pin_from_menu.png", @renderer.encode_png(comp.compose_frame())))
|
|
dock_pick(comp, "Pin to dock", 25U)
|
|
assert_true(comp.shell.slot_popup_rect(launcher).w > 0)
|
|
let pinned = comp.shell.module_setting("dock", "pinned").unwrap_or("")
|
|
assert_true(pinned.length() > 1 && pinned != ";")
|
|
// The same app's menu now offers Unpin.
|
|
click_at(comp, pr.x + 40, pr.y + 60, 30U, btn=273U)
|
|
assert_eq(comp.shell.menu_title, first)
|
|
assert_true(comp.shell.menu_rows.map(r => r.label).contains("Unpin from dock"))
|
|
comp.handle_input(@nested.InputEvent::Key(1U, true), 35U) // Escape closes the menu
|
|
comp.handle_input(@nested.InputEvent::Key(1U, false), 36U)
|
|
comp.handle_input(@nested.InputEvent::Key(1U, true), 37U) // and the Applications menu
|
|
comp.handle_input(@nested.InputEvent::Key(1U, false), 38U)
|
|
// Two running apps pinned in front: Super+2 brings the second one's window forward.
|
|
comp.shell.set_module_setting(slot, "pinned", "libreoffice-writer;libreoffice-calc;vim")
|
|
let _a = open_and_configure_client(comp, socket_path, "Report.odt", "libreoffice-writer")
|
|
let _b = open_and_configure_client(comp, socket_path, "Budget.ods", "libreoffice-calc")
|
|
let _c = open_and_configure_client(comp, socket_path, "Notes.odt", "libreoffice-writer")
|
|
ignore(comp.compose_frame())
|
|
let focused = fn() {
|
|
let mut f = ""
|
|
for _, w in comp.windows {
|
|
if w.focused {
|
|
f = w.title
|
|
}
|
|
}
|
|
f
|
|
}
|
|
super_key(comp, 3U, 40U) // Super+2
|
|
assert_eq(focused(), "Budget.ods")
|
|
super_key(comp, 2U, 50U) // Super+1: Writer's newest window, then its other one
|
|
assert_eq(focused(), "Notes.odt")
|
|
super_key(comp, 2U, 60U)
|
|
assert_eq(focused(), "Report.odt")
|
|
// Writer's menu lists its two windows by title; picking one brings it forward.
|
|
let r = comp.shell.slot_rect(slot)
|
|
click_at(comp, r.x + 6 + 12, r.y + r.h / 2, 70U, btn=273U)
|
|
let labels = comp.shell.menu_rows.map(r => r.label)
|
|
assert_true(labels.contains("Report.odt") && labels.contains("Notes.odt"))
|
|
ignore(@sys.write_file_bytes("_build/dock_bar_menu.png", @renderer.encode_png(comp.compose_frame())))
|
|
dock_pick(comp, "Notes.odt", 80U)
|
|
ignore(comp.compose_frame())
|
|
assert_eq(focused(), "Notes.odt")
|
|
comp.handle_input(@nested.InputEvent::PointerMove((r.x + 6 + 30 + 12).to_double(), (r.y + r.h / 2).to_double()), 90U)
|
|
ignore(@sys.write_file_bytes("_build/dock_bar.png", @renderer.encode_png(comp.compose_frame())))
|
|
}
|