Commit Graph

37 Commits (f8be3f746ba9e8a868c74414a40c2e41b14b61d1)

Author SHA1 Message Date
Martin Flöser 91d78daac4 Ensure libinput connection thread uses real time scheduling
Summary:
The SCHED_RESET_ON_FORK results in threads (not only processes) to have
the scheduling policy reset to default. This means that the libinput
thread is not real time, but this was actually intended.

To solve this problem KWin does start without the RESET_ON_FORK flag
during startup. Once createInput has been called the scheduling is
adjusted again and RESET_ON_FORK is added again. This results in the
libinput thread and all threads Qt starts in between (e.g. dbus) to gain
real time policy. But it is still not leaked to other processes or to
threads in KWin which don't need it.

Other options considered: just don't use RESET_ON_FORK and instead
manually reset on fork. This would mean all threads in KWin gain real
time, but we don't need this. It's only interesting for the main
(rendering, Wayland thread) and the input thread. Also the danger to
leak into another process is too high.

Keeping the capability till the libinput thread is created and adjust
the thread itself. This option was discarded as I don't want KWin to
have any capabilities when the QApplication is started.

Test Plan: ps -eL -o class,rtprio,cmd,comm  | grep kwin_wayland

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8065
2017-10-31 12:44:51 +01:00
David Edmundson fe231be5e2 Keep all touchpad QActions in the main thread
Summary:
Making QActions with the Connection as a parent is dangerous as it gets
moved to a new thread, moving all child objects to that thread.

KGlobalAccel and QAction aren't thread safe and we shouldn't be using it
in two threads. This was notably seen when runnng invokeShortcut over
DBus which then invokes it on the main thread. Something my laptop was
doing when I closed the lid.

This patch simply moves the code to the Input class, where we set up the
libinput connection.

Test Plan:
Closed lid, kwin_wayland was still there when I resumed
Set manual shortcut for toggling touchpad, that still worked

Reviewers: #plasma

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5733
2017-05-07 16:08:00 +02:00
Roman Gilg ffa60dfef1 [libinput] Connection helper class for DBus connection
Create auxiliary class for Connection class in order to connect to DBus
from main thread.

Reviewers: #kwin, davidedmundson, graesslin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4081
2017-01-12 08:16:04 +01:00
Roman Gilg b868df2715 [libinput] Fix threaded Connection DBus object registering
On registering object use the object in the right thread.
Otherwise there are multiple errors.

BUG: 374554

Differential Revision: https://phabricator.kde.org/D4027
2017-01-09 09:07:05 +01:00
Aleix Pol 1f5356e609 Fix build (with clang at least)
Summary:
No need to capture the variable as it's static. Also apparently wrong.
Used to get the following error message:
/home/apol/devel/frameworks/kwin/libinput/connection.cpp:103:56: error: 's_self' cannot be captured because it does not have automatic storage duration
    connect(s_self, &Connection::deviceAdded, s_self, [s_self](Device* device) {
                                                       ^
/home/apol/devel/frameworks/kwin/libinput/connection.cpp:45:25: note: 's_self' declared here
Connection *Connection::s_self = nullptr;
                        ^
/home/apol/devel/frameworks/kwin/libinput/connection.cpp:106:58: error: 's_self' cannot be captured because it does not have automatic storage duration
    connect(s_self, &Connection::deviceRemoved, s_self, [s_self](Device* device) {
                                                         ^
/home/apol/devel/frameworks/kwin/libinput/connection.cpp:45:25: note: 's_self' declared here
Connection *Connection::s_self = nullptr;
                        ^

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3703
2016-12-16 13:40:44 +01:00
Roman Gilg 7f16d83e04 [libinput] Add more support for pointer devices, in particular touchpads
This patch is made in preparation for the Touchpad KCM for Wayland.

Summary:
* KWin has a Libinput version requirement bump to 1.5
* new isTouchpad property to distinguish touchpads from mice
* new lmrTapButtonMap property
* new disableWhileTyping property
* new pointerAccelerationProfile property
* new defaultPointerAcceleration property
* save to config mechanism added for new propertys and pointerAcceleration
* new D-Bus interface org.kde.KWin.InputDeviceManager and method devicesSysNames
* removed unnecessary additional D-Bus service name org.kde.KWin.InputDevice
* changing acceleration in the Mouse KCM doesn't influence touchpads anymore

Reviewers: #kwin, #plasma, davidedmundson

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3479
2016-12-02 14:58:56 +01:00
Martin Gräßlin de89176cd2 [libinput] Load/store device configuration
Summary:
Device gets a KConfigGroup injected and supports loading device-specific
settings. This is invoked from Libinput::Connection when adding a new
Device.

Whenever a Device option is changed successfully through the DBus
interface it gets synced into the KConfigGroup, thus on next loading of
the Device it gets restored.

The config group follows a pattern of:
[libinput][vendor][product][name]

Thus every device has a specific and persistent configuration.

Test Plan: So far only tested through autotests

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3264
2016-11-07 13:45:48 +01:00
Martin Gräßlin 9eede1c66b Merge branch 'Plasma/5.8' 2016-10-17 08:59:35 +02:00
Martin Gräßlin 4c7752c965 Support LEDs in Xkb and libinput
Summary:
The Xkb implementation starts to track the state of the LEDs in the
keymap and emits a signal whenever the LEDs change. This signal is
connected to a method in LibInput::Connection which updates the led
state on all devices and uses it to init the state of the led when a new
device gets connected.

BUG: 369214
FIXED-IN: 5.8.2

Test Plan: Connected a keyboard with LEDs and enabled NumLock and ScrollLock.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2943
2016-10-17 08:01:49 +02:00
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 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 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 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 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 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 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 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 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