lv2 / pugl

A minimal portable API for embeddable GUIs
https://gitlab.com/lv2/pugl/
ISC License
174 stars 34 forks source link

x11: fix keyboard input with control modifier active #115

Closed falkTX closed 10 months ago

falkTX commented 10 months ago

In X11, using Ubuntu 22.04 KDE Plasma desktop, I could not get proper keyboard events while the control key was held down.

I added a print right after the x11 utf8 key decode, like so:

  printf("x11 special:%d ufound:%d key:%d:'%c' %02x:%02x:'%s'\n",
           special, ufound, event->key.key, event->key.key, ustr[0], ustr[1], ustr);

And this was the print out for Ctrl+C:

x11 special:0 ufound:1 key:3:'' 03:00:''

After the fix from this PR, the following is printed, and yes it then works as expected:

x11 special:0 ufound:1 key:99:'c' 63:00:'c'
drobilla commented 10 months ago

This fixes (arguably, I guess) the key, but there's still text entry of a control character.

drobilla commented 10 months ago

On X11, that's just what the lookup stuff does. I don't know if all such events should just be filtered, or if this breaks whatever input method, or...

falkTX commented 10 months ago

I checked with other modifiers, Alt and Meta still get the key properly, only Control modifier made it lose the regular keys.

drobilla commented 10 months ago

Yeah, it's because the control key is a set bit, at least, uh "traditionally". In this case, I guess they should "always" (?) be filtered out, and it seems weird that the X string lookup stuff does this, but whatever I guess, that's a separate issue. Seems obvious the PuglKeyPressEvent::key shouldn't be shifted/"controlled" here regardless.

Merged as a7803c9, thanks.