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

Gestures are not recognized after suspend and/or bluetooh reconnection #228

Closed
schmunk42 opened this issue Oct 14, 2019 · 23 comments
Closed

Comments

@schmunk42
Copy link

Related issues #68 #160 #167

libinput-gestures: session gnome-xorg+x11 on Linux-5.3.5-arch1-1-ARCH-x86_64-with-arch, python 3.7.4, libinput 1.14.1
/usr/bin/libinput-gestures: hash f95095d1e2bdad0b6c844ae190ede89e
Gestures configured in ~/.config/libinput-gestures.conf:
swipe up         3 xdotool key Home
swipe down       3 xdotool key End
swipe left       3 xdotool key alt+Left
swipe right      3 xdotool key alt+Right
swipe up         4 xdotool key super+a
swipe down       4 xdotool key super+s
swipe left       4 xdotool key super+alt+Left
swipe right      4 xdotool key super+alt+Right
libinput-gestures: device /dev/input/event21: Apple Inc. Magic Trackpad 2

Gestures are not recognized after suspend and/or bluetooh reconnection

I am using an Apple Trackpad 2. When my computer was suspended and woke back up again gestures are not working, despite the above output and debugging with libinput debug-events, where the gestures are detected correctly, but the corresponding actions (eg. super+s) are not triggered.

When I run libinput-gestures-setup restart, gestures are working again. When disabling the external touchpad device, my internal touchpad is detected, but gestures are also not working. Even a reconnection of the external trackpad does not bring back gestures for this device.

While gestures are visible with libinput debug-events, actions are not show via libinput-gestures -v.

A workaround would be to restart libinput-gestures after every device change, but I wonder if this is an issue with this lib.

@bulletmark
Copy link
Owner

It is not "an issue with this lib". It is a problem with libinput or with your hardware not resuming the libinput debug-events utility after a resume. This has been written about in plenty of other issues around here. See #194 (comment) for a solution others have used.

@schmunk42
Copy link
Author

Just to note that, I have the problem after a device change (connect) and libinput debug-events is showing the correct multi finger gestures.

While a suspend also triggers the problem, it seems not to be the root cause of it.

@schmunk42
Copy link
Author

PS: I looked through the code and debugged a bit around.

TL;dr

device all

"fixes" my problem, because all events are now shown via libinput debug-events.

When using a specific device the events get lost, if the connection is lost. And it also does not support switching of trackpads.

stdbuf -oL -- libinput debug-events --device /dev/input/event21

@schmunk42
Copy link
Author

@bulletmark
Copy link
Owner

@schmunk42 so you are actually saying that your /dev/input devices get re-enumerated after a system resume. I am surprised nobody else who has seen this problem has ever mentioned that because it clearly explains what the issue is. Setting device all is not really a fix because it incurs a lot more performance overhead for libinput-gestures to parse all events.

I suspend my laptop all the time and in many years of use I have never seen this problem (i.e. my devices never get re-enumerated after a resume) and it has not been commonly reported so it seems to occur only on some laptops. Note I do see my devices frequently get re-enumerated after a reboot though. I will leave this issue open while I do more research about this issue.

@bulletmark bulletmark reopened this Oct 14, 2019
@bulletmark
Copy link
Owner

bulletmark commented Oct 14, 2019

BTW, please read the description of the device command in libinput-gestures.conf and instead of device all set your device to the absolute path of your device under /dev/input/by-path/ and let me know if that makes any difference.

@schmunk42
Copy link
Author

schmunk42 commented Oct 14, 2019

As mentioned before, this problem does not (only) occur when suspending the laptop. This also happens ie., when I take my laptop to the meeting room without my external touchpad connected via bluetooth. I also can not use gestures with the built-in touchpad then.

To simulate the issue, I switch the touchpad off an back on again ... the /dev/input assignment stays the same, but there is no output at all for libinput debug-events --device ....

Peter Huetterer mentioned here

that's "intentional". when you specify a device path, you really just specify that path and it'll disappear when the device gets disconnected. While it may come back as the same device there's no guarantee for that, the event nodes aren't stable. For example, if you unplug two devices, and re-plug them in the opposite order, the event node numbers are swapped too.

I don't see any other option than all at the moment, taking the above statement into account.

@bulletmark
Copy link
Owner

At the moment I am concentrating on your claim here that libinput-gestures does not work after a simple suspend/resume. Please be clear here if you are talking about the built-in trackpad, or an external one, etc.

If you are using an external device and/or you are reconnecting devices then of course the device numbers will get re-enumerated so you will have to use the dbus solution I pointed you to above, or similar.

@bulletmark
Copy link
Owner

Also, please do the test I asked you to do above.

@schmunk42
Copy link
Author

Please see https://gist.github.com/schmunk42/59a2534adb2c1608bfc8884b6d3644dc for a log output with a specific device.

btw: I can't notice any performance downgrade by using all, I also "just" see an additional keyboard stream.

