[Github-comments] [geany] keybindings behaving erronously with xmodmap-ed layout (#951)

Colomban Wendling notifications at xxxxx
Thu Mar 10 17:16:24 UTC 2016


Okay, after a lengthy discussion with @ville-h on IRC, gazing at the code and testing, I think I found the source of the issue.

We set an accelerator on menu items using `gtk_widget_add_accelerator()` so GTK displays the binding for us.  But as we also install the accel group on the main window, GTK will actually try and trigger the binding for us if we don't ourselves (or it does it before we do?  I don't think so but I didn't investigate further, and it doesn't matter so much).  Anyway, it seems that this GTK mechanism doesn't agree on the modifiers with us, and gets triggered erroneously.
For some reason GTK uses the event->hardware_keycode, and then translates it, through `_gtk_key_hash_lookup()`.  The behavior seen here might even be wanted somehow if I read quickly, as the docs for this says:

> Looks up the best matching entry or entries in the hash table for a given event. The results are sorted so that entries with less modifiers come before entries with more modifiers.

So maybe their code isn't strictly wrong, but maybe the fact there are several handler mixed (Geany's own, GTK's and Scintilla's) makes it wrongly select an fuzzy match for some reason.


Fixing this might or might not be tricky.  The straightforward solution would be not registering accelerators to GTK in a way that makes it handle them.  This might be as simple as not adding the accel group to the main window (in `keybindings_init()`, and some other places -- look out for `gtk_window_add_accel_group()`).  I didn't test if this has side effects, but @ville-h saw it fixed the issue.

The not straightforward solution, but that might (or might not) be best for everyone could be try and switch all keybinding handling to GTK's mechanisms instead of doing it manually.  This might fix some issues with key handling, or might introduce new ones (like the one discussed here, if it's not merely due to conflicting handlers).  I'm not quite sure what this would require though (note: I'm not really talking about registering actions as Thomas tried once, but "simply" to use GTK's keymap thing or whatever its lowish-level thing is).

Finally, whatever solutions we end up with, it would make sense to add "keybindability" to everything, so not only users can modify some low-level actions (i.e. movements and alike), but also we handle them all in whichever way we do, so there should be no room for fallback to something we didn't expect for any keybinding we actually expect to work.

---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/951#issuecomment-194963260
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160310/401e43db/attachment.html>


More information about the Github-comments mailing list