JoseExposito / touchegg

Linux multi-touch gesture recognizer
GNU General Public License v3.0
3.68k stars 171 forks source link

Action "`SEND_KEYS`", key `plus`, sends the key `=` and not `+`, sometimes prepended by `]`. #546

Closed dreirund closed 3 years ago

dreirund commented 3 years ago

Describe the bug

I have a gesture configured with the action to send key(s), and I have configured to send the "plus"-key:

  1. In touché, I select:
    • Gesture: Pinch, 2 fingers out
    • Action: keyboard shortcut
    • Shortcut: I press the + key and it prints "plus".
    • Repeat command
  2. The relevant statement of the touchegg.conf then shows
       <gesture type="PINCH" fingers="2" direction="OUT">
         <action type="SEND_KEYS">
           <modifiers></modifiers>
           <keys>plus</keys>
           <repeat>true</repeat>
           <animation>NONE</animation>
           <decreaseKeys></decreaseKeys>
         </action>
       </gesture>
  3. When I perform a two finger pinch out gesture in a terminal or text editor window which has focus, then = are inserted, not a +.
  4. Even sometimes one or two ] are inserted before the =s. (When I set minus, then it correctly prints -s, but sometimes / prepended.) Thes prepending happens only if I make the gesture after the window freshly became focus. Subsequent gestures in the same window without changing to a different window in between do not trigger this.
  5. Test: Also happens when I assign that action to a two finger swipe right.
    • Just once I had it that while making the gesture very short, it did insert ] and after releasing my fingers from the screen, it did continue to input ] indefinitely, until I performed the gesture again. This is hard to reproduce.

Expected behaviour

Print + characters.

Actual behaviour

Prints = characters, sometimes prepended by ].

Logs

touchegg --client --debug:

Touchégg v2.0.12.
Starting Touchégg in client mode
Parsing your configuration file...
Using configuration file "/home/felics/.config/touchegg/touchegg.conf"
Configuration parsed successfully
Connecting to Touchégg daemon...
Connection with Touchégg established
Gesture begin detected
  Gesture information:
    Fingers: 2
    Type: PINCH
    Direction: OUT
  Gesture performed on app: Guake
  Action configured for this gesture
  Starting action
Gesture update detected (2.91705%)
Gesture update detected (6.86721%)
Gesture update detected (9.72349%)
Gesture update detected (15.5576%)
Gesture update detected (19.9635%)
Gesture update detected (24.8253%)
]Gesture update detected (28.6235%)
Gesture update detected (32.5737%)
Gesture update detected (35.825%)
Gesture update detected (39.5624%)
Gesture update detected (42.8441%)
==Gesture update detected (47.3412%)
Gesture update detected (50.3494%)
=Gesture update detected (55.9708%)
Gesture update detected (59.7387%)
Gesture update detected (64.722%)
Gesture update detected (68.3075%)
=Gesture update detected (71.8019%)
Gesture update detected (74.7493%)
=Gesture update detected (78.0918%)
Gesture update detected (81.1911%)
=Gesture update detected (85.5667%)
Gesture update detected (88.818%)
Gesture update detected (96.0194%)
Gesture update detected (99.3619%)
=Gesture update detected (100%)
Gesture end detected
=

Your environment

JoseExposito commented 3 years ago

I'm not able to reproduce it on GNOME:

image

I think this is most likely related to your keyboard configuration. On an ANSI keyboard (USA) "+" and "=" are in the same key. I tested it with an ISO keyboard (European version) and I wasn't able to reproduce the issue.

What kind of keyboard are you using?

dreirund commented 3 years ago

Also with keyboards I have quite a custom configuration:

I have a laptop keyboard which has some keys at quite unusual position, and the key labeling is US layout. So I use US layout for that keyboard by default in the X server.

And then I have an USB keyboard, where I use Germen layout for by default.

See here for a photograph of the hardware.

And I have configured a few other layouts I can switch to.

More specifically, I have the following keyboard configuration in /etc/X11/xorg.conf.d/05-keyboard.conf:

# See `man xkeyboard-config`
# Options for compose: `grep "compose:" /usr/share/X11/xkb/rules/base.lst`

## Default for some random keyboards
Section "InputClass"
        Identifier "Generic keyboard"
        MatchIsKeyboard "on"
        Driver     "libinput"
        Option     "XkbModel"    "pc106"
        Option     "XkbLayout"   "de,cz,ru,ua"
        Option     "XkbVariant"  ",,phonetic,phonetic"
        Option     "XkbOptions"  "grp:ctrls_toggle,terminate:ctrl_alt_bksp,nbsp:none,keypad:future,kpdl:dotoss,numpad:shift3,grab:break_actions,shift:both_capslock_cancel,eurosign:e,compose:caps"
