Commit graph

80 commits

Author SHA1 Message Date
Xaver Hugl
a38a44cb2a libinput: use std::unique_ptr for events 2022-06-21 17:50:49 +00:00
Vlad Zahorodnii
066ac3200a backends/libinput: Rework Device getter
libinput_device_get_user_data() can be used to get the associated Device
object with libinput_device. That way, we won't need to maintain a
private list of all input devices.
2022-04-29 12:47:34 +00:00
Vlad Zahorodnii
7096e3ead8 Run clang-format
The .clang-format file is based on the one in ECM except the following
style options:

 - AlwaysBreakBeforeMultilineStrings
 - BinPackArguments
 - BinPackParameters
 - ColumnLimit
 - BreakBeforeBraces
 - KeepEmptyLinesAtTheStartOfBlocks
2022-03-25 13:25:15 +02:00
Volker Krause
eee16b01a4 Port away from deprecated QWheelEvent position methods
Those are gone in Qt6 (unlike similarly named methods for other
event types).
2022-03-13 12:23:22 +00:00
Matt Scheirer
6287ab16f4 [libinput] Add support for display mapping 2021-12-13 18:53:23 +00:00
Matt Scheirer
a719ceab4a [libinput] Persist device calibration & orientation 2021-12-13 18:53:23 +00:00
Vlad Zahorodnii
94de28bfbe Move input backends in their own directory 2021-11-01 16:27:16 +02:00
Vlad Zahorodnii
ef72bae42f Introduce base InputDevice class
The main motivation behind this change is to prepare input abstractions
for virtual input devices so the wl_seat can properly advertise caps or
the cursor getting properly mapped/unmapped when a fake pointer is
added/removed on a system without a hardware mouse connected.

With this, there are three abstractions - InputDevice, InputBackend, and
InputRedirection.

An InputDevice represents an input device such as a mouse, a keyboard, a
tablet, etc. The InputBackend class notifies the InputRedirection about
(dis-)connected devices. The InputRedirection manages the input devices.

Such design allows to unify the event flow for real and virtual input
devices.

There can be several input backends active. For example, the libinput
backend and an input backend that provides virtual input devices, e.g.
libeis or org_kde_kwin_fake_input.
2021-11-01 16:27:16 +02:00
Vlad Zahorodnii
31b9f34d9b libinput: Port to AbstractOutput
CCBUG: 443088
2021-09-29 12:03:39 +03:00
Aleix Pol
b7389c6f1a libinput tests: Fix new-delete-type-mismatch error when using ASAN 2021-05-13 06:53:13 +00:00
Vlad Zahorodnii
f6217be2ad Drop testLibinputContext 2021-03-23 08:01:19 +00:00
Vlad Zahorodnii
2df429ce5e autotests: Drop TestLibinputTouchEvent::testNoAssignedSlot()
We've switched to libinput_event_get_seat_slot(), which returns a
non-negative number to indicate the slot.
2021-02-16 12:52:08 +02:00
Vlad Zahorodnii
93e0265e4e Move source code to src/ directory
Once in a while, we receive complaints from other fellow KDE developers
about the file organization of kwin. This change addresses some of those
complaints by moving all of source code in a separate directory, src/,
thus making the project structure more traditional. Things such as tests
are kept in their own toplevel directories.

This change may wreak havoc on merge requests that add new files to kwin,
but if a patch modifies an already existing file, git should be smart
enough to figure out that the file has been relocated.

We may potentially split the src/ directory further to make navigating
the source code easier, but hopefully this is good enough already.
2021-02-10 15:31:43 +00:00
Vlad Zahorodnii
68c675d00d Make source code more relocatable
Occasionally, I see complaints about the file organization of kwin,
which is fair enough.

This change makes the source code more relocatable by removing relative
paths from includes.

CMAKE_CURRENT_SOURCE_DIR was added to the interface include directories
of kwin library. This means that as long as you link against kwin target,
the real location of the source code of the library doesn't matter.

With autotests, things are not as convenient as with kwin target. Some
tests use cpp files from kwin core. If we move all source code in a src/
directory, they will need to be adjusted, but mostly only in build
scripts.
2021-02-10 15:31:42 +00:00
Nicolas Fella
99947c8bd8 Use versionless Qt cmake target
This makes it easier to build against both Qt5 and Qt6

