termux / termux-x11

Termux X11 add-on application.
https://termux.dev
GNU General Public License v3.0
1.72k stars 274 forks source link

[Bug]: ctrl-space-workaround does not work #665

Open natebragg opened 4 days ago

natebragg commented 4 days ago

Problem description

Some systems don't handle CTRL+space correctly. On my machine, running xev from within termux-x11 -xstartup "aterm", pressing and releasing left CTRL results in the following output:

KeyPress event, serial 32, synthetic NO, window 0x600001,
    root 0x511, subw 0x0, time 10088320, (1466,1198), root:(1467,1199),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x600001,
    root 0x511, subw 0x0, time 10089266, (1466,1198), root:(1467,1199),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

Pressing left CTRL followed by pressing the space bar results in the following output:

KeyPress event, serial 32, synthetic NO, window 0x600001,
    root 0x511, subw 0x0, time 10091627, (1466,1198), root:(1467,1199),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

KeyRelease event, serial 32, synthetic NO, window 0x600001,
    root 0x511, subw 0x0, time 10092033, (1466,1198), root:(1467,1199),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

These are the same except for the time field. This same issue is present in normal termux, and is fixed using the ctrl-space-workaround setting inside the .termux/termux.properties file.

Please include a setting that fixes the same issue.

What steps will reproduce the bug?

Follow the steps above.

What is the expected behavior?

CTRL+space is processed properly, and gives the correct keycodes inside xev.

twaik commented 4 days ago

.termux/termux.properties is a properties file of termux-app, not related to termux-x11. Try to disable Hardware keyboard scancodes workaround in preferences.

natebragg commented 4 days ago

Disabling that did not work. And yes, I aware that file has nothing to do with termux-x11, I only meant that the behavior was the same between the two, and that that property was how it was fixed in termux.

twaik commented 4 days ago

Try using Prefer scancodes when possible and if it does not work re-enable hardware keyboard scancodes workaround.

twaik commented 3 days ago

Did it work?

twaik commented 3 days ago

@natebragg

natebragg commented 3 days ago

None of the 4 combinations of these two options enable CTRL+space. Although they do change the behavior of the keyboard. I use the us Dvorak layout, and using those options requires me to setxkbmap 'us(dvorak)'.

My device is unique, and apparently vanilla termux does not correctly handle this by default, which is why you must use the previously mentioned config line. Take a look at their code that handles this option to see how they fix CTRL+space on weird devices.

twaik commented 2 days ago

Ok, I need the log with "TERMUX_X11_DEBUG=1" of termux-x11 not getting these events. Use this apk. app-universal-debug.zip

natebragg commented 2 days ago

Here is the log I collected, with some potentially helpful notes added at the top of the file:

ctrl+space.log

In case it helps, this was pretty much the same behavior when I was trying to figure out this issue in the termux app: termux/termux-app#3896 .

As a separate issue, not sure if the following changes are intentional, but on my hardware the debug version you sent me behaves quite differently than the release I had installed. I use a Meta Quest 3, and after launching termux-x11, 1) it required using the controllers which is bizarre as I almost always work using hand tracking, 2) it blew away all the other apps when it launched, meaning I was unable to multitask, 3) the window was unable to be resized, 4) the cursor did not appear outside of the window making the rest of the system unusable, and 5) the font was like 4pt, which was completely unreadible. Not sure if these are only issues with the debug build or with the non-debug build, but if you can post an apk of the non-debug build I'll test and file any of these bugs that occur there.