Task manager: right-click a window's pill for Minimize/Restore, Maximize, Quit
CI / test (push) Failing after 16s

- Right-clicking a pill in the task manager opens that window's menu (titled with the window's
  title): Minimize (Restore when minimized), Maximize (Restore size when maximized) and Quit,
  which asks the app to close the window (xdg_toplevel close, like the title-bar close button).
  Empty task-bar space keeps the module's own menu (Module settings, Replace with, Remove widget).
- Modules only get left clicks, so the shell draws the menu and hit-tests the pills itself: the
  pill geometry moved to lib/panel/tasks.mbt, shared by the tasks module and the shell. No WIT
  change, so every host works as before.
- New menu row kind 6 and ShellAction::Window(id, WindowCommand); the compositor runs it through
  the same WM requests as the title-bar buttons. WinInfo carries `maximized`.
- Tests: native end-to-end (menu rows, minimize/restore, maximize/restore size, Quit sends close,
  empty space keeps the module menu) and lib/panel pill geometry tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hiX13fXK1eMboRe5oQ
This commit is contained in:
Claude committed 2026-11-25 20:13:38 +00:00
1 parent f33f84c35b
commit f844ac66ff
9 files changed
+238 -35

No files matched your search

+61
View File
@@ -305,6 +305,67 @@ test "the task list module focuses the window whose pill is clicked" {
assert_true(focused() != first || other.length() == 1)
}
///|
test "right-click a task-bar pill for the window's menu: Minimize, Maximize, Quit" {
let socket_path = "/tmp/wayland-moon-taskmenu-" +
@sys.getpid().to_string() +
".sock"
let theme = @scene.ThemeTokens::moon_night()
let comp = @host.ChandraCompositor::new(socket_path, theme, 1280, 720).unwrap()
let (c, _shm, _surf, _xdg, tl, _deco) = open_and_configure_client(comp, socket_path, "A", "a")
let _b = open_and_configure_client(comp, socket_path, "B", "b")
ignore(comp.compose_frame())
let tasks = rect_of(comp, "tasks")
let cy = tasks.y + tasks.h / 2
let labels = fn() { comp.shell.menu_rows.map(r => r.label) }
// Pick menu row `label` (rows: 26px title, then 28px each).
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)
}
// Pill 0 is window 1 (opening order): its menu, titled with its title.
click_at(comp, tasks.x + 20, cy, 1U, btn=273U)
assert_true(comp.shell.menu_open)
assert_eq(comp.shell.menu_title, "A")
assert_eq(labels(), ["Minimize", "Maximize", "Quit"])
// Minimize, then the same pill's menu offers Restore, which brings it back.
pick("Minimize", 10U)
assert_true(!comp.shell.menu_open)
assert_true(comp.wm.windows.get(1UL).unwrap().minimized)
click_at(comp, tasks.x + 20, cy, 20U, btn=273U)
assert_eq(labels(), ["Restore", "Maximize", "Quit"])
pick("Restore", 30U)
assert_true(!comp.wm.windows.get(1UL).unwrap().minimized)
// Maximize, then Restore size.
let w0 = comp.windows.get(1UL).unwrap().geometry.w
click_at(comp, tasks.x + 20, cy, 40U, btn=273U)
pick("Maximize", 50U)
assert_true(comp.windows.get(1UL).unwrap().geometry.w > w0)
click_at(comp, tasks.x + 20, cy, 60U, btn=273U)
assert_eq(labels(), ["Minimize", "Restore size", "Quit"])
pick("Restore size", 70U)
assert_eq(comp.windows.get(1UL).unwrap().geometry.w, w0)
// Pill 1 is window 2.
click_at(comp, tasks.x + 146 + 20, cy, 80U, btn=273U)
assert_eq(comp.shell.menu_title, "B")
comp.handle_input(@nested.InputEvent::Key(1U, true), 85U) // Escape
assert_true(!comp.shell.menu_open)
// Quit asks the app to close its window (xdg_toplevel.close, opcode 1 on its toplevel).
ignore(drain_msgs(c))
click_at(comp, tasks.x + 20, cy, 90U, btn=273U)
pick("Quit", 100U)
for _i = 0; _i < 5; _i = _i + 1 {
comp.step()
@sys.sleep_ms(2)
}
assert_true(has_msg(drain_msgs(c), tl, 1U))
// Empty task-bar space keeps the module's own menu.
click_at(comp, tasks.x + tasks.w - 10, cy, 110U, btn=273U)
assert_eq(comp.shell.menu_title, "Task Manager")
assert_true(labels().contains("Remove widget"))
}
///|
test "right-click a panel module to replace it in place, or remove it" {
let comp = new_comp("swap")