- 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
@@ -0,0 +1,4 @@
|
||||
Keyboard shortcuts: the compositor's named actions (open the launcher, show the desktop, switch
|
||||
windows, screenshots, recordings) and the key combo each is bound to. The shell keeps changed
|
||||
combos in state.edn and they apply at once; a module with this capability (the settings
|
||||
module's Shortcuts tab) lists and rebinds them.
|
||||
@@ -0,0 +1,43 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
|
||||
///|
|
||||
fn wasmImportShortcuts(p0 : Int) = "chandra:desktop/shortcuts@0.1.0" "shortcuts"
|
||||
|
||||
///|
|
||||
fn wasmImportCapture(p0 : Int) = "chandra:desktop/shortcuts@0.1.0" "capture"
|
||||
|
||||
///|
|
||||
fn wasmImportCancelCapture() = "chandra:desktop/shortcuts@0.1.0" "cancel-capture"
|
||||
|
||||
///|
|
||||
fn wasmImportReset(p0 : Int) = "chandra:desktop/shortcuts@0.1.0" "reset"
|
||||
|
||||
///|
|
||||
fn wasmImportResetAll() = "chandra:desktop/shortcuts@0.1.0" "reset-all"
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
|
||||
#|(func (param i32) (result i32) (local i32)
|
||||
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
|
||||
#| local.tee 1 i32.const 0 call $moonbit.init_array8
|
||||
#| local.get 1)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_load8_u(offset : Int) -> Int =
|
||||
#|(func (param i32) (result i32) local.get 0 i32.load8_u)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
|
||||
#|(func (param i32) (param i32) (result i32)
|
||||
#| local.get 0
|
||||
#| local.get 1 call $moonbit.init_array16
|
||||
#| local.get 0)
|
||||
|
||||
///|
|
||||
extern "wasm" fn mbt_ffi_free(position : Int) =
|
||||
#|(func (param i32) local.get 0 call $moonbit.decref)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
warnings = "-44"
|
||||
@@ -0,0 +1,62 @@
|
||||
// Generated by `wit-bindgen` 0.63.0. DO NOT EDIT!
|
||||
///|
|
||||
pub(all) struct Shortcut {
|
||||
name : String; binding : String; default_binding : String; conflict : String; capturing : Bool
|
||||
}
|
||||
///|
|
||||
/// Every shortcut, in the order they are listed.
|
||||
pub fn shortcuts() -> Array[Shortcut] {
|
||||
|
||||
let return_area = mbt_ffi_malloc(8)
|
||||
wasmImportShortcuts(return_area);
|
||||
|
||||
let array : Array[Shortcut] = [];
|
||||
for index = 0; index < (mbt_ffi_load32((return_area) + 4)); index = index + 1 {
|
||||
let iter_base = (mbt_ffi_load32((return_area) + 0)) + (index * 36)
|
||||
|
||||
let result = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 0), mbt_ffi_load32((iter_base) + 4))
|
||||
|
||||
let result0 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 8), mbt_ffi_load32((iter_base) + 12))
|
||||
|
||||
let result1 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 16), mbt_ffi_load32((iter_base) + 20))
|
||||
|
||||
let result2 = mbt_ffi_ptr2str(mbt_ffi_load32((iter_base) + 24), mbt_ffi_load32((iter_base) + 28))
|
||||
|
||||
array.push(Shortcut::{name : result, binding : result0, default_binding : result1, conflict : result2, capturing : (mbt_ffi_load8_u((iter_base) + 32) != 0)})
|
||||
}
|
||||
mbt_ffi_free(mbt_ffi_load32((return_area) + 0))
|
||||
let ret = array
|
||||
mbt_ffi_free(return_area)
|
||||
return ret
|
||||
|
||||
}
|
||||
///|
|
||||
/// Bind shortcut `index` to the next key combo pressed anywhere: the compositor takes that key
|
||||
/// instead of acting on it. Escape cancels, Backspace unbinds. Window switching needs a combo
|
||||
/// with a modifier (it keeps waiting otherwise).
|
||||
pub fn capture(index : UInt) -> Unit {
|
||||
|
||||
wasmImportCapture((index).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
/// Stop waiting for a combo; the binding stays as it was.
|
||||
pub fn cancel_capture() -> Unit {
|
||||
|
||||
wasmImportCancelCapture();
|
||||
|
||||
}
|
||||
///|
|
||||
/// Put shortcut `index` back to its default combo.
|
||||
pub fn reset(index : UInt) -> Unit {
|
||||
|
||||
wasmImportReset((index).reinterpret_as_int());
|
||||
|
||||
}
|
||||
///|
|
||||
pub fn reset_all() -> Unit {
|
||||
|
||||
wasmImportResetAll();
|
||||
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ pub(all) enum Request {
|
||||
PowerAction(Int32)
|
||||
Network(NetworkRequest)
|
||||
MoveInstance(InstanceMove)
|
||||
Shortcut(Int32)
|
||||
}
|
||||
|
||||
pub(all) struct SettingChange {
|
||||
|
||||
@@ -58,6 +58,7 @@ pub(all) enum Request {
|
||||
PowerAction(Int)
|
||||
Network(NetworkRequest)
|
||||
MoveInstance(InstanceMove)
|
||||
Shortcut(Int)
|
||||
}
|
||||
///|
|
||||
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
|
||||
@@ -390,7 +391,8 @@ pub fn set_config(handle : UInt, key : String, value : String) -> Bool {
|
||||
/// (sssi: id name path loaded), 4 instances (sss: slot module name), 5 wallpapers (s), 6 session
|
||||
/// settings (s), 7 icons (si: app id, raster image handle from `raster.load-image`) served by `icons.app-icon`,
|
||||
/// 8 network status (one row, iissiiii: state signal name message wifi-enabled airplane
|
||||
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved).
|
||||
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved), 10 keyboard
|
||||
/// shortcuts (ssssi: name binding default-binding conflict capturing).
|
||||
pub fn publish_table(which : UInt, rows : FixedArray[Byte]) -> Unit {
|
||||
|
||||
let ptr = mbt_ffi_bytes2ptr(rows)
|
||||
@@ -564,6 +566,10 @@ pub fn next_request() -> Request? {
|
||||
|
||||
Request::MoveInstance(InstanceMove::{slot : result4, delta : mbt_ffi_load32((return_area) + 16)})
|
||||
}
|
||||
16 => {
|
||||
|
||||
Request::Shortcut(mbt_ffi_load32((return_area) + 8))
|
||||
}
|
||||
_ => panic()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user