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

+5 -36
View File
@@ -1,48 +1,17 @@
///| Super+D: show the desktop.
///| Show the desktop (Super+D by default; the shortcut lives in the shortcut table).
///
/// Minimizes every visible window of the active workspace and remembers them; Super+D again
/// Minimizes every visible window of the active workspace and remembers them; the shortcut again
/// (while nothing is on screen) brings them back in their old stacking order with the one that
/// was on top focused. Opening or restoring a window in between starts over: the next Super+D
/// clears the screen again. Neither the D press nor its release reaches a client.
///|
/// evdev codes.
let key_d : UInt32 = 32
/// was on top focused. Opening or restoring a window in between starts over: the next time
/// clears the screen again. Neither the key press nor its release reaches a client.
///|
/// evdev codes of the Super keys.
let key_lsuper : UInt32 = 125
///|
let key_rsuper : UInt32 = 126
///|
/// Handle a key for Super+D. Returns true when the key is consumed (not for clients).
fn ChandraCompositor::show_desktop_key(
self : ChandraCompositor,
code : UInt32,
pressed : Bool,
) -> Bool {
if code == key_lsuper || code == key_rsuper {
self.super_down = pressed
return false // the Super tap (launcher) is handled by the caller
}
if code != key_d {
return false
}
if !pressed {
// The release of a D we swallowed must not reach a client either.
let swallowed = self.d_swallowed
self.d_swallowed = false
return swallowed
}
if !self.super_down || self.shell.inspecting() {
return false
}
self.d_swallowed = true
self.toggle_show_desktop()
true
}
///|
/// Minimize all visible windows of the active workspace, or restore the ones Super+D hid.
pub fn ChandraCompositor::toggle_show_desktop(