@bulletmark
Copy link
Owner

That is not what I asked for. Please read what I wrote above. I want you to use the path under /dev/input/by-path/ for whatever touchpad you are having the problem with then observe operation over a suspend.

@bulletmark
Copy link
Owner

Also, whether you notice it or not there is a sizeable compromise on system performance. Setting device all will work but that is a hammer solution.

@schmunk42
Copy link
Author

Also, whether you notice it or not there is a sizeable compromise on system performance. Setting device all will work but that is a hammer solution.

How could I handle the switch of touchpads, when I use a specific path?

@bulletmark
Copy link
Owner

It is not clear to me what you are asking for here. Do you disable your internal touchpad when you plug the Apple touchpad in? How do you normally specify to libinput-gestures which touchpad to use?

@schmunk42
Copy link
Author

That is not what I asked for. Please read what I wrote above. I want you to use the path under /dev/input/by-path/ for whatever touchpad you are having the problem with then observe operation over a suspend.

I don't have a path for the external touchpad (should be linked to /event21, or?):

 schmunk@xps-15  /dev/input/by-path  
> ls -la
total 0
drwxr-xr-x 2 root root 220 Oct 15 07:57 .
drwxr-xr-x 4 root root 580 Oct 15 09:24 ..
lrwxrwxrwx 1 root root  10 Oct 11 11:40 pci-0000:00:14.0-usb-0:12:1.0-event -> ../event12
lrwxrwxrwx 1 root root  10 Oct 15 07:57 pci-0000:00:14.0-usb-0:2.2.2:1.0-event-kbd -> ../event19
lrwxrwxrwx 1 root root  10 Oct 15 07:57 pci-0000:00:14.0-usb-0:2.2.2:1.1-event -> ../event20
lrwxrwxrwx 1 root root   9 Oct 11 11:40 pci-0000:00:15.1-platform-i2c_designware.1-event-mouse -> ../event9
lrwxrwxrwx 1 root root   9 Oct 11 11:40 pci-0000:00:15.1-platform-i2c_designware.1-mouse -> ../mouse0
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-i8042-serio-0-event-kbd -> ../event4
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-INT33D5:00-event -> ../event5
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-pcspkr-event-spkr -> ../event7
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-PNP0C14:03-event -> ../event8

from libinput list-devices:

Device:           Apple Inc. Magic Trackpad 2
Kernel:           /dev/input/event21
Group:            8
Seat:             seat0, default
Size:             162x115mm
Capabilities:     pointer gesture
Tap-to-click:     disabled
Tap-and-drag:     enabled
Tap drag lock:    disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: disabled
Calibration:      n/a
Scroll methods:   *two-finger edge 
Click methods:    button-areas *clickfinger 
Disable-w-typing: n/a
Accel profiles:   none
Rotation:         n/a

Device:           DLL07BE:01 06CB:7A13 Touchpad
Kernel:           /dev/input/event9
Group:            9
Seat:             seat0, default
Size:             102x77mm
Capabilities:     pointer gesture
Tap-to-click:     disabled
Tap-and-drag:     enabled
Tap drag lock:    disabled
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: disabled
Calibration:      n/a
Scroll methods:   *two-finger edge 
Click methods:    *button-areas clickfinger 
Disable-w-typing: enabled
Accel profiles:   none
Rotation:         n/a

@bulletmark
Copy link
Owner

What about under dev/input/by-id? Is there a link there to the Apple touchpad?

@schmunk42
Copy link
Author

It is not clear to me what you are asking for here. Do you disable your internal touchpad when you plug the Apple touchpad in?

No. But I had to restart libinput-gestures, to "make the external work".

How do you normally specify to libinput-gestures which touchpad to use?

At work (with external touchpad) I think it is simply autodetected before the internal.
At home I only have one (internal).

@schmunk42
Copy link
Author

What about under dev/input/by-id? Is there a link there to the Apple touchpad?

No, just my Apple Keyboard.

> ls -la /dev/input/by-id 
total 0
drwxr-xr-x 2 root root 100 Oct 15 07:57 .
drwxr-xr-x 4 root root 580 Oct 15 09:54 ..
lrwxrwxrwx 1 root root  10 Oct 15 07:57 usb-Apple__Inc_Apple_Keyboard-event-if01 -> ../event20
lrwxrwxrwx 1 root root  10 Oct 15 07:57 usb-Apple__Inc_Apple_Keyboard-event-kbd -> ../event19
lrwxrwxrwx 1 root root  10 Oct 11 11:40 usb-CN045G28LOG007AGB6YRA01_Integrated_Webcam_HD-event-if00 -> ../event12

@schmunk42
Copy link
Author

schmunk42 commented Oct 15, 2019

Just noticed: I can plug-in the external touchpad via USB (actually this is usually only used for charging the batteries) and then I see it via event22 (was 21 via bluetooth)