GIT_SILENT
2021-01-30 17:18:21 +01:00
Vlad Zahorodnii
44176c6a8c Lower default severity of logging categories
Warning messages are not the kind of messages that should be ignored,
they indicate that something is off or wrong.

Also, this makes triaging bugs easier as we no longer have to ask people
to run kwin with the QT_LOGGING_RULES environment variable set.
2021-01-25 14:03:14 +02:00
Xaver Hugl
a4fb852a94 Replace per-device touch slot with global slot
With multiple touch devices the slots could interfere
2021-01-18 17:00:47 +00:00
Aleix Pol
199860a007 Fix tests build, provide mocks for libinput functions 2021-01-07 02:56:19 +01:00
Vlad Zahorodnii
26b249061e cmake: Remove FindUDev.cmake
It's in extra-cmake-modules now.
2021-01-05 23:08:47 +02:00
Laurent Montel
2ac8611523 If include is define in .h remove it if it's defined in .cpp too (scripted) 2020-10-23 21:37:16 +02:00
Vlad Zahorodnii
4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Méven Car
564c739371 Wayland: Allow to set a scroll Factor for input devices
Summary:
Mouse and touchpad wheel events are concerned.

CCBUG: 403843

KCM patch: D28331

Test Plan: build, ctest, manual set of scrollfactor value via qdbusviewer

Reviewers: #kwin, davidedmundson, zzag, bport, ervin, apol

Reviewed By: #kwin, davidedmundson, ervin, apol

Subscribers: apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28310
2020-04-07 19:08:49 +02:00
Aleix Pol
da2d896257 Fix for older cmake versions
Summary: Recent changes prevented it to build on KDE Neon.

Test Plan: Built it on Neon

Reviewers: #kwin, bshah, davidedmundson

Reviewed By: #kwin, bshah, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28511
2020-04-02 13:20:03 +02:00
Aleix Pol
dbac4bce7e Reduce the amount of objects that are compiled several times
Summary:
We build some objects several times which makes it uncomfortable to develop KWin
since every time we modify something a lot of things get rebuilt. This should
help a bit although it doesn't solve all the problems.

Test Plan: Builds, tests pass

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: davidedmundson, zzag, anthonyfieroni, iasensio, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28445
2020-04-02 00:41:55 +02:00
Aleix Pol
e0052cedcb Implement the tablet wayland protocol in kwin
Summary:
Uses the tablet classes introduced in kwayland.
Depends on D26858

Test Plan:
Scratched my tablet with a magic stick and it did things depending on the pressure.
https://youtu.be/GGx0TlNJlzs

Reviewers: #kwin, #plasma, zzag, davidedmundson

Reviewed By: #kwin, #plasma, zzag, davidedmundson

Subscribers: davidedmundson, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26859
2020-03-20 03:05:41 +01:00
Aleix Pol
f5a73b87e3 Initial support for tablets on Wayland
Summary:
This includes support for them on libinput and turns it into fake
pointer actions.
This doesn't implement zwp_tablet, this will have to happen in an
iteration later.

Test Plan:
Been playing around with it, see video.
https://www.youtube.com/watch?v=GF1WbO8FVvU

Reviewers: #plasma, #kwin, romangg

Reviewed By: #plasma, #kwin, romangg

Subscribers: zzag, davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25663
2019-12-10 21:56:31 +01:00
Vlad Zahorodnii
09b47b5250 Undo some recent cmake changes
Unfortunately linking can be very fragile so let's not break things.
2019-09-18 13:50:52 +03:00
Vlad Zahorodnii
dcf91d4321 Cleanup style in CMakeLists.txt files
We have lots of inconsistency at the moment in CMakeLists.txt files. Most
of it is due to kwin being a very old project. This change hopefully fixes
all of it.
2019-09-17 16:03:05 +03:00
Vlad Zagorodniy
7f593a67ad Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.

