- 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
@@ -9,6 +9,9 @@
|
||||
/// :theme :light ; the settings module's Dark mode switch is off (absent: dark)
|
||||
/// :power {:screen-off 5 :suspend 30} ; minutes without input before the screen goes off /
|
||||
/// ; the computer suspends, 0 never (absent: 10 and 0)
|
||||
/// :shortcuts {:show-desktop "Super+Ctrl+D" :screenshot-full ""}
|
||||
/// ; keyboard shortcuts changed from their defaults ("" unbinds;
|
||||
/// ; ids and combo syntax in shortcuts.mbt)
|
||||
/// :session [{:app "foot"} {:app "org.gnome.Nautilus" :minimized true}]
|
||||
/// ; the windows open when the last session ended, reopened at
|
||||
/// ; the next start (see session.mbt in compositor/host)
|
||||
@@ -38,6 +41,8 @@ pub(all) struct SavedState {
|
||||
dark_mode : Bool?
|
||||
/// From `:power`: (screen-off, suspend) minutes; a missing one keeps its default.
|
||||
power : (Int?, Int?)
|
||||
/// From `:shortcuts`: (id, combo text) pairs; empty when the file doesn't say.
|
||||
shortcuts : Array[(String, String)]
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -51,7 +56,7 @@ let layout_names : Array[String] = ["tiling", "monocle", "floating"]
|
||||
///| The keys this build owns; everything else in the file is kept as it is.
|
||||
let owned_keys : Array[String] = [
|
||||
"layout", "recent", "desktop-card", "windows", "wallpaper", "restore-session", "remember-windows",
|
||||
"theme", "power",
|
||||
"theme", "power", "shortcuts",
|
||||
]
|
||||
|
||||
///| How state.edn names each wallpaper, in `@libshell.wallpaper_names` order.
|
||||
@@ -97,6 +102,7 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
|
||||
remember_windows: None,
|
||||
dark_mode: None,
|
||||
power: (None, None),
|
||||
shortcuts: [],
|
||||
}
|
||||
}
|
||||
let entries = read_state_file()
|
||||
@@ -208,6 +214,19 @@ pub fn DesktopShell::load_state(self : DesktopShell) -> SavedState {
|
||||
}
|
||||
_ => (None, None)
|
||||
},
|
||||
shortcuts: match lookup_key(entries, "shortcuts") {
|
||||
Some(Mapping(m)) => {
|
||||
let out : Array[(String, String)] = []
|
||||
for e in m {
|
||||
match e {
|
||||
(Keyword(k), Text(v)) | (Text(k), Text(v)) => out.push((k, v))
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
_ => []
|
||||
},
|
||||
dark_mode: match lookup_key(entries, "theme") {
|
||||
Some(Keyword("light")) => Some(false)
|
||||
Some(Keyword("dark")) => Some(true)
|
||||
@@ -245,6 +264,7 @@ pub fn DesktopShell::apply_state(self : DesktopShell, st : SavedState) -> Unit {
|
||||
Some(m) if m >= 0 => self.suspend_min = m
|
||||
_ => ()
|
||||
}
|
||||
self.shortcuts.apply_saved(st.shortcuts)
|
||||
match st.desk {
|
||||
Some((x, y)) => {
|
||||
self.desk_set = true
|
||||
@@ -323,6 +343,12 @@ pub fn DesktopShell::save_state(self : DesktopShell) -> Unit {
|
||||
(@edn.Value::Keyword("suspend"), @edn.Value::Integer(self.suspend_min.to_string())),
|
||||
])))
|
||||
}
|
||||
let changed = self.shortcuts.changed()
|
||||
if changed.length() > 0 {
|
||||
entries.insert(2, (@edn.Value::Keyword("shortcuts"), @edn.Value::Mapping(
|
||||
changed.map(c => (@edn.Value::Keyword(c.0), @edn.Value::Text(c.1))),
|
||||
)))
|
||||
}
|
||||
if !self.dark_mode {
|
||||
entries.insert(2, (@edn.Value::Keyword("theme"), @edn.Value::Keyword("light")))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user