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

+15 -2
View File
@@ -59,14 +59,15 @@ enum {
K_PW_SCREEN, K_PW_SET_SCREEN, K_PW_SUSP, K_PW_SET_SUSP, K_PW_SUSPEND, K_PW_OFF, K_PW_REBOOT,
K_BAT_READ,
K_NET_STATUS, K_NET_LIST, K_NET_SCAN, K_NET_CONNECT, K_NET_DISCONNECT, K_NET_FORGET, K_NET_SET_WIFI,
K_NET_SET_AIRPLANE
K_NET_SET_AIRPLANE,
K_SC_LIST, K_SC_CAPTURE, K_SC_CANCEL, K_SC_RESET, K_SC_RESET_ALL
};
typedef struct Env { Inst *inst; int kind; } Env;
/* ---- host data the shell publishes before calling a guest ----
* A table is [u32 rows] then rows of fields, each field a LE i32 ('i') or a u32 byte length + UTF-8 ('s'). */
enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_WALLPAPERS, T_SESSION_SETTINGS, T_ICONS,
T_NET_STATUS, T_NET_NETWORKS, T_N };
T_NET_STATUS, T_NET_NETWORKS, T_SHORTCUTS, T_N };
typedef struct { uint8_t *data; size_t len; } Blob;
static Blob tables[T_N];
static int32_t host_ints[12] = {[7] = -1}; /* 0 layout mode, 1 inspector on, 2 current wallpaper, 3 session settings on (bit i: row i),
@@ -393,6 +394,13 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
* "ssid\x1fpassword" (see wit/host/plasmoids.wit network-request). */
case K_NET_STATUS: build_record(in, T_NET_STATUS, "iissbbbb", a0); break;
case K_NET_LIST: build_list(in, T_NET_NETWORKS, "sibbb", a0); break;
/* Shortcuts: the list from table 10 (name binding default conflict capturing); request 18 is
* action * 1000 + index (0 capture, 1 reset, 2 reset all, 3 cancel the capture). */
case K_SC_LIST: build_list(in, T_SHORTCUTS, "ssssb", a0); break;
case K_SC_CAPTURE: if (a0 >= 0 && a0 < 1000) push_req(18, a0, NULL); break;
case K_SC_RESET: if (a0 >= 0 && a0 < 1000) push_req(18, 1000 + a0, NULL); break;
case K_SC_RESET_ALL: push_req(18, 2000, NULL); break;
case K_SC_CANCEL: push_req(18, 3000, NULL); break;
case K_NET_SCAN: push_req(16, 0, NULL); break;
case K_NET_DISCONNECT: push_req(16, 1, NULL); break;
case K_NET_SET_WIFI: push_req(16, a0 ? 3 : 2, NULL); break;
@@ -588,6 +596,11 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
if (!strcmp(iface, "power") && !strcmp(fn, "suspend")) return K_PW_SUSPEND;
if (!strcmp(iface, "power") && !strcmp(fn, "power-off")) return K_PW_OFF;
if (!strcmp(iface, "power") && !strcmp(fn, "reboot")) return K_PW_REBOOT;
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "shortcuts")) return K_SC_LIST;
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "capture")) return K_SC_CAPTURE;
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "cancel-capture")) return K_SC_CANCEL;
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "reset")) return K_SC_RESET;
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "reset-all")) return K_SC_RESET_ALL;
if (!strcmp(iface, "network") && !strcmp(fn, "status")) return K_NET_STATUS;
if (!strcmp(iface, "network") && !strcmp(fn, "wifi-networks")) return K_NET_LIST;
if (!strcmp(iface, "network") && !strcmp(fn, "scan")) return K_NET_SCAN;