BUG: 404152
FIXED-IN: 5.17.0

Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
  wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
  in all three cases wayland debug looked the same (except diagonal scroll
  motions).

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19000
2019-05-17 12:06:10 +03:00
Atul Bisht
c7154fc5b9 [libinput] Add support for clickfinger and button areas click method
Summary:
Added support for libinput clickfinger , areas method for touchpad KCM
Also added mock methods.

Included commits in branch libinputClickMethod:

         Added libinput mock methods
         Added : 1. setScrollMethod 2. added key value pair in QMap 3. added methods for Q_Props
         Added Q_Props for click method, signal
         Added variables and initialize in constructor

Reviewers: #kwin, graesslin, davidedmundson, zzag

Reviewed By: #kwin, graesslin, zzag

Subscribers: zzag, graesslin, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17577
2018-12-22 17:29:49 +01:00
Martin Flöser
ba0cf19286 Fix dbus export of property Device::supportedButtons
Summary:
When launching the touchpad kcm we see the following warning:
    Error on d-bus read of "supportedButtons"

And the Gui shows "Error while loading values. See logs for more
information. Please restart this configuration module".

By extending the unit test for reading back the properties through DBus
I noticed that it's not trivially possible to export QFlags to DBus. As
the QFlags can be implicitly casted to int, the property is changed to
an int value.

Test Plan: Test case adjusted, did not pass prior to change, passes now.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17472
2018-12-13 19:36:28 +01:00
David Edmundson
a3cff85e7a Remove Qt module declarations in includes
Summary:
Test Plan: Compiles

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13359
2018-06-05 18:07:23 +01:00
Martin Flöser
4cc1d7a245 Require libinput version 1.9
Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9930
2018-01-21 11:15:41 +01:00
Martin Flöser
d2a9232ad3 Pass SwitchEvent from LibInput through KWin and add to DebugConsole
Summary:
This change introduces a new SwitchEvent and passes it through the
InputEventSpy and InputEventFilter. The DebugConsoleFilter implements it
so that the events can be monitored in the debug console.

Test Plan: Untested as my only device with such switches has too old libinput

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9521
2018-01-09 19:32:58 +01:00
Martin Flöser
ac2f41c86d [libinput] Add support for switch devices and events
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

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9516
2018-01-04 18:05:44 +01:00
Martin Flöser
68698b4201 [libinput] Find screen for touch screen devices and calibrate accordingly
Summary:
This change finds the screen for a touch screen device based on:
 * number available screens
 * output name defined on the touch screen device
 * internal screen
 * and physical size

The id of the screen is stored in the Device allowing to adjust the
touch points accordingly. This means instead of transferring to the
combined display size the touch points are transferred into the output
space and the position of the output is added. Thus in a multi screen
system the touch points are properly mapped to the output.

Furthermore the screen orientation is passed to the Device and a
calibration matrix is set accordingly. Thus a transformed screen has the
touch screen transformed accordingly.

Please note that this only affects libinput on Wayland and not on X11!
The x11 standalone platform needs to gain similar code.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8748
2017-12-23 10:18:55 +01:00
Martin Flöser
1c61e61119 [autotests] Support new way to run the tests without need to install
Summary:
KWin was quite good in ensuring that you don't need to install by
passing paths to the tests. The new way is much nicer, so code is
adjusted for the new way. Also if we require a newer ECM in future we
need to support the new way.

No guarantee that the tests don't pick something up from the system env,
that needs more testing.

References: https://community.kde.org/Guidelines_and_HOWTOs/Making_apps_run_uninstalled

Test Plan: The tests which loaded helpers pass

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7543
2017-11-21 20:34:52 +01:00
Jesse Pullinen
0eba3f3c18 Fix TouchEvent::id() returning -1, fixes a crash
Summary:
Libinput returns -1 when calling libinput_event_touch_get_slot on an event
from a single-touch touchscreen. The returned value is used in
DecorationEventFilter to determine the touch which is acting on it. The value -1
is used to signify that the decoration is not being acted on. Thus when
releasing the touch, it checks whether it was being dragged, and as it thinks
it isn't, it doesn't handle it and the decoration is still being dragged.
Clicking on the decoration then crashes kwin.

