Repository navigation
fix(keybindings): look up the bound keyval before the ASCII fallback - #2365
Open
shaktimaan00 wants to merge 1 commit into
Open
shaktimaan00 wants to merge 1 commit into
shaktimaan00 wants to merge 1 commit into
Conversation
Keypad shortcuts never fired: activate() rewrote every keyval above 126 to the first ASCII keysym on the same keycode, so a shortcut bound to <Primary>KP_Divide (65455) was looked up as slash (47), which load_accelerators() had never registered. Worse, a binding on that ASCII key was triggered instead, so Ctrl+KP_Subtract ran zoom-out. The rewritten keysym is now only a fallback: the keyval itself is looked up first, which restores keypad bindings while keeping Guake#1946 fixed, as non-latin layouts still reach their English keysym through the second lookup. Fixes Guake#2351 sem-ver: bugfix
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.
Keypad shortcuts never fire: try the bound keyval before the ASCII fallback
Keybindings.activate()rewrites every keyval above 126 to the first ASCII keysym found on the samehardware keycode, so that shortcuts keep working on non-latin layouts (#1946). Every keypad keysym is
above 126, so the rewrite also hit them: a shortcut bound to
<Primary>KP_Dividewas looked up asslash(47), a keyvalload_accelerators()had never registered, and the keystroke was handed toVTE —
/got typed. When the ASCII key on that keycode happened to carry a default binding, thewrong action ran instead:
Ctrl+KP_Subtractrewrote tominusand triggeredzoom-out.The rewritten keysym becomes a fallback instead of a replacement. The keyval itself is looked up
first, the ASCII one second, so:
<Primary>KP_Divideonsplit-tab-verticalsplits),The second lookup only happens when the rewrite actually ran (
ascii_key is not None), so thelatin-layout path — one keyval, one case-fold, one lookup — is unchanged. That is also why I did not
use the unconditional
lookup[event.keyval] or lookup[key]form: it would additionally make anuppercase registration such as
<Control>Astart firing onCtrl+Shift+A, a behaviour change thisissue does not ask for.
Changes
guake/keybindings.py—activate(): keep the rewritten keysym inascii_key, look upevent.keyvalfirst when it exists, thenascii_key.guake/tests/test_keybindings.py(new) — four tests, one per acceptance item; they driveactivate()with a stubGdk.Keymapand thefrpc105 keyvals from the report(
106: KP_Divide, slash, division,82: KP_Subtract, minus,28: е, t).releasenotes/notes/bugfix-numpad-keybindings-0e21c8e24e6fb5a4.yaml(new) — the reno noteCONTRIBUTINGasks for.Acceptance
test_keypad_binding_fires:<Primary>KP_Divideonsplit-tab-vertical, event keyval 65455on keycode 106 →
activate()returnsTrueand the action runs.split-tab-vertical = <Primary>KP_Divide+Ctrl+KP_Dividesplits the terminal vertically,instead of
/reaching the terminal. Same test:activate()returningTrueis what stopsthe event being propagated to VTE, and the bound callable is the
split_v()action(
Keybindings.__init__bindssplit-tab-verticalto...split_v()).test_keypad_binding_is_not_shadowed_by_the_ascii_keysym_on_its_keycode: with both<Primary>KP_Subtractand<Primary>minusregistered,Ctrl+KP_Subtractruns the former andzoom-outis never called.test_non_latin_keyval_falls_back_to_the_english_keysym: keyval 1077(Cyrillic
е) on keycode 28 still reaches<Control>t.<Primary>slashkeeps working from the keypad key when nothing is bound to the KP keysym.test_ascii_keysym_still_fires_when_the_keypad_key_has_no_binding.The two regression cases fail with the old
activate()(git stash push -- guake/keybindings.py):What I could not check here: a real X session with a physical numpad and an
frpc105 layout. Thetests replay the keyvals/keycodes the report dumped from that keymap, but nobody has pressed the key
on the patched build.
Commands run
Container:
python:3.11-bookworm+gir1.2-gtk-3.0,gir1.2-keybinder-3.0,gir1.2-wnck-3.0,gir1.2-notify-0.7,libutempter0,gsettings-desktop-schemas,xvfb,xauth,libglib2.0-bin;pip install pycairo "pygobject<3.52" pytest==8.3.4 pytest-mock pyfakefs, andmake generate-paths,make compile-glib-schemas-dev,pip install -e . --no-deps(their CI'smake dev-actionsequivalent). Run asGSETTINGS_SCHEMA_DIR=/work/guake/data xvfb-run -a …, i.e.their
make test-actionsxvfb path.pytest guake/tests/test_keybindings.py -qkeybindings.pystashedpytest guake -qblack --check guake --extend-exclude guake/_version.pyflake8 guakepylint --rcfile=.pylintrc guakereno -q linttab_activity_indication-be54b262d370a96b.yaml, not touched here)