-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-Type: Support multiple Xkb layouts #6247
Conversation
That nested for-for-for-for loop is nuts. I'll clean that up. |
320dccf
to
63a81c5
Compare
Linked a bunch of issues now. I feel confident enough this should fix at least the linked ones. |
ee9d0b5
to
c1a998f
Compare
As mentioned auto-type works for multiple keyboard layouts. I tested three us, de and fi positively! Maybe #1915 is related to the Alt-Shift key combo for layout switching which is sometimes hanging. |
Thank you for testing! I'm not exactly sure what causes the layout toggle switch from not working after performing Auto-Type. As I said in the other issue I've had it persistently only once where restarting the X server was the only solution but at that time I didn't debug it as I planned to get back to that later but unfortunately I couldn't reproduce it at all when I got to it. I'm pretty sure it isn't related to modifiers because I was able to reproduce it consistently after every X restart that it failed to switch after a single Auto-Type sequence. Though, if you occasionally have this issue and don't mind using pre-release software it would be interesting to know if with this PR in daily use if you encounter it again. Just make sure you have backups of your database. This PR makes multiple changes to how the input is managed so it may avoid that completely. |
I've built an AppImage for testing purposes. Keep in mind that this is an unsigned and unofficial build of KeePassXC. |
@hifi I will test the version I built from your PR in daily use throughout the week and update you in case I spot any errors or the Alt-Shift Problem reoccurs. If you would like to have an earlier status update, just ping me. |
BTW I have been thinking about adding custom ANSI-C/UTF-8 keyboard layout to the XServer and switch to it for Auto-Type. That way it is not necessary to search for the corresponding keycode in the active/available keyboard layouts and would do away with the nested for loops. |
It's fairly straightforward how searching for a keycode is managed in this PR so I don't see much benefit in adding a custom keymap. The old method of adding a symbol on-the-fly to the current layout would be more feasible to keep. There are a lot of loops but it's not that much data it needs to go through anyway that it would make a meaningful difference in performance. Even if it takes a few milliseconds to build the full keymap and a millisecond or two to find a keycode it wouldn't feel much different having a pre-built complete keymap either. From non-scientific testing the code is fast enough on a modern CPU it types almost instantly if you disable typing delay. |
@hifi, thanks for explanation. I do assume then, that the "old merhod" of adding a symbol to the current keymap would only be performed in case the symbol does not yet exist on the primary/presumed active keymap. Hence in case of @,z,y etc it would first reuse a presumed keycode which in the truly active keymap might have a different symbol. |
@hifi I have been using the new version for one week productively and did not notice any mistypings whatsoever. |
@hifi I have the Alt+Shift not working for keyboard layout switching problem again at the moment. Do you have anything I should do to further analyse the LAlt+LShift problem or would you prefer to log a separate issue for it ? Though typing in the correct keyboard layout (manual switching via the Panel applet in Cinnamon is still possible) works flawless with your patch. I do use Citrix Receiver and Zoom client from time to time. And Zoom client freezes my mouse, which goes away after I close the Zoom session or killall zoom on the command line. So I do not think this has anything to do with KeepassXC to be honest. I have done some more deep digging to find out about the problem and came across this interesting answer on Stack Overflow: Why is the order in which shortcuts keys are executed important?
So once I de/re-activated the NumLock key on my keyboard things (keyboard switch via LAlt+LShift) started working again. I only checked the current state of the keyboard LED mask after the problem disappeared using:
Would you kindly verify whether this is the case for your problem too ?
|
When switching the keyboard layout under normal conditions using LAlt+LShift working the change to my secondary keyboard layout (layouts being us,de, ie. when set to de) is reflected in the following two lines (using watch xset -q):
As mentioned in the #324 this change is reflected just the same in case when utilizing a ternary keyboard layout as with my trials adding us,de,fi keyboard layouts to the mix! That is I cannot distinguish de or fi from each other, as they both show the same in xset -q. That is why I suggested the code used in xkblayout-state to debug further. I have to compile it from scratch next time I am stuck with this issue to get further debug output for comparison. |
So layouts work but switching is still glitching 🤔 Would be nice to know a way to trigger that condition on demand as it's impossible to debug without a consistent repro. Thanks for putting so much effort into this! I wonder if it's just some timing issue with modifiers. |
We are very firmly in niche territory with 3 keyboard layouts, we may have to just accept this is as good as it'll get with this PR. |
This is excellent work @hifi, want to merge it? |
If we can live without remap support, sure, I think this is good enough and can be improved in develop when issues arise. Because the layout switch dying is not related to this PR as it's still present we can fix it separately when we understand the issue better. |
Completely rewritten XCB Auto-Type keymap system. - supports multiple simultaneous layouts - prefers current layout if it has all keysyms available - removed hardcoded KeySymMap - removed clunky custom KeySym emulation Biggest breaking change is removing KeySym emulation for keys that do not exist in any of the layouts currently in use. It would be possible to make it work but if you are trying to type syms that are not available in any of your layouts you are abusing it. It also adds unnecessary complexity and opens up timing issues when the keymap is modified on-the-fly. Now we are just reading it. This also workarounds a Qt related issue where QX11Info::display() returns a connection to X server that fails to receive updated keymap data when client settings change. We use our own connection now to get it working.
c1a998f
to
5fb9619
Compare
@droidmonkey, layouts work also for three keyboard layouts. But the layout toggle switch is also glitching with two layouts. But it may not be apparent with only one =^P |
This is a fairly naive attempt at fixing multiple Xkb layout issues. There are more than one open issue for this but I'm not linking them unless this ends up being mergeable.
Testing strategy
setxkbmap fi,us -option grp:alt_space_toggle
Ensure there's an entry with username that has characters that use different modifiers on each layout,
@
and"
both use Shift-2 for example and changing layouts on-the-fly should keep things working. With old code it should consistently fail and produce the same key always. You can also use any special characters like umlauts.I haven't tested this a lot yet but figured I'd push it out here.
Type of change