Skip to content
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

More consistent typing #462

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

More consistent typing #462

wants to merge 3 commits into from

Conversation

gerw
Copy link

@gerw gerw commented May 29, 2024

There are some issues like #414, where wrong keys are typed. This might be due to the fact that for typing, the xtest keyboard is used, but xdotool uses another keyboard to map keysyms to keycodes.

I tried to fiddle around and the changes in my repository seem to heal these issues. In some rare occasions, I still get some wrong key presses, though.

@gerw
Copy link
Author

gerw commented May 29, 2024

Now, I have realized that it is even more complicated:

If the variable use_xtest in _xdo_send_key is false, the keys are typed with XSendEvent. This utilizes the mapping of the last used keyboard device (I think this is the Core Keyboard Mapping). In this situation, the old code produces the correct result and the code from this PR might fail.

But it can be even weirded. Consider

xdotool key --window 39845900 o key o key --window 39845900 o

The first o is typed in another window, using the core keyboard mapping and this is the mapping of the keyboard which was used last. The next o is typed into the current window using XTestFakeKeyEvent, i.e. it is using the mapping from the xtest keyboard. This also sets the core keyboard mapping to the mapping of the xtest keyboard. Consequently, the last o is typed again with the core keyboard mapping which now equals the mapping from the xtest keyboard...

@jordansissel
Copy link
Owner

jordansissel commented May 29, 2024 via email

@gerw
Copy link
Author

gerw commented May 29, 2024

I’m wondering if, assuming it can be done correctly, the keyboard mapping code would need to put mappings onto the right xinput device instead of what xdotool does today?

Yes, but this depends on the method which is used to send the keycodes (xtest vs XSendEvent) and might also change during execution...

@gerw
Copy link
Author

gerw commented Jul 2, 2024

I pushed a further commit. This is the best that I came up with. The only downside is that now, _xdo_populate_charcode_map is used in two methods with have a const xdo_t *xdo and the const is casted away... I am not sure how to deal with this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants