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

+7 -62
View File
@@ -7,7 +7,7 @@
/// picture, Escape cancels; F takes the whole screen and W the active window instead, the arrow
/// keys nudge the selection (Shift+arrows resize it).
///
/// The other Spectacle shortcuts take a picture at once: Print the full screen, Super+Print the
/// The other Spectacle shortcuts (these are the defaults) take a picture at once: Print the full screen, Super+Print the
/// active window, Super+Ctrl+Print the window under the pointer. The screenshot panel module
/// offers the same four modes.
///
@@ -16,13 +16,8 @@
/// user-dirs.dirs names one), put on the clipboard as image/png, and a notification with a
/// thumbnail confirms it for a few seconds.
///| evdev codes.
let key_s : UInt = 31
///|
let key_print : UInt = 99
///|
///| evdev codes (keys on the overlay; the shortcuts themselves are in the shortcut table,
/// compositor/shell/shortcuts.mbt, and can be rebound in Settings > Shortcuts).
let key_enter : UInt = 28
///|
@@ -46,9 +41,6 @@ let mod_shift : UInt = 1
///|
let mod_ctrl : UInt = 4
///|
let mod_logo : UInt = 64
///| What a screenshot takes.
pub(all) enum ShotMode {
/// Draw a rectangle on the overlay (or click a window).
@@ -595,10 +587,9 @@ fn ChandraCompositor::screenshot_input(self : ChandraCompositor, ev : @nested.In
}
}
///| A key, for the shortcuts and the overlay.
///| A key, for the overlay.
fn ChandraCompositor::screenshot_key(self : ChandraCompositor, code : UInt, pressed : Bool) -> Bool {
if code == key_lsuper || code == key_rsuper {
self.super_down = pressed // shared with Super+D
if self.shot is Some(_) {
self.super_solo = false
return true
@@ -613,60 +604,14 @@ fn ChandraCompositor::screenshot_key(self : ChandraCompositor, code : UInt, pres
}
return self.shot is Some(_)
}
let logo = self.super_down || (self.mods & mod_logo) != 0U
let shift = (self.mods & mod_shift) != 0U
let ctrl = (self.mods & mod_ctrl) != 0U
match self.shot {
Some(o) => {
self.shot_swallow.push(code)
self.overlay_key(o, code, shift, ctrl)
self.overlay_key(o, code, (self.mods & mod_shift) != 0U, (self.mods & mod_ctrl) != 0U)
true
}
None => {
if self.shell.inspecting() || self.switcher_on {
return false
}
if code == key_r && logo && (shift || ctrl || (self.mods & mod_alt) != 0U) {
self.shot_swallow.push(code)
self.super_solo = false
self.toggle_recording(
if shift {
ShotMode::Region
} else if ctrl {
ShotMode::WindowUnderCursor
} else {
ShotMode::FullScreen
},
)
return true
}
let mode = if code == key_s && logo && shift {
Some(ShotMode::Region)
} else if code == key_print {
Some(
if logo && shift {
ShotMode::Region
} else if logo && ctrl {
ShotMode::WindowUnderCursor
} else if logo {
ShotMode::ActiveWindow
} else {
ShotMode::FullScreen
},
)
} else {
None
}
match mode {
Some(m) => {
self.shot_swallow.push(code)
self.super_solo = false
self.take_screenshot(m)
true
}
None => false
}
}
// The shortcuts that start screenshots and recordings are in the shortcut table (shortcuts.mbt).
None => false
}
}