- 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
@@ -269,6 +269,7 @@ impl chandra::host::plasmoids::Host for State {
|
||||
Req::Network(action, ssid, password) => {
|
||||
R::Network(chandra::host::plasmoids::NetworkRequest { action, ssid, password })
|
||||
}
|
||||
Req::Shortcut(code) => R::Shortcut(code),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ pub enum Req {
|
||||
/// A network action (0 scan, 1 disconnect, 2/3 Wi-Fi off/on, 4/5 airplane mode off/on,
|
||||
/// 6 connect, 7 forget), the network's name and the password.
|
||||
Network(i32, String, String),
|
||||
/// A shortcuts request: action * 1000 + index (0 capture, 1 reset, 2 reset all, 3 cancel).
|
||||
Shortcut(i32),
|
||||
}
|
||||
|
||||
pub const T_APPS: usize = 0;
|
||||
@@ -72,11 +74,13 @@ pub const T_ICONS: usize = 7;
|
||||
pub const T_NET_STATUS: usize = 8;
|
||||
/// Wi-Fi networks in range (siiii): ssid signal secured active saved.
|
||||
pub const T_NET_NETWORKS: usize = 9;
|
||||
/// Keyboard shortcuts (ssssi): name binding default-binding conflict capturing.
|
||||
pub const T_SHORTCUTS: usize = 10;
|
||||
|
||||
/// Host data every module reads from, shared by all loaded modules.
|
||||
#[derive(Default)]
|
||||
pub struct Shared {
|
||||
pub tables: [Vec<u8>; 10],
|
||||
pub tables: [Vec<u8>; 11],
|
||||
pub layout_mode: i32,
|
||||
pub wallpaper: i32,
|
||||
/// Which session settings are on: bit i for row i of the session settings table.
|
||||
@@ -352,6 +356,38 @@ impl d::power::Host for PState {
|
||||
}
|
||||
}
|
||||
|
||||
impl d::shortcuts::Host for PState {
|
||||
fn shortcuts(&mut self) -> Vec<d::shortcuts::Shortcut> {
|
||||
self.rows(T_SHORTCUTS, "ssssi")
|
||||
.iter()
|
||||
.filter(|r| r.len() == 5)
|
||||
.map(|r| d::shortcuts::Shortcut {
|
||||
name: s(&r[0]),
|
||||
binding: s(&r[1]),
|
||||
default_binding: s(&r[2]),
|
||||
conflict: s(&r[3]),
|
||||
capturing: i(&r[4]) != 0,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
fn capture(&mut self, index: u32) {
|
||||
if index < 1000 {
|
||||
self.shared.borrow_mut().requests.push_back(Req::Shortcut(index as i32));
|
||||
}
|
||||
}
|
||||
fn cancel_capture(&mut self) {
|
||||
self.shared.borrow_mut().requests.push_back(Req::Shortcut(3000));
|
||||
}
|
||||
fn reset(&mut self, index: u32) {
|
||||
if index < 1000 {
|
||||
self.shared.borrow_mut().requests.push_back(Req::Shortcut(1000 + index as i32));
|
||||
}
|
||||
}
|
||||
fn reset_all(&mut self) {
|
||||
self.shared.borrow_mut().requests.push_back(Req::Shortcut(2000));
|
||||
}
|
||||
}
|
||||
|
||||
impl d::screenshot::Host for PState {
|
||||
fn take(&mut self, mode: u32) {
|
||||
if mode <= 3 {
|
||||
|
||||
Reference in new issue
Block a user