feat(gui): bind a custom shortcut from the button picker - #784
Open
AalmanSadath wants to merge 2 commits into
Open
feat(gui): bind a custom shortcut from the button picker#784AalmanSadath wants to merge 2 commits into
AalmanSadath wants to merge 2 commits into
Conversation
Action::CustomShortcut is deliberately absent from Action::catalog, so the mouse button picker had no way to reach it: binding a chord to a button meant hand-editing config.toml. The Actions Ring editor already had the field, so this puts the same one in each button's popover and in a gesture button's per-direction flyout. Two differences from the ring's editor. Add stays disabled until the text parses as a KeyCombo, rather than the ring's silent `if let Ok(..)` that commits nothing and says nothing when the chord is malformed. And the field drops `cleanable`, whose glyph took enough of the row to truncate the placeholder, now that it clears itself anyway. One InputState serves every binding popover, since only one is open at a time. It is owned by MouseModelView rather than created per render, which would clear the field on every repaint, and it resets on commit and on every popover open so a chord typed for one button does not follow the user to the next. The placeholder lost its "Shortcut, " prefix to fit the popover; the ring editor moves to the shortened key too, so the catalogs carry one string instead of two near-identical ones.
Greptile SummaryThis PR adds custom-shortcut entry to mouse-button and gesture-direction pickers while sharing and resetting one persistent input field across popovers.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| crates/openlogi-desktop/src/features/mouse/picker.rs | Adds custom-shortcut input, validation, bound-state display, and commit behavior to button and gesture pickers. |
| crates/openlogi-desktop/src/features/mouse/view.rs | Owns the shared shortcut input and clears it across commits, popover transitions, and gesture-direction changes. |
| crates/openlogi-desktop/src/features/action_ring.rs | Moves the action-ring shortcut editor to the shortened localized placeholder. |
| crates/openlogi-ui/locales/en.yml | Replaces the long shortcut placeholder translation key, with equivalent updates across all locale catalogs. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Open button or gesture picker] --> B[Clear shared shortcut input]
B --> C[Enter key combination]
C --> D{Parses as KeyCombo?}
D -- No --> E[Add remains disabled]
D -- Yes --> F[Commit CustomShortcut]
F --> G[Clear shared input]
C --> H[Switch gesture direction]
H --> B
Reviews (2): Last reviewed commit: "fix(gui): clear the shortcut field when ..." | Re-trigger Greptile
Switching direction leaves the same popover open, so it never runs through set_binding_popover_open and the shared field kept whatever had been typed. The flyout is rebuilt with on_pick aimed at the newly selected direction, so pressing Add committed the retained chord to the wrong one. Both paths now reset through a single clear_shortcut_input helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Action::CustomShortcutis deliberately excluded fromAction::catalog, so themouse button picker had no way to reach it — binding a chord to a button meant
hand-editing
config.toml. The Actions Ring editor already had the field, sothis adds the same one to each button's popover and to a gesture button's
per-direction flyout.
Two deliberate differences from the ring's editor:
KeyCombo. The ring'sif let Ok(..)commits nothing and says nothing when the chord is malformed,which is the shape of the confusion in [Bug / Feature Request]: Unable to assign custom single-key shortcuts (like 'C' or 'X') via GUI, and manual TOML edits are overwritten on app restart #518.
cleanableis off. Its glyph took enough of the row to truncate theplaceholder, and the field now clears itself anyway.
Changes
features/mouse/picker.rs: newshortcut_rowshelper — the chord alreadybound (if any), the text field, and an Add button committing through the
existing
PickFn. Prepended to the action list in bothaction_pickerandthe gesture
flyout_card. The bound chord has no catalog row to check, sothe section states it explicitly; without that the picker looks unbound
whenever a shortcut is in use.
features/mouse/view.rs:MouseModelViewowns one lazily-createdInputState, threaded to both popovers. One field for the view, not one perpopover — only one is open at a time, and a per-render entity would clear
the field on every repaint. It resets on commit and on every popover
open/close, so a chord typed for one button does not follow the user to the
next. Reset lives in
set_binding_popover_open, which runs outside paintfor the same reason
gesture_active_dirdoes.features/action_ring.rs: moved to the shortened placeholder key."Shortcut, e.g. Cmd+Shift+P"→"e.g. Cmd+Shift+P"in all21 catalogs, same position, real translations rather than English fill-in. The
longer string did not fit the popover, and both call sites move together so
the catalogs carry one placeholder instead of two near-identical ones.
No wire types changed —
Action::CustomShortcutalready round-trips throughconfig and IPC — so
PROTOCOL_VERSIONis untouched.Testing
All run on Linux with
RUSTFLAGS="-D warnings".cargo xtask ci's skipped jobis
tests (macos)— not reproducible on this host, so not claimed green.Exercised in a dev GUI build against
openlogi-agent-mockon Fedora 44 /Wayland: entering a chord on a button and on a gesture direction, Add disabled
until the text parses, the field clearing on commit and when switching buttons,
and the bound chord showing in the section. Not runtime-tested on hardware —
this is GUI-side only, and whether the agent then fires the chord is the
injector path, which this PR does not touch. Worth noting #514 reports the agent
ignoring a
CustomShortcuton a button; if that is still live it is a separateagent-side bug, not something this change would fix.
Fixes #573