- 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:
30 files changed
+1304
-149
No files matched your search
@@ -1,4 +1,4 @@
|
||||
///| Alt+Tab window switcher.
|
||||
///| Alt+Tab window switcher (the combo is "Switch windows" in the shortcut table).
|
||||
///
|
||||
/// Hold Alt and press Tab: a list of the open windows (minimized ones too), most recently used
|
||||
/// first, with the previous window selected. Each further Tab moves down the list (Shift+Tab up,
|
||||
@@ -7,9 +7,6 @@
|
||||
/// that had focus is told Alt was let go so it doesn't think it is still held.
|
||||
|
||||
///| evdev codes.
|
||||
let key_tab : UInt = 15
|
||||
|
||||
///|
|
||||
let key_esc : UInt = 1
|
||||
|
||||
///|
|
||||
@@ -70,29 +67,49 @@ fn ChandraCompositor::switcher_close(self : ChandraCompositor, commit : Bool) ->
|
||||
}
|
||||
|
||||
///| Handle a key for the switcher. Returns true when the key is consumed (not for clients).
|
||||
/// Its combo comes from the shortcut table ("switch windows", Alt+Tab by default): holding the
|
||||
/// combo's modifiers, its key opens the switcher and steps down (Shift: up), and letting go of one
|
||||
/// of those modifiers switches.
|
||||
fn ChandraCompositor::switcher_key(self : ChandraCompositor, code : UInt, pressed : Bool, time_ms : UInt) -> Bool {
|
||||
if code == key_lalt || code == key_ralt {
|
||||
self.alt_down = pressed
|
||||
if !pressed && self.switcher_on {
|
||||
let combo = self.shell.shortcuts.combo_for(SwitchWindows)
|
||||
let hold = match combo {
|
||||
Some(c) => c.mods & @shell.combo_mods
|
||||
None => 0U
|
||||
}
|
||||
if @shell.is_modifier_key(code) {
|
||||
if !pressed && self.switcher_on && (@shell.modifier_of_key(code) & hold) != 0U {
|
||||
self.switcher_close(true)
|
||||
}
|
||||
return false // clients still see Alt itself
|
||||
return false // clients still see the modifiers themselves
|
||||
}
|
||||
let key = match combo {
|
||||
Some(c) => c.key
|
||||
None => 0U
|
||||
}
|
||||
if !pressed {
|
||||
// Releases of keys we swallowed must not reach a client either.
|
||||
return self.switcher_on && (code == key_tab || code == key_esc || code == key_up || code == key_down || code == key_left || code == key_right)
|
||||
return self.switcher_on && (code == key || code == key_esc || code == key_up || code == key_down || code == key_left || code == key_right)
|
||||
}
|
||||
if code == key_tab && self.alt_down && !self.shell.inspecting() {
|
||||
let shift = (self.mods & 1U) != 0U
|
||||
// The combo's modifiers held (Shift may be added, to go backwards).
|
||||
let held = self.held_mods()
|
||||
let shift = (held & @shell.mod_shift) != 0U && (hold & @shell.mod_shift) == 0U
|
||||
let combo_held = hold != 0U && (held & (@shell.combo_mods ^ @shell.mod_shift)) == (hold & (@shell.combo_mods ^ @shell.mod_shift)) &&
|
||||
((hold & @shell.mod_shift) == 0U || (held & @shell.mod_shift) != 0U)
|
||||
if code == key && combo_held && !self.shell.inspecting() {
|
||||
if !self.switcher_on {
|
||||
let c = self.switcher_candidates()
|
||||
if c.length() < 2 {
|
||||
return true // nothing to switch to; still not a client's Tab
|
||||
return true // nothing to switch to; still not a client's key
|
||||
}
|
||||
// Let the client that had focus see Alt released: it won't get the real release.
|
||||
// Let the client that had focus see the held modifiers released: it won't get the real
|
||||
// releases.
|
||||
match self.kbd_win {
|
||||
Some(w) => {
|
||||
self.server.keyboard_key(w, time_ms, key_lalt, false)
|
||||
for m in [@shell.mod_alt, @shell.mod_ctrl, @shell.mod_logo, @shell.mod_shift] {
|
||||
if (hold & m) != 0U {
|
||||
self.server.keyboard_key(w, time_ms, @shell.key_of_modifier(m), false)
|
||||
}
|
||||
}
|
||||
self.server.keyboard_modifiers(w, 0U, 0U, 0U, 0U)
|
||||
}
|
||||
None => ()
|
||||
|
||||
Reference in new issue
Block a user