Settings > Shortcuts: rebind the compositor's keyboard shortcuts
CI / test (push) Failing after 18s

- One shortcut table (compositor/shell/shortcuts.mbt): named actions with their default combos,
  the same as before: Super tap launcher, Super+D, Alt+Tab, Super+Shift+S, Super+Shift+Print,
  Print, Super+Print, Super+Ctrl+Print, Super+Shift+R, Super+Alt+R, Super+Ctrl+R. Combos are
  "Super+Ctrl+Alt+Shift+Key" text (parse/print, aliases like Meta, PrtSc, Return); "Super" alone
  is a Super tap. Two shortcuts on one combo conflict and the one listed first wins.
- The compositor looks every non-modifier key press up in the table (compositor/host/
  shortcuts.mbt) instead of the hardcoded checks in showdesktop/screenshot/recorder; the switcher
  reads its combo from it (hold the combo's modifiers, its key steps, Shift reverses, releasing a
  held modifier switches). Matching is now exact on Super/Ctrl/Alt/Shift (caps/num lock ignored),
  so e.g. Super+Shift+D or Ctrl+Print no longer fire Super+D / Print.
- Settings gets a fifth tab, Shortcuts (key 5, SettingsTab::Shortcuts): every shortcut and its
  combo. Click a row (or Enter) and press the new keys: the compositor captures the combo before
  anything else sees it (Escape cancels, Backspace unbinds, a Super tap binds "Super"; window
  switching keeps waiting until the combo has a modifier). Changed rows get a Reset button
  (Backspace/Delete on the highlighted row too), plus "Reset all to defaults"; conflicting combos
  show in red with a line saying which shortcut wins. The popup is 360 px wide for the fifth tab.
- New `shortcuts` capability (shortcuts, capture, cancel-capture, reset, reset-all), served from
  host table 10 and request 18 by the wasmer/wasmtime stub, host-wasm and the MoonBit wasmhost
  (chandra:host/plasmoids `shortcut(s32)`).
- Changes are kept in state.edn as :shortcuts {:show-desktop "Super+Ctrl+D" ...} (only the ones
  that differ; "" unbinds), applied at startup and live.
- There were no window-management or tiling key shortcuts to move into the table.
- Tests: combo parsing/printing, defaults, conflicts, switcher constraint, save/restore pairs,
  rebinding through the compositor, capture (Escape/Backspace/Super tap), the Shortcuts tab
  (capture, conflict line, Reset, Reset all) and the state.edn round trip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hjypNwGHE9WeFvnWLA
This commit is contained in:
Claude committed 2026-11-25 20:41:22 +00:00
1 parent 8ecdef17d4
commit 34885bfdda
30 files changed
+1304 -149

No files matched your search

+27 -10
View File
@@ -71,12 +71,19 @@ pub(all) struct ChandraCompositor {
mut press_fwd : Bool
mut kbd_win : UInt64?
mut mods : UInt
/// A Super key is down and nothing else was pressed since: releasing it opens the launcher.
/// A Super key is down and nothing else was pressed since: releasing it is a Super tap (the
/// launcher by default; shortcuts.mbt).
mut super_solo : Bool
/// Super+D (showdesktop.mbt): whether a Super key is held, whether the D press was swallowed,
/// and the windows it minimized (bottom to top) so a second Super+D can restore them.
/// Whether a Super key is held (shortcuts.mbt).
mut super_down : Bool
mut d_swallowed : Bool
/// Keys a shortcut used, whose release must not reach a client either (shortcuts.mbt).
sc_swallow : Array[UInt]
/// While the Shortcuts tab waits for a combo: keys it took (their releases are swallowed) and
/// whether Super is down alone (a Super tap binds "Super").
capture_swallow : Array[UInt]
mut capture_super : Bool
/// Show desktop (showdesktop.mbt): the windows it minimized (bottom to top) so doing it again
/// can restore them.
mut desktop_hidden : Array[UInt64]
mut layout_mode : @wm.LayoutMode
/// Set when the user asked to end the session (the logout button); the main loop then exits.
@@ -187,7 +194,9 @@ pub fn ChandraCompositor::new(
mods: 0U,
super_solo: false,
super_down: false,
d_swallowed: false,
sc_swallow: [],
capture_swallow: [],
capture_super: false,
desktop_hidden: [],
layout_mode: @wm.LayoutMode::Tiling,
quit_requested: false,
@@ -1260,6 +1269,15 @@ pub fn ChandraCompositor::handle_input(
time_ms : UInt,
) -> Unit {
self.note_activity(@sys.monotonic_ms())
match ev {
Key(code, pressed) => {
self.track_modifier_key(code, pressed)
if self.capture_key(code, pressed) {
return
}
}
_ => ()
}
if self.screenshot_input(ev, time_ms) {
return
}
@@ -1498,17 +1516,16 @@ pub fn ChandraCompositor::handle_input(
Key(code, pressed) =>
if self.switcher_key(code, pressed, time_ms) {
self.super_solo = false
} else if self.show_desktop_key(code, pressed) {
} else if self.shortcut_key(code, pressed) {
self.super_solo = false
} else if code == 125U || code == 126U {
// Super (left/right): a bare tap toggles the launcher search; never reaches clients.
// Super (left/right): a bare tap runs the shortcut bound to "Super" (the launcher by
// default); Super never reaches clients.
if pressed {
self.super_solo = true
} else if self.super_solo {
self.super_solo = false
if !self.shell.inspecting() {
self.shell.toggle_launcher()
}
self.super_tap()
}
} else if self.shell.inspecting() {
self.super_solo = false