summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2023-03-29 12:40:56 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2023-03-30 05:53:23 +0000
commitc26c05b255d51e344e07704aaae47c4150e9537f (patch)
treedff446d3373f359ff6d02dac9318d355f955b6c6
parent7e1ab13f89ca28f92b60943c2c7c3c822c43cf27 (diff)
downloadlibinput-c26c05b255d51e344e07704aaae47c4150e9537f.tar.gz
tablet: split out arbitration/rotation handling assignment
No functional changes Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/evdev-tablet.c58
1 files changed, 36 insertions, 22 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 9367d860..4bc12632 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -2145,10 +2145,40 @@ tablet_destroy(struct evdev_dispatch *dispatch)
}
static void
+tablet_setup_touch_arbitration(struct evdev_device *device,
+ struct evdev_device *new_device)
+{
+ struct tablet_dispatch *tablet = tablet_dispatch(device->dispatch);
+
+ evdev_log_debug(device,
+ "touch-arbitration: activated for %s<->%s\n",
+ device->devname,
+ new_device->devname);
+ tablet->touch_device = new_device;
+}
+
+static void
+tablet_setup_rotation(struct evdev_device *device,
+ struct evdev_device *new_device)
+{
+ struct tablet_dispatch *tablet = tablet_dispatch(device->dispatch);
+
+ evdev_log_debug(device,
+ "tablet-rotation: %s will rotate %s\n",
+ device->devname,
+ new_device->devname);
+ tablet->rotation.touch_device = new_device;
+
+ if (libinput_device_config_left_handed_get(&new_device->base)) {
+ tablet->rotation.touch_device_left_handed_state = true;
+ tablet_change_rotation(device, DO_NOTIFY);
+ }
+}
+
+static void
tablet_device_added(struct evdev_device *device,
struct evdev_device *added_device)
{
- struct tablet_dispatch *tablet = tablet_dispatch(device->dispatch);
bool is_touchscreen, is_ext_touchpad;
if (libinput_device_get_device_group(&device->base) !=
@@ -2160,28 +2190,12 @@ tablet_device_added(struct evdev_device *device,
is_ext_touchpad = evdev_device_has_capability(added_device,
LIBINPUT_DEVICE_CAP_POINTER) &&
(added_device->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD);
- /* Touch screens or external touchpads only */
- if (is_touchscreen || is_ext_touchpad) {
- evdev_log_debug(device,
- "touch-arbitration: activated for %s<->%s\n",
- device->devname,
- added_device->devname);
- tablet->touch_device = added_device;
- }
-
- if (is_ext_touchpad) {
- evdev_log_debug(device,
- "tablet-rotation: %s will rotate %s\n",
- device->devname,
- added_device->devname);
- tablet->rotation.touch_device = added_device;
-
- if (libinput_device_config_left_handed_get(&added_device->base)) {
- tablet->rotation.touch_device_left_handed_state = true;
- tablet_change_rotation(device, DO_NOTIFY);
- }
- }
+ if (is_touchscreen || is_ext_touchpad)
+ tablet_setup_touch_arbitration(device, added_device);
+
+ if (is_ext_touchpad)
+ tablet_setup_rotation(device, added_device);
}
static void