Bug 101008 - SW_TABLET_MODE not handled by libinput
Summary: SW_TABLET_MODE not handled by libinput
Status: RESOLVED FIXED
Alias: None
Product: Wayland
Classification: Unclassified
Component: libinput (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Peter Hutterer
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 86223 100551
Blocks: 102408
  Show dependency treegraph
 
Reported: 2017-05-11 17:10 UTC by Davide Depau
Modified: 2018-03-19 08:47 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Outputs of a few commands (2.23 KB, application/gzip)
2017-05-11 17:10 UTC, Davide Depau
Details
evemu recording from attachment 131317 (3.16 KB, text/plain)
2017-05-16 23:24 UTC, Peter Hutterer
Details
attachment-30460-0.html (1.76 KB, text/html)
2017-08-19 18:39 UTC, Davide Depau
Details
New events recording (2.45 KB, text/plain)
2018-03-17 13:22 UTC, Davide Depau
Details
Touchpad events recording (6.78 KB, text/plain)
2018-03-17 13:25 UTC, Davide Depau
Details
Touchpad events recording (verbose) (9.40 KB, text/x-log)
2018-03-19 08:06 UTC, Davide Depau
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Davide Depau 2017-05-11 17:10:21 UTC
Created attachment 131317 [details]
Outputs of a few commands

I'm running libinput 1.6.3 on Ubuntu 17.04. I noticed that Xorg does not detect the SW_TABLET_MODE event.
In fact, libinput doesn't seem to either. While evtest and evemu correctly report all the events, libinput-debug-events does not.
I attached a couple command outputs to show this.

The computer is a Lenovo ThinkPad X1 Yoga 1st gen, the device in question, as you'll able to see in the logs, is "ThinkPad Extra Buttons".
Comment 1 Peter Hutterer 2017-05-12 04:15:28 UTC
yeah, that code is simply missing right now. I assume there's code in the DE that handles it?
Comment 2 Peter Hutterer 2017-05-16 23:21:49 UTC
Relevant gnome-settings-demon bug: https://bugzilla.gnome.org/show_bug.cgi?id=740037
Which links to bug #86223 but that one only merged the switch interface, not the tablet mode code.
Relevant mutter bug:https://bugzilla.gnome.org/show_bug.cgi?id=744036

Looks like everyone is waiting for libinput, sorry about that.
Comment 3 Peter Hutterer 2017-05-16 23:24:48 UTC
Created attachment 131376 [details]
evemu recording from attachment 131317 [details]
Comment 4 Peter Hutterer 2017-05-17 03:15:35 UTC
branch for testing: https://github.com/whot/libinput/tree/wip/sw-tablet-mode
patches for review on the list: https://lists.freedesktop.org/archives/wayland-devel/2017-May/034120.html
Comment 5 Davide Depau 2017-06-09 15:10:26 UTC
I guess this needs testing. Is it okay if I cherry pick the patches and apply them to Ubuntu's source package to minimize incompatibilities?
Comment 6 Peter Hutterer 2017-06-10 02:33:20 UTC
should work, should even be ABI compatible (run-time anyway) if you have to remove it later (at least until we introduce some new switch that has the same value)
Comment 7 Peter Hutterer 2017-08-17 22:55:32 UTC
Davide - you got any status update for me here? What part of the DE handles the tablet mode anyway?
Comment 8 Davide Depau 2017-08-19 18:39:56 UTC
Created attachment 133629 [details]
attachment-30460-0.html

Sorry I forgot about this. I'll set a reminder for next week to test it.
I don't know about what part of the DE handles it, I'm sure there are apps
(Onboard) that detect it and change their behavior accordingly.

On Fri, Aug 18, 2017 at 12:55 AM <bugzilla-daemon@freedesktop.org> wrote:

> *Comment # 7 <https://bugs.freedesktop.org/show_bug.cgi?id=101008#c7> on
> bug 101008 <https://bugs.freedesktop.org/show_bug.cgi?id=101008> from Peter
> Hutterer <peter.hutterer@who-t.net> *
>
> Davide - you got any status update for me here? What part of the DE handles the
> tablet mode anyway?
>
> ------------------------------
> You are receiving this mail because:
>
>    - You are on the CC list for the bug.
>    - You reported the bug.
>
>
Comment 9 Peter Hutterer 2017-08-28 04:47:27 UTC
what do you mean by "apps (Onboard)"? libinput only passes this on to the wayland compositor, nothing else would have access to it. So unless some compositor takes that switch event and sends it to a client (there's no public wayland protocol for that btw) no app can see it.

Unless you're using libinput in a direct context for some custom software, but that's not the case based on comment #0
Comment 10 Davide Depau 2017-09-01 12:15:23 UTC
I'm going to test the patch now. Sorry for the delay, I've been quite busy.

> what do you mean by "apps (Onboard)"? libinput only passes this on to the
> wayland compositor, nothing else would have access to it. So unless some 
> compositor takes that switch event and sends it to a client (there's no
> public wayland protocol for that btw) no app can see it.

I'm not sure what happens under the hood, but Onboard has a setting regarding SW_TABLET_MODE. Maybe it works on Xorg only (which is what I mainly use by the way, I sometimes need to run GUI programs as root).

Here's a screenshot of Onboard settings: https://s26.postimg.org/5lv8bi7dl/Screenshot_from_2017-09-01_14-12-54.png
Comment 11 Davide Depau 2017-09-01 12:53:05 UTC
Okay, I replayed changes from your GitHub repository into Ubuntu's sources and built it. Basically nothing changed. 'libinput debug-events' shows nothing.
Evtest still shows the switch event.
Comment 12 Peter Hutterer 2017-09-04 03:53:40 UTC
From https://launchpad.net/onboard/1.4/1.4.0:
     - Add detection based on acpid reporting the SW_TABLET_MODE switch

So you need acpid running, and the code in question connects to /var/run/acpid.socket (see class AcpidListener). Didn't chase it down past that, but it means this is completely independent on libinput and I doubt onboard would use libinput anyway. Really this should be a compositor-wide state exposed via e.g. dbus or whatever.


That aside, this will get added as part of bug 102408 because that's a real use-case that we need to fix.
Comment 13 Davide Depau 2017-09-07 08:49:25 UTC
> So you need acpid running, and the code in question connects to /var/run/acpid.socket (see class AcpidListener).

Mmh that's weird because I have both acpid running and the socket.
I'll look at that at some point.

Let me know if you need me to test anything else.

By the way I still think application/shells may want to use SW_TABLET_MODE if that's possible (e.g change user interface based on that)
Comment 14 Peter Hutterer 2017-09-07 22:04:01 UTC
"may want to use" - if I could remove all the features I implemented in various software over the years and that never got used by anyone, things would be a lot easier to maintain ;)
Comment 15 Peter Hutterer 2017-09-10 23:40:28 UTC
commit 82f2dd8faa0f78351f0c59431a374166cb851c9e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Apr 21 17:52:37 2017 +1000

    Add support for SW_TABLET_MODE
    
    https://bugs.freedesktop.org/show_bug.cgi?id=101008
Comment 16 Davide Depau 2018-03-17 13:22:39 UTC
Created attachment 138170 [details]
New events recording

Hello,
I kind of forgot of this issue, but recently installed Arch Linux (libinput 1.10.3) and noticed that not only tablet mode is handled for the most parts, but that it's also somehow detecting tablet mode "correctly" (i.e. on my computer, tablet mode used to be triggered only when the laptop display was rotated completely, touching the back of the computer. It's now triggered as soon as it's past 180°).

I noticed the following issues on my computer, however:

- When tablet mode is ON, the trackpoint is disabled; the touchpad is not.
- My computer has a convenient volume rocker on the side and a Super button right under the touchscreen. When tablet mode is ON, they're disabled.

Notice that my computer physically blocks the keyboard past 180°, so there's no need to disable keyboard input in this particular model.

I recorded an event log. I only pressed the side and touchscreen buttons on this test, and as you can see they only work when it's not in tablet mode.
Comment 17 Davide Depau 2018-03-17 13:25:57 UTC
Created attachment 138171 [details]
Touchpad events recording

This log is for the touchpad that doesn't get disabled.
Comment 18 Peter Hutterer 2018-03-19 05:25:26 UTC
Davide, can I have separate bugs for those please, the code that originally fixed this is still there so I guess some kernel changes are the cause here.

> It's now triggered as soon as it's past 180°

fwiw, this is not something libinput controls, we merely get the message from the kernel but we don't know when that is generated. So great if it works better, but you probably have to thank the kernel developers for that :)


For the touchpad issue, I'll need the libinput debug-events --verbose output, thanks. The volume/keyboard thing is related to Bug 103749
Comment 19 Davide Depau 2018-03-19 08:06:02 UTC
Created attachment 138191 [details]
Touchpad events recording (verbose)

Okay, this is `debug-events --verbose` with some touchpad actions in tablet mode.
I'll subscribe to the other bug for the volume buttons issue.
Comment 20 Davide Depau 2018-03-19 08:47:37 UTC
By the way, the tablet mode triggering issue has been fixed in the thinkpad_acpi kernel module, indeed:
https://github.com/torvalds/linux/commit/b03f4d49469f3bde9600192af15b8f17f8673679#diff-e2e320fe537c53110c8355bb95815c8e


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.