Commit graph

44 commits

Author SHA1 Message Date
Martin Gräßlin
cc2f4e3240 Support for relative pointer motion events
Summary:
If KWin interacts with Libinput the RelativePointerManager interface
gets created on the Wayland server. The ForwardInputEventFilter does
forward the relative motion events in addition to the normal motion
events.

In order to properly support the relative motion events as they are
expected by the Wayland protocol the handling of pointer motion events
got slightly adjusted:
* Libinput Pointer event extended by the additional data points
* Libinput Pointer event carries the delta as a QSizeF instead of
QPointF
* PointerInputRedirection adjusted to take a pointer motion event with
more arguments
* Custom QMouseEvent subclass adjusted to carry the additional members

The DebugConsole is adjusted to show the relative motion events in
addition to the global position.

Test Plan:
Verified the manager object is created and verified the
events in DebugConsole. Unfortunately not aware of any test application.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2979
2016-10-12 11:26:46 +02:00
Sebastian Kügler
9f35544940 [libinput] Don't set the parent on the Device
This causes an assert with debug build of Qt due to threading issues.
We don't need the setParent call as we use deleteLater when a device
gets removed.

Reviewed-by: Martin Gräßlin
2016-09-07 10:58:37 +02:00
Martin Gräßlin
ab5d31426a [libinput] Expose all input devices through DBus
Summary:
The Connection exposes a new service called org.kde.KWin.InputDevice
and every Device registers an own object exposing all properties.

This allows an external configuration tool to change the behavior of
the devices at runtime. E.g. to test configuration settings.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2407
2016-08-15 16:10:50 +02:00
Martin Gräßlin
cd6d82fcbc [libinput] Add device configuration for tap-drag-lock
From libinput documentation:
Also optional is a feature called "drag lock". With drag lock disabled,
lifting the finger will stop any drag process. When enabled, libinput
will ignore a finger up event during a drag process, provided the finger
is set down again within a implementation-specific timeout.
2016-08-11 16:32:00 +02:00
Martin Gräßlin
02cf9e8a64 [libinput] Add support for tap and drag
From libinput documentation:
A tap immediately followed by a finger down and that finger being held
down emulates a button press. Moving the finger around can thus drag
the selected item on the screen.
2016-08-11 16:02:26 +02:00
Martin Gräßlin
00f3f990d6 [libinput] Use macro for the standard boolean config setters
Less code duplication
2016-08-11 15:41:06 +02:00
Martin Gräßlin
e18e2eb57c [libinput] Rename Device::tapEnabledByDefault to tapToClickEnabledByDefault
Slightly more descriptive name what the feature is about.
2016-08-11 15:18:40 +02:00
Martin Gräßlin
2f7298bed5 [libinput] Add support for tapToClick configuration
New property added to Device which allows reading and setting the
tap to click configuration.
2016-08-11 15:13:36 +02:00
Martin Gräßlin
e88a709f03 Raise minimum libinput version to 1.2
Now provided on build.kde.org, thus let's properly depend on it and
remove the ifdef.
2016-08-08 09:18:39 +02:00
Martin Gräßlin
8a83a6fef5 [libinput] Add support for gesture events
Summary:
Gesture events are swipe or pinch events on a touch pad.

This change implements basic support by:
 * wrapping them in LibInput::Event
 * processing them in LibInput::Connection and emitting
   dedicated signals
 * Forwarding them in InputRedirection to PointerInputRedirection
 * Support them in the internal input event filter
 * Printing debug information in DebugConsole

Further handling is not yet done. In future the following should be
implemented:
 * activating e.g. zoom and present windows on pinch/swipe gesture
 * forwarding non global gestures to KWayland

Note that forwarding to KWayland is not yet useful as QtWayland does
not yet have support for the unstable protocol. No Qt application could
make use of it yet. So for the moment just global gestures is the best
we can get.

Test Plan: Looked at output of DebugConsole when triggering gestures

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2359
2016-08-08 09:15:06 +02:00
Martin Gräßlin
6a6af0e8b5 [libinput] Add optional device detection for cap tablet tool
The capability tablet tool is new in Libinput 1.2. As build.kde.org
does not yet support this version, it's only an optional check.

So far the code only detects whether the capability exists and reports
this accordingly.
2016-08-03 09:31:47 +02:00
Allen Winter
31f067ede2 pedantic fixes 2016-07-16 13:14:44 -04:00
Martin Gräßlin
9b187f8a3b [libinput] Properly handle threaded Device creation
Summary:
Device is created from Connection::processEvents which is run in the
main gui thread, while Connection itself is in a different thread. Thus
passing *this* as parent is wrong.

This change removes the parent, moves the created Device into the
Connection thread and also deletes properly by using deleteLater.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1746
2016-06-02 16:24:31 +02:00
Martin Gräßlin
c04f193532 [libinput] A not valid LibInput::Context should return -1 as filedescriptor
0 is a valid filedescriptor after all.