> ls -la /dev/input/by-id
total 0
drwxr-xr-x 2 root root 140 Oct 15 10:03 .
drwxr-xr-x 4 root root 580 Oct 15 10:03 ..
lrwxrwxrwx 1 root root  10 Oct 15 07:57 usb-Apple__Inc_Apple_Keyboard-event-if01 -> ../event20
lrwxrwxrwx 1 root root  10 Oct 15 07:57 usb-Apple__Inc_Apple_Keyboard-event-kbd -> ../event19
lrwxrwxrwx 1 root root  10 Oct 15 10:03 usb-Apple_Inc._Magic_Trackpad_2_CC2551408R5GTFQA1-if01-event-mouse -> ../event22
lrwxrwxrwx 1 root root   9 Oct 15 10:03 usb-Apple_Inc._Magic_Trackpad_2_CC2551408R5GTFQA1-if01-mouse -> ../mouse2
lrwxrwxrwx 1 root root  10 Oct 11 11:40 usb-CN045G28LOG007AGB6YRA01_Integrated_Webcam_HD-event-if00 -> ../event12
 schmunk@xps-15  ~  
> ls -la /dev/input/by-path 
total 0
drwxr-xr-x 2 root root 260 Oct 15 10:03 .
drwxr-xr-x 4 root root 580 Oct 15 10:03 ..
lrwxrwxrwx 1 root root  10 Oct 15 10:03 pci-0000:00:14.0-usb-0:1:1.1-event-mouse -> ../event22
lrwxrwxrwx 1 root root   9 Oct 15 10:03 pci-0000:00:14.0-usb-0:1:1.1-mouse -> ../mouse2
lrwxrwxrwx 1 root root  10 Oct 11 11:40 pci-0000:00:14.0-usb-0:12:1.0-event -> ../event12
lrwxrwxrwx 1 root root  10 Oct 15 07:57 pci-0000:00:14.0-usb-0:2.2.2:1.0-event-kbd -> ../event19
lrwxrwxrwx 1 root root  10 Oct 15 07:57 pci-0000:00:14.0-usb-0:2.2.2:1.1-event -> ../event20
lrwxrwxrwx 1 root root   9 Oct 11 11:40 pci-0000:00:15.1-platform-i2c_designware.1-event-mouse -> ../event9
lrwxrwxrwx 1 root root   9 Oct 11 11:40 pci-0000:00:15.1-platform-i2c_designware.1-mouse -> ../mouse0
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-i8042-serio-0-event-kbd -> ../event4
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-INT33D5:00-event -> ../event5
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-pcspkr-event-spkr -> ../event7
lrwxrwxrwx 1 root root   9 Oct 11 11:40 platform-PNP0C14:03-event -> ../event8

@bulletmark
Copy link
Owner

I noticed you have edited your comments above to remove your statement that you get this same problem with your internal touchpad. So the problem only applies to the removeable touchpad which is as expected given the /dev/input device is re-enumerated. Please try what I said about the suspend test using the USB connection, given you can see the by-path for it.

@schmunk42
Copy link
Author

I noticed you have edited your comments above to remove your statement that you get this same problem with your internal touchpad.

The problem with the internal touchpad seems obvious to me, since, if there's no device set in the config (or not device all), libinput-gestures tries to auto-detect one on startup and does not try detection again.

So the problem only applies to the removeable touchpad which is as expected given the /dev/input device is re-enumerated.

It is usually not re-enumerated when simply switching on/off bluetooth or unplugging/plugging via USB. But for sure, there are different IDs for either USB or Bluetooth

Please try what I said about the suspend test using the USB connection, given you can see the by-path for it.

It also does not work by-path via USB, neither during suspend nor unplug/plug.
Via USB and systemctl suspend I even can not move the mouse-pointer anymore, when the trackpad is only connected via USB, without re-plugging, although this might be a special case with the Apple Trackpad.

@bulletmark
Copy link
Owner

Your description of your problem is still unclear. Are you having a problem with your internal touchpad, or your external touchpad, or both? Please describe the EXACT sequence of events that initiate the problem. You say "The problem with the internal touchpad seems obvious to me". What problem?! There should be no problem with your internal touchpad if you were not plugging an external touchpad. The input device is NOT re-enumerated for your internal touchpad on a resume, contrary to what you appear to believe.

If you want libinput-gestures to automatically switch between internal and external touchpad as the external touchpad is inserted/removed then yes, libinput-gestures is not designed to handle that and you will have to restart it (e.g. automatically via a udev or dbus script), or just use "device all" if you are happy to wear the inefficiency.

@schmunk42
Copy link
Author

If you want libinput-gestures to automatically switch between internal and external touchpad as the external touchpad is inserted/removed then yes, libinput-gestures is not designed to handle that and you will have to restart it (e.g. automatically via a udev or dbus script), or just use "device all" if you are happy to wear the inefficiency.

Issue can be closed then, thanks for the explanation.

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

No branches or pull requests

2 participants