Test Plan: Move a window by dragging the decoration with a single-touch touchscreen.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D7854
2017-09-19 07:11:40 +03:00
Roman Gilg
fd07b1dc98 [libinput] Change unset of scroll method and acceleration profile
Go for a more intuitive unset behaviour of scroll method and acceleration
profile properties.

Summary:
Unsetting a scroll method should only work, if the scroll method is currently
active. For example when scroll-two-finger is active (i.e. scroll-edge,
scroll-on-button-down is not active):
* unsetting scroll-two-finger should deactivate it and activate no-scroll
* but unsetting for example scroll-edge should _not_ deactivate scroll-two-
  finger and _not_ activate no-scroll

Reworked setting scroll method auto test in order to test it.

Regarding acceleration profiles: Unsetting one, should always switch to the
other possible one as long as both are supported. In this case
LIBINPUT_CONFIG_ACCEL_PROFILE_NONE is not a valid option in contrast to the
definition of the scroll method enums.

Reviewers: #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3590
2016-12-06 13:45:54 +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
Roman Gilg
87150816c7 [libinput] Rework device config writing and save enum of ScrollMode as integer
This is a larger patch rewriting some parts of the config saving functionality
in device.cpp in order to:

1. Make it possible to save ScrollMode as integer instead of using three booleans
2. Simplify the addition of new keys or types in the future

Changes in detail:
a) Adds new ConfigKey ScrollMethod and removed now unnecessary keys per method
b) Adds constructors to the ConfigData struct. This allows to create ConfigData
   entries for s_configData without the need of stating empty brackets and the
   useage of default values.
c) Use plain member function pointers instead of std::function, in order to
   compactify code and have better compile output in case something goes wrong.
c) Cleans up ScrollMethod functions and adds interface methods for transforming
   the saved integer into type enum libinput_config_scroll_method.
d) Adjusts auto test for loading the ScrollMethod value from the config file.

Reviewers: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3460
2016-11-22 19:18:15 +01:00
Roman Gilg
ad0647688a [libinput] Query defaultLeftHanded, save leftHanded, fix ScrollMode config
Some small improvements / fixes to the libinput backend:
- Query libinput_device_config_left_handed_get_default
- Write leftHanded property to config file
- When saving the touchpad scroll mode, write false to all other ones.
  Otherwise it will always enable the last read entry after reboot.
- Use macro for setLeftHanded(bool) and setNaturalScroll(bool)

Reviewers: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3430
2016-11-22 14:49:01 +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
f17d06ee7d Merge branch 'Plasma/5.8' 2016-11-04 10:03:10 +01:00
Martin Gräßlin
fb4b0c40ef [autotests/libinput] Extend the Device test
Added tests for new functionality:
* scroll enabled by default properties
* scroll supported properties
* scroll on button down
2016-11-04 08:58:09 +01:00
Martin Gräßlin
f1d17c1a56 [autotests/libinput] Extend device test for scrol methods
Covers the variants for scroll method.
2016-11-03 17:51:32 +01:00
Martin Gräßlin
e9dfdbe6a8 [autotests/libinput] Extend Device test case
Tests the new functionality for:
* natural scroll
* middle emulation
2016-11-03 17:22:31 +01:00
David Strobach
e4283543f6 [libinput] Add scroll method configuration support
Wraps libinput
libinput_device_config_scroll_get_methods
libinput_device_config_scroll_get_default_method
libinput_device_config_scroll_set_method
libinput_device_config_scroll_get_method
libinput_device_config_scroll_set_button
libinput_device_config_scroll_get_button
libinput_device_config_scroll_get_default_button

Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3194
BUG: 371803
FIXED-IN: 5.8.4
2016-11-03 14:03:17 +01:00
David Strobach
b19341777a [libinput] Add natural scrolling support
Wraps libinput
libinput_device_config_has_natural_scroll
libinput_device_config_set_natural_scroll_enabled
libinput_device_config_get_natural_scroll_enabled
libinput_device_config_scroll_get_default_natural_scroll_enabled

Differential Revision: https://phabricator.kde.org/D3193
BUG: 371791
FIXED-IN: 5.8.4
2016-11-03 14:02:27 +01:00