[libinput] Add support for switch devices and events
ClosedPublic

Authored by graesslin on Dec 27 2017, 5:02 PM.

Details

Summary

This change adds support for the switch devices introduces with libinput
1.7 (lid) and 1.9 (tablet mode). So far it's not yet used internally in
KWin, but only exposed through the Device and Events.

As KWin currently only requires libinput 1.5 and we are rather late in
the release cycle the new functionality is ifdef'ed. The requirement
will be raised once master is 5.13. It is already available on
build.kde.org, but e.g. Neon only has 1.6.

The switch events are interesting as they report whether the lid is
closed (might be interesting for e.g. powerdevil) and whether a
convertible is in tablet mode (supported for e.g. Lenovo Yogas with
recent kernel). This can be used by KWin internally to enable/disable
the virtual keyboard. And can be exposed globally to switch to Plasma
Mobile shell in future.

Test Plan

Only through test case as my Lenovo Yoga uses Neon which has a
too old libinput

Diff Detail

Repository
R108 KWin
Branch
libinput-switch
Lint
No Linters Available
Unit
No Unit Test Coverage
graesslin created this revision.Dec 27 2017, 5:02 PM
Restricted Application added a project: KWin. · View Herald TranscriptDec 27 2017, 5:02 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript
graesslin requested review of this revision.Dec 27 2017, 5:02 PM
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptDec 27 2017, 5:02 PM
Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptDec 27 2017, 9:58 PM
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptJan 3 2018, 8:39 PM

Building libinput from source isn't too hard, and maybe then you can test on your hardware?

Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptJan 3 2018, 11:07 PM
romangg accepted this revision.EditedJan 4 2018, 8:35 AM
romangg added a subscriber: romangg.

Code looks good to me. At the moment there is nothing to test anyway, right?

FYI Martin if you want to build libinput in the future on Neon, then you need besides the stuff linked by @ngraham the GNOME Staging PPA since there is a GTK3 dependency. I was also able some time ago to disable building lbinput with its debug console (which needs the GTK3 stuff) so I didn't need the PPA, but with the current meson version I wasn't able to, so I got the PPA and added the following file to /etc/apt/preferences.d/gnome3-team-gnome3-staging (then it only updates the listed four packages from the PPA):

Package: *
Pin: release o=LP-PPA-gnome3-team-gnome3-staging
Pin-Priority: -1

Package: libgtk-3-dev
Pin: release o=LP-PPA-gnome3-team-gnome3-staging
Pin-Priority: 500

Package: libgtk-3-common
Pin: release o=LP-PPA-gnome3-team-gnome3-staging
Pin-Priority: 500

Package: libgtk-3-0
Pin: release o=LP-PPA-gnome3-team-gnome3-staging
Pin-Priority: 500

Package: gir1.2-gtk-3.0
Pin: release o=LP-PPA-gnome3-team-gnome3-staging
Pin-Priority: 500

EDIT: I looked it up again. You need to build lbinput with the -Ddebug-gui=false flag. In this context you can also try out a project, that I just recently started:

https://github.com/subdiff/fdbuild

Assuming you have all dependencies, just do

fdbuild --init-with-template libinput
cd libinput
fdbuild

and it should compile and install libinput. If you want to build with -Ddebug-gui=false change the value in the fdbuild.yaml settings file. Here you can also change the install location and if you have to install as superuser.

This revision is now accepted and ready to land.Jan 4 2018, 8:35 AM
Restricted Application edited projects, added Plasma; removed KWin. · View Herald TranscriptJan 4 2018, 8:35 AM
This revision was automatically updated to reflect the committed changes.
Restricted Application edited projects, added KWin; removed Plasma. · View Herald TranscriptJan 4 2018, 5:06 PM