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
254 lines
11 KiB
MoonBit
254 lines
11 KiB
MoonBit
///| Keyboard shortcuts: the combo text format, the shortcut table (defaults, conflicts, saving),
|
|
/// rebinding through the compositor and through the settings module's Shortcuts tab.
|
|
|
|
///|
|
|
test "key combos parse and print, modifiers in a fixed order" {
|
|
let p = fn(s : String) { @shell.KeyCombo::parse(s).map(c => c.to_text()) }
|
|
assert_eq(p("Super+Shift+S"), Some("Super+Shift+S"))
|
|
assert_eq(p("shift+super+s"), Some("Super+Shift+S"))
|
|
assert_eq(p("Ctrl + Alt + Delete"), Some("Ctrl+Alt+Delete"))
|
|
assert_eq(p("Meta+PrtSc"), Some("Super+Print"))
|
|
assert_eq(p("Control+Return"), Some("Ctrl+Enter"))
|
|
assert_eq(p("Alt+Tab"), Some("Alt+Tab"))
|
|
assert_eq(p("F12"), Some("F12"))
|
|
assert_eq(p("Super"), Some("Super"))
|
|
assert_true(@shell.KeyCombo::parse("Super").unwrap().is_super_tap())
|
|
assert_eq(@shell.KeyCombo::parse("Super+Shift+S"), Some({ mods: 64U | 1U, key: 31U }))
|
|
// Not combos: nothing, a dangling +, unknown keys, a repeated modifier, a modifier alone.
|
|
for bad in ["", "Super+", "+S", "Hyper+S", "Super+Foo", "Shift+Shift+A", "Ctrl", "Ctrl+Alt"] {
|
|
assert_eq(@shell.KeyCombo::parse(bad), None)
|
|
}
|
|
}
|
|
|
|
///|
|
|
test "the default shortcuts are the compositor's long-standing combos" {
|
|
let want = [
|
|
("launcher", "Super"),
|
|
("show-desktop", "Super+D"),
|
|
("switch-windows", "Alt+Tab"),
|
|
("screenshot-region", "Super+Shift+S"),
|
|
("screenshot-region-print", "Super+Shift+Print"),
|
|
("screenshot-full", "Print"),
|
|
("screenshot-window", "Super+Print"),
|
|
("screenshot-under-cursor", "Super+Ctrl+Print"),
|
|
("record-region", "Super+Shift+R"),
|
|
("record-screen", "Super+Alt+R"),
|
|
("record-window", "Super+Ctrl+R"),
|
|
("dock-apps", "Super+1"),
|
|
]
|
|
let sc = @shell.Shortcuts::defaults()
|
|
assert_eq(@shell.shortcut_table.length(), want.length())
|
|
for i, w in want {
|
|
assert_eq(@shell.shortcut_table[i].id, w.0)
|
|
assert_eq(sc.binding_text(i), w.1) // every default parses and prints back the same
|
|
assert_eq(sc.conflict(i), None)
|
|
assert_true(sc.is_default(i))
|
|
}
|
|
assert_eq(sc.lookup({ mods: 64U, key: 32U }), Some(@shell.ShortcutAction::ShowDesktop))
|
|
assert_eq(sc.lookup({ mods: 64U | 1U, key: 99U }), Some(@shell.ShortcutAction::ShotRegion))
|
|
assert_eq(sc.lookup({ mods: 0U, key: 99U }), Some(@shell.ShortcutAction::ShotFull))
|
|
// Caps lock (2) and num lock (16) don't change a combo; other modifiers do.
|
|
assert_eq(sc.lookup({ mods: 64U | 2U | 16U, key: 32U }), Some(@shell.ShortcutAction::ShowDesktop))
|
|
assert_eq(sc.lookup({ mods: 64U | 4U, key: 32U }), None)
|
|
assert_eq(sc.changed(), [])
|
|
}
|
|
|
|
///|
|
|
test "two shortcuts on one combo conflict; the one listed first wins" {
|
|
let sc = @shell.Shortcuts::defaults()
|
|
assert_true(sc.set(9, @shell.KeyCombo::parse("Super+D"))) // record the screen
|
|
assert_eq(sc.conflict(1), Some(9))
|
|
assert_eq(sc.conflict(9), Some(1))
|
|
assert_eq(sc.lookup({ mods: 64U, key: 32U }), Some(@shell.ShortcutAction::ShowDesktop))
|
|
// Left and right Super are the same key for combos.
|
|
assert_true(sc.set(0, Some({ mods: 0U, key: 126U })))
|
|
assert_eq(sc.binding_text(0), "Super")
|
|
assert_eq(sc.find({ mods: 0U, key: 125U }), Some(0))
|
|
// Unbound shortcuts conflict with nothing.
|
|
assert_true(sc.set(1, None))
|
|
assert_eq(sc.conflict(9), None)
|
|
assert_eq(sc.binding_text(1), "")
|
|
sc.reset(1)
|
|
assert_eq(sc.binding_text(1), "Super+D")
|
|
sc.reset_all()
|
|
assert_eq(sc.changed(), [])
|
|
}
|
|
|
|
///|
|
|
test "window switching needs a modifier to hold" {
|
|
let sc = @shell.Shortcuts::defaults()
|
|
assert_false(sc.set(2, @shell.KeyCombo::parse("Tab")))
|
|
assert_false(sc.set(2, @shell.KeyCombo::parse("Super")))
|
|
assert_true(sc.set(2, @shell.KeyCombo::parse("Super+Tab")))
|
|
assert_false(sc.set(99, @shell.KeyCombo::parse("Super+Tab")))
|
|
// Anything else takes any combo.
|
|
assert_true(sc.set(1, @shell.KeyCombo::parse("F9")))
|
|
}
|
|
|
|
///|
|
|
test "changed shortcuts round-trip as (id, text) pairs; bad saved entries keep the default" {
|
|
let a = @shell.Shortcuts::defaults()
|
|
ignore(a.set(1, @shell.KeyCombo::parse("Super+Ctrl+D")))
|
|
ignore(a.set(5, None))
|
|
let saved = a.changed()
|
|
assert_eq(saved, [("show-desktop", "Super+Ctrl+D"), ("screenshot-full", "")])
|
|
let b = @shell.Shortcuts::defaults()
|
|
b.apply_saved(saved)
|
|
assert_eq(b.bindings, a.bindings)
|
|
let c = @shell.Shortcuts::defaults()
|
|
c.apply_saved([("no-such-shortcut", "F1"), ("show-desktop", "Super+Nope"), ("switch-windows", "Tab")])
|
|
assert_eq(c.changed(), [])
|
|
}
|
|
|
|
///|
|
|
test "a rebound shortcut acts on its new combo at once and the old one goes to the client" {
|
|
let comp = new_comp("sc-rebind")
|
|
let key = fn(code : UInt, down : Bool, t : UInt) {
|
|
comp.handle_input(@nested.InputEvent::Key(code, down), t)
|
|
}
|
|
// The launcher moves from a Super tap to Ctrl+Space.
|
|
assert_true(comp.shell.set_shortcut(0, @shell.KeyCombo::parse("Ctrl+Space")))
|
|
key(125U, true, 1U)
|
|
key(125U, false, 2U)
|
|
assert_false(comp.shell.popup_open()) // a Super tap does nothing now
|
|
comp.handle_input(@nested.InputEvent::Modifiers(4U, 0U, 0U, 0U), 3U)
|
|
key(57U, true, 4U)
|
|
key(57U, false, 5U)
|
|
comp.handle_input(@nested.InputEvent::Modifiers(0U, 0U, 0U, 0U), 6U)
|
|
assert_true(comp.shell.popup_open())
|
|
comp.shell.key_down("Escape")
|
|
assert_false(comp.shell.popup_open())
|
|
// Show desktop on Super+K: Super+D no longer shows the desktop, Super+K does.
|
|
assert_true(comp.shell.set_shortcut(1, @shell.KeyCombo::parse("Super+K")))
|
|
comp.desktop_hidden.push(42UL) // what a Super+D would clear
|
|
key(125U, true, 10U)
|
|
key(32U, true, 11U)
|
|
key(32U, false, 12U)
|
|
key(125U, false, 13U)
|
|
assert_eq(comp.desktop_hidden, [42UL])
|
|
key(125U, true, 20U)
|
|
key(37U, true, 21U)
|
|
key(37U, false, 22U)
|
|
key(125U, false, 23U)
|
|
assert_eq(comp.desktop_hidden, []) // nothing on screen: the toggle tried to bring windows back
|
|
assert_false(comp.shell.popup_open())
|
|
}
|
|
|
|
///|
|
|
test "capturing takes the next combo for the shortcut; Escape cancels, Backspace unbinds" {
|
|
let comp = new_comp("sc-capture")
|
|
let key = fn(code : UInt, down : Bool, t : UInt) {
|
|
comp.handle_input(@nested.InputEvent::Key(code, down), t)
|
|
}
|
|
// Show desktop: press Super+Ctrl+D.
|
|
comp.shell.start_shortcut_capture(1)
|
|
assert_eq(comp.shell.shortcut_capturing(), 1)
|
|
key(125U, true, 1U)
|
|
comp.handle_input(@nested.InputEvent::Modifiers(64U | 4U, 0U, 0U, 0U), 2U)
|
|
key(29U, true, 3U)
|
|
key(32U, true, 4U)
|
|
assert_eq(comp.shell.shortcut_capturing(), -1)
|
|
assert_eq(comp.shell.shortcuts.binding_text(1), "Super+Ctrl+D")
|
|
// Its releases are swallowed and the Super release is no tap (the launcher stays shut).
|
|
key(32U, false, 5U)
|
|
key(29U, false, 6U)
|
|
comp.handle_input(@nested.InputEvent::Modifiers(0U, 0U, 0U, 0U), 7U)
|
|
key(125U, false, 8U)
|
|
assert_false(comp.shell.popup_open())
|
|
// Escape cancels: the binding stays.
|
|
comp.shell.start_shortcut_capture(1)
|
|
key(1U, true, 10U)
|
|
key(1U, false, 11U)
|
|
assert_eq(comp.shell.shortcut_capturing(), -1)
|
|
assert_eq(comp.shell.shortcuts.binding_text(1), "Super+Ctrl+D")
|
|
// Backspace unbinds.
|
|
comp.shell.start_shortcut_capture(5)
|
|
key(14U, true, 12U)
|
|
key(14U, false, 13U)
|
|
assert_eq(comp.shell.shortcuts.binding_text(5), "")
|
|
// A Super tap binds "Super"; window switching won't take a combo without a modifier.
|
|
comp.shell.start_shortcut_capture(1)
|
|
key(125U, true, 14U)
|
|
key(125U, false, 15U)
|
|
assert_eq(comp.shell.shortcuts.binding_text(1), "Super")
|
|
assert_false(comp.shell.popup_open())
|
|
comp.shell.start_shortcut_capture(2)
|
|
key(15U, true, 16U)
|
|
key(15U, false, 17U)
|
|
assert_eq(comp.shell.shortcut_capturing(), 2) // still waiting
|
|
key(125U, true, 18U)
|
|
key(15U, true, 19U)
|
|
key(15U, false, 20U)
|
|
key(125U, false, 21U)
|
|
assert_eq(comp.shell.shortcut_capturing(), -1)
|
|
assert_eq(comp.shell.shortcuts.binding_text(2), "Super+Tab")
|
|
// Reset all puts every default back.
|
|
comp.shell.reset_all_shortcuts()
|
|
assert_eq(comp.shell.shortcuts.changed(), [])
|
|
}
|
|
|
|
///|
|
|
test "the settings module's Shortcuts tab lists, captures, flags conflicts and resets" {
|
|
let comp = new_comp("sc-tab")
|
|
let slot = comp.shell.slot_of("session-settings")
|
|
assert_true(comp.shell.open_settings(Shortcuts))
|
|
ignore(comp.compose_frame())
|
|
let pr = comp.shell.slot_popup_rect(slot)
|
|
// A heading, the eleven shortcuts, "Reset all to defaults".
|
|
let n = @shell.shortcut_table.length()
|
|
assert_eq(pr.h, 40 + (n + 2) * 28 + 6)
|
|
// Shortcut i's row (the popup grows upwards from the panel, so read where it is now).
|
|
let row_y = fn(i : Int) { comp.shell.slot_popup_rect(slot).y + 40 + (1 + i) * 28 + 13 }
|
|
// Click "Show the desktop" and press Super+R: no other shortcut has that combo...
|
|
click_at(comp, pr.x + 40, row_y(1), 5U)
|
|
assert_eq(comp.shell.shortcut_capturing(), 1)
|
|
comp.handle_input(@nested.InputEvent::Key(125U, true), 10U)
|
|
comp.handle_input(@nested.InputEvent::Key(19U, true), 11U)
|
|
comp.handle_input(@nested.InputEvent::Key(19U, false), 12U)
|
|
comp.handle_input(@nested.InputEvent::Key(125U, false), 13U)
|
|
ignore(comp.compose_frame())
|
|
assert_eq(comp.shell.shortcuts.binding_text(1), "Super+R")
|
|
assert_eq(comp.shell.shortcuts.conflict(1), None)
|
|
assert_eq(comp.shell.slot_popup_rect(slot).h, pr.h)
|
|
// ...but putting record-the-screen on Super+R too shows a conflict line under the list.
|
|
assert_true(comp.shell.set_shortcut(9, @shell.KeyCombo::parse("Super+R")))
|
|
ignore(comp.compose_frame())
|
|
assert_eq(comp.shell.slot_popup_rect(slot).h, pr.h + 28)
|
|
// "Reset" at the end of row 1 puts show-desktop back; the conflict line goes.
|
|
click_at(comp, pr.x + pr.w - 20, row_y(1), 20U)
|
|
assert_eq(comp.shell.shortcuts.binding_text(1), "Super+D")
|
|
ignore(comp.compose_frame())
|
|
assert_eq(comp.shell.slot_popup_rect(slot).h, pr.h)
|
|
// "Reset all to defaults" (the last row).
|
|
click_at(comp, pr.x + 40, row_y(n), 30U)
|
|
assert_eq(comp.shell.shortcuts.changed(), [])
|
|
// A capture started from the tab ends when the popup closes.
|
|
click_at(comp, pr.x + 40, row_y(3), 40U)
|
|
assert_eq(comp.shell.shortcut_capturing(), 3)
|
|
comp.shell.key_down("Escape")
|
|
assert_eq(comp.shell.shortcut_capturing(), -1)
|
|
}
|
|
|
|
///|
|
|
test "changed shortcuts are saved to state.edn and restored" {
|
|
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
|
write_state_edn("{:note \"keep\"}\n")
|
|
let a = new_comp("sc-save-a")
|
|
a.shell.persist = true
|
|
a.restore_state()
|
|
assert_eq(a.shell.shortcuts.changed(), [])
|
|
assert_true(a.shell.set_shortcut(1, @shell.KeyCombo::parse("Super+Ctrl+D")))
|
|
assert_true(a.shell.set_shortcut(5, None))
|
|
let text = read_state_edn()
|
|
assert_true(text.contains(":shortcuts {:show-desktop \"Super+Ctrl+D\" :screenshot-full \"\"}"))
|
|
assert_true(text.contains(":note \"keep\""))
|
|
let b = new_comp("sc-save-b")
|
|
b.shell.persist = true
|
|
b.restore_state()
|
|
assert_eq(b.shell.shortcuts.binding_text(1), "Super+Ctrl+D")
|
|
assert_eq(b.shell.shortcuts.binding_text(5), "")
|
|
b.shell.reset_all_shortcuts()
|
|
assert_false(read_state_edn().contains(":shortcuts"))
|
|
}
|
|
}
|