Autotest extended to cover this case.
2016-06-02 16:23:23 +02:00
Martin Gräßlin
69cbb40903 Pass LibInput::Device* through the event handlers
Summary:
The signals emitted by LibInput::Connection carry the Device for which
the input event was received. This Device is passed to the input handlers.

Custom event classes are added which extend QMouseEvent, QKeyEvent and
QWheelEvent respectively and expose the Device. The Device is only passed
around as a forward declared pointer, so even if compiled without libinput
support, it should still compile.

Event handlers which need to get access to the Device can now just cast
the event pointer to the custom class and access it. This can be used in
future to handle device specific key codes, etc.

As we don't have a proper event classes for touch events the event
handlers do not yet have access to the Device. Here the internal API
needs to be adjusted in future.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1667
2016-05-30 15:26:37 +02:00
Martin Gräßlin
6d090cd263 [libinput] Add the Device to Event
Summary:
The Event class now holds a pointer to the Device and not only to the
native libinput_device.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1666
2016-05-30 15:23:38 +02:00
Martin Gräßlin
72d9472674 Fix auto-complete failure 2016-05-25 13:28:14 +02:00
Martin Gräßlin
82d2a2f9f1 [libinput] Track all created Devices in Device
Summary:
Device has a static QVector<Device*> into which each created Device
is added and provides a static method to match a libinput_device* to
the already created Device.

This can be used by the the libinput Event class wrapper to properly
reference the Device the event is for.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1665
2016-05-25 12:13:03 +02:00
Martin Gräßlin
9cdd76f20d [libinput] Expose whether an alpha-numeric keyboard is connected
Summary: Similar to the already existing hasKeyboard, hasTouch and hasPointer.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1671
2016-05-24 13:00:41 +02:00
Martin Gräßlin
5e284224ee [libinput] Support toggleTouchpad
Summary:
The LibInput::Device provides a way to enable/disable the device.
This is used by the Connection to toggle all touchpad devices on/off
when the touchpad key is pressed. For this KWin "steals" the global
shortcuts from the touchpad kded.

Detecting what is a touchpad is unfortunately not tivial. The code
uses the following approach:
* it's a pointer
* it's not also a keyboard or touch screen
* it's at least one of the following:
 ** supports multiple tap fingers
 ** supports disable while typing
 ** supports disable on external mouse

If the code finds a touchpad and changes it's state successfully,
it triggers the touchpadEnabledChanged on Plasma's osdService.

Test Plan: Tested on notebook with toggle touchpad button

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1545
2016-05-11 14:19:25 +02:00
Martin Gräßlin
78c70a0775 [lbinput] Support setting pointer acceleration
Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1544
2016-05-11 14:17:05 +02:00
Martin Gräßlin
254573bee1 [libinput] Support for left-handed pointer
Summary:
The configuration file kcminput, group Mouse is parsed to decide whether
pointer devices should be in left handed mode. The config is applied
whenever a new device is added.

In addition the Connection listens to KGlobalSettings for a mouse
settings changed signal which might be emitted by the mouse KCM.

When such a signal is emitted, all pointer devices are reconfigured.

This allows to change the mouse handed settings on Wayland.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1543
2016-05-11 14:12:25 +02:00
Martin Gräßlin
4c9c0c5143 [libinput] Try to fix build on build.kde.org
Apparently libinput is too old and LIBINPUT_DEVICE_CAP_TABLET_TOOL is
not yet available. As we don't use it yet, it's put into the #if 0 part
for future use.
2016-05-06 09:34:20 +02:00
Martin Gräßlin
4d7134f6c7 [libinput] Add a wrapper class Device for a libinput_device
Summary:
The Device class wraps all the information we can get from libinput
about the device, like whether it's a keyboard, pointer, touch, etc.

In addition some more information is queried to figure out how "useful"
a device is. For a keyboard all alphanumeric keys are checked whether
they exist, for a pointer all (normal) buttons are queried.

All the information is exposed as Q_PROPERTY and used by the
DebugConsole. The DebugConsole gained a new tab "Input Devices" which
renders all devices and their properties in a tree view. When plugging
in/out a device, the model gets reset, so it's always up to date.

The new Device class can be used in future to configure the device,
e.g. disable touch pad, set mouse acceleration, etc.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1538
2016-05-06 08:21:49 +02:00
Martin Gräßlin
cc64bb25ae Fix build of stable branch on build.kde.org
CI system doesn't have Qt 5.5 yet, let's not break because of
qCInfo.
2016-03-03 08:00:55 +01:00
Martin Gräßlin
eca06ecb02 [libinput] Install a log handler
Let's get all debug events from libinput and forward them to a custom
log handler. This in turn can pass them to Qt's categorized logging.
So it's still easy to
* disable all libinput related logging
* configure the log level

