]> git.mdlowis.com Git - proto/labwc.git/commitdiff
seat: add seat_update_capabilities helper
authorJoshua Ashton <joshua@froggi.es>
Wed, 17 Aug 2022 18:12:24 +0000 (18:12 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 27 Sep 2022 16:31:00 +0000 (17:31 +0100)
src/seat.c

index b775cf4cc270d5f021e1a9b61f921a579d33ed1e..481adf3a8489f0c8a00818524b2814f9c5fa6a2c 100644 (file)
@@ -198,6 +198,30 @@ new_touch(struct seat *seat, struct input *input)
        }
 }
 
+static void
+seat_update_capabilities(struct seat *seat)
+{
+       struct input *input = NULL;
+       uint32_t caps = 0;
+       
+       wl_list_for_each(input, &seat->inputs, link) {
+               switch (input->wlr_input_device->type) {
+               case WLR_INPUT_DEVICE_KEYBOARD:
+                       caps |= WL_SEAT_CAPABILITY_KEYBOARD;
+                       break;
+               case WLR_INPUT_DEVICE_POINTER:
+                       caps |= WL_SEAT_CAPABILITY_POINTER;
+                       break;
+               case WLR_INPUT_DEVICE_TOUCH:
+                       caps |= WL_SEAT_CAPABILITY_TOUCH;
+                       break;
+               default:
+                       break;
+               }
+       }
+       wlr_seat_set_capabilities(seat->seat, caps);
+}
+
 static void
 new_input_notify(struct wl_listener *listener, void *data)
 {
@@ -226,23 +250,7 @@ new_input_notify(struct wl_listener *listener, void *data)
        wl_signal_add(&device->events.destroy, &input->destroy);
        wl_list_insert(&seat->inputs, &input->link);
 
-       uint32_t caps = 0;
-       wl_list_for_each(input, &seat->inputs, link) {
-               switch (input->wlr_input_device->type) {
-               case WLR_INPUT_DEVICE_KEYBOARD:
-                       caps |= WL_SEAT_CAPABILITY_KEYBOARD;
-                       break;
-               case WLR_INPUT_DEVICE_POINTER:
-                       caps |= WL_SEAT_CAPABILITY_POINTER;
-                       break;
-               case WLR_INPUT_DEVICE_TOUCH:
-                       caps |= WL_SEAT_CAPABILITY_TOUCH;
-                       break;
-               default:
-                       break;
-               }
-       }
-       wlr_seat_set_capabilities(seat->seat, caps);
+       seat_update_capabilities(seat);
 }
 
 static void