EndSection

## Builtin keyboard on GPD MicroPC
Section "InputClass"
        Identifier "GPD MicroPC keyboard"
        MatchIsKeyboard "on"
        MatchProduct "AT Translated Set 2 keyboard"
        Driver     "libinput"
        Option     "XkbRules"    "evdev"
        Option     "XkbModel"    "pc105"
        Option     "XkbLayout"   "us,cz,ru,ua"
        Option     "XkbVariant"  "altgr-intl,,phonetic,phonetic"
        Option     "XkbOptions"  "grp:ctrls_toggle,terminate:ctrl_alt_bksp,nbsp:none,grab:break_actions,shift:both_capslock_cancel,compose:caps"
        # ,eurosign:e"
EndSection

This configures the laptop keyboard ("AT Translated Set 2 keyboard", the second section in the file) for us layout per default, and all other keyboards for de layout per default.

Does that make sense for you in understanding what happens?

xinput list:

⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ AMR-4630-XXX-0- 0-1023 USB KEYBOARD Mouse id=9    [slave  pointer  (2)]
⎜   ↳ USB Optical Mouse                         id=12   [slave  pointer  (2)]
⎜   ↳ Lite-On Tech IBM USB Travel Keyboard with Ultra Nav Mouse id=14   [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Video Bus                                 id=6    [slave  keyboard (3)]
    ↳ Power Button                              id=7    [slave  keyboard (3)]
    ↳ AMR-4630-XXX-0- 0-1023 USB KEYBOARD       id=8    [slave  keyboard (3)]
    ↳ AMR-4630-XXX-0- 0-1023 USB KEYBOARD System Control    id=10   [slave  keyboard (3)]
    ↳ AMR-4630-XXX-0- 0-1023 USB KEYBOARD Consumer Control  id=11   [slave  keyboard (3)]
    ↳ Lite-On Tech IBM USB Travel Keyboard with Ultra Nav   id=13   [slave  keyboard (3)]
    ↳ Lite-On Tech IBM USB Travel Keyboard with Ultra Nav System Control    id=15   [slave  keyboard (3)]
    ↳ Lite-On Tech IBM USB Travel Keyboard with Ultra Nav Consumer Control  id=16   [slave  keyboard (3)]
    ↳ Intel HID events                          id=17   [slave  keyboard (3)]
    ↳ Intel HID 5 button array                  id=18   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=19   [slave  keyboard (3)]

Could it be that touchegg does emit something like "keycodes" (e.g. some codes which are still subject to layout translation by the X server) to the Virtual core XTEST keyboard, and that I should explicitly configure a layout for it? (Which one should I use, if that is the case?)

JoseExposito commented 3 years ago

It looks like Touchégg is being mapped to the US layout.

You can double check it by running xev and performing the pinch gesture to send a "+". In my case:

$ xev
KeyPress event, serial 37, synthetic NO, window 0x2a00001,
    root 0x71a, subw 0x0, time 1713881, (102,97), root:(152,216),
    state 0x0, keycode 35 (keysym 0x2b, plus), same_screen YES,
    XLookupString gives 1 bytes: (2b) "+"
    XmbLookupString gives 1 bytes: (2b) "+"
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x2a00001,
    root 0x71a, subw 0x0, time 1713881, (102,97), root:(152,216),
    state 0x0, keycode 35 (keysym 0x2b, plus), same_screen YES,
    XLookupString gives 1 bytes: (2b) "+"
    XFilterEvent returns: False

And also:

$ xmodmap -pk | grep plus
     35     0x002b (plus)   0x002a (asterisk)   0x005d (bracketright)   0x007d (braceright) 0x005d (bracketright)   0xfe54 (dead_macron)    

It is quite a custom configuration, so I can't tell you exactly what to change (you probably know better than me), but that's the expected output.

Closing the issue as this is a configuration problem, not an issue with Touchégg, but feel free to add more comments if you need help, and I'll try to help you.

dreirund commented 3 years ago

How does Touchégg inject keys? Does it use Virtual core XTEST keyboard?

JoseExposito commented 3 years ago

Touchégg uses the XTest extension to inject keys, so yes, the used device should be XTEST keyboard.