Both was not possible before.
2016-02-05 12:50:49 +01:00
Martin Gräßlin
5904349c69 [libinput] Event compression for PointerAxis 2015-11-03 10:26:01 +01:00
Martin Gräßlin
123e361f55 [libinput] Pointer motion event compression
If we have multiple pointer motion events we compress it to just one.
2015-11-03 10:26:01 +01:00
Martin Gräßlin
cebd723c2c [libinput] Add an event queue
The Connection thread fills the event queue, it gets read from the
main thread. In order to properly support the threaded approach the
setup is changed to delegate into the own thread.
2015-11-03 10:26:01 +01:00
Martin Gräßlin
1cfd72f49f [libinput] Use a dedicated thread for libinput
When the Connection is created we move it into a dedicated thread
so that even processing happens in the thread. Currently all events
are still queued directly.
2015-11-03 10:26:01 +01:00
Martin Gräßlin
ea77d32259 [libinput] Make signals queueable
* Declare and register enums as metatypes
* quint32 instead of uint32_t
2015-11-03 10:26:01 +01:00
Martin Gräßlin
6b95705f24 [libinput] Don't change default log level
With this change libinput is less noisy and only prints errors to stderr.

In addition one could install a dedicated log handler and forward to
qCDebug and friends.
2015-08-21 14:38:57 +02:00
Martin Gräßlin
fe28ca1d8a [libinput] Add dedicated logging category for libinput 2015-07-31 12:43:35 +02:00
Martin Gräßlin
efa0500313 [libinput] Bind libinput support to VirtualTerminal
This change is motivated by the fact that we need to suspend libinput
before switching the virtual terminal. Also we don't want to take over
libinput if we do not have a VirtualTerminal created - in windowed mode
we don't want libinput to be started. So binding it to the backends which
create the VirtualTerminal makes sense.

The KWin::Application gains a new signal virtualTerminalCreated which is
emitted from VirtualTerminal once it's properly setup. This is used by
Input to create Libinput integration instead of binding it to logind.

Furthermore Libinput gets suspended when the VirtualTerminal reports that
it is no longer active. For re-activation we still just use logind's
session active property.
2015-04-24 12:03:19 +02:00
Martin Gräßlin
e6b076df9c Move Udev into an own header and implementation
For a DRM backend we also need Udev, so don't bundle with libinput.
2015-04-24 12:03:19 +02:00
Martin Gräßlin
61579506e3 [input] Only update seat state if session is active
When our session gets inactive libinput loses all devices, thus our
Seat would not have neither keyboard, pointer nor touch. To not confuse
all connected clients we block updates while libinput is suspended. After
resume we check whether something actually changed and emit the
corresponding signals to ensure everything is up to date.
2015-04-01 11:05:45 +02:00
Martin Gräßlin
f7bed6a003 [libinput] Pass device capabilities to Wayland::Server::SeatInterface
We handle device added/remove to monitor whether we have keyboard,
pointer and touch devices and emit signals. Those are used to update
the SeatInferface from InputRedirection.
2015-03-26 16:19:26 +01:00
Martin Gräßlin
93b3626a37 [libinput] Try to dispatch events directly after setup
Without we might end in a race as kwin_wayland might start the Xwayland
server before we have a populated seat interface.
2015-03-26 16:17:51 +01:00
Martin Gräßlin
60783b8228 Touch support in libinput 2015-03-25 16:40:17 +01:00
Martin Gräßlin
e886bd7c78 Adjust to newer libinput and require at least 0.10
There was API changes regarding axis event handling.
CCBUG: 342893
2015-03-20 12:42:57 +01:00
Martin Gräßlin
11fd9f69c1 Fix build with clang and gcc 5.0
BUG: 343529
FIXED-IN: 5.2.1
2015-02-03 14:01:53 +01:00
Martin Gräßlin
6a032e78b7 Suspend/Resume libinput when logind session Active changes
LogindIntegration starts monitoring the Active property on the session
and emits a signal when the state changes. The LibInput::Connection
connects to this signal during the setup and uses it to suspend/resume
the libinput context.
2014-10-20 14:51:24 +02:00
Martin Gräßlin
a918591fef Use Logind to open/close devices needed by libinput
With libinput we have the problem that we need to have privileges to
open the device files. In order to not need wrappers or suid bits, we
use logind. This means that kwin_wayland has to be the session controler.

A LogindIntegration is added to connect to logind and wrap the dbus
calls. This is based on the logind integration done for ksld in
ksmserver. The LogindIntegration is started by Workspace and the
InputRedirection tries to become the session controller and starts the
libinput integration only after this succeeded.
2014-10-20 14:51:24 +02:00
Martin Gräßlin
c4bb3d11fc Initial support for libinput
Libinput is an optional dependency for getting low level input events.
As opening the input devices requires root privs this is rather
pointless in the current state. But there is a small added test app which
can be executed with root privs to demonstrate the functionality. To
properly get input events we need a wrapper like it's used in weston.

So far the following is setup:
* opening devices found by udev
* forwarding keyboard events to InputRedirection
* forwarding pointer button events to InputRedirection
* forwarding pointer axis events to InputRedirection
* signals emitted for pointer motion events

Pointer motion events need some further work as they are provided
as delta events. We need to track that and map them properly.

Also missing are touch events due to me not having a touch screen.
It should be fairly simple to setup the touch events, though.

Also hotplugging of devices is not yet implemented.
2014-10-20 14:51:24 +02:00