tablet: split out arbitration/rotation handling assignment
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 29 Mar 2023 02:40:56 +0000 (12:40 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 30 Mar 2023 05:53:23 +0000 (05:53 +0000)
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-tablet.c

index 9367d8605786ec340061887ff141e03893fc58f9..4bc126329aed6b8cb482a199437b5efb6f8a6b92 100644 (file)
@@ -2144,11 +2144,41 @@ tablet_destroy(struct evdev_dispatch *dispatch)
        free(tablet);
 }
 
+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