]> git.mdlowis.com Git - proto/labwc.git/commitdiff
rcxml: Make sure a default libinput category always exists
authorJohn Lindgren <john@jlindgren.net>
Thu, 22 Dec 2022 21:44:08 +0000 (16:44 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 22 Dec 2022 22:18:27 +0000 (22:18 +0000)
Previously, if rc.xml defined only non-default libinput categories,
no default category was created. This meant that configure_libinput()
might totally skip configuring some devices even with default
settings, like tap-to-click.

Fix this by making sure that a default category is always created.

include/config/libinput.h
src/config/libinput.c
src/config/rcxml.c
src/seat.c

index d7831ed4275b01f11d850ccea954b61eb4876bd2..97409b34e9cc506b3fb74e00b3f178c703327073 100644 (file)
@@ -28,5 +28,6 @@ struct libinput_category {
 
 enum device_type get_device_type(const char *s);
 struct libinput_category *libinput_category_create(void);
+struct libinput_category *libinput_category_get_default(void);
 
 #endif /* __LABWC_LIBINPUT_H */
index 685c6720cb1917c7111b943bcb34117f0216a7fd..ee3ca1e6bcfcf7e90fbb868e7a1fd46c6e0a6e72 100644 (file)
@@ -9,6 +9,7 @@
 static void
 libinput_category_init(struct libinput_category *l)
 {
+       l->type = DEFAULT_DEVICE;
        l->name = NULL;
        l->pointer_speed = -2;
        l->natural_scroll = -1;
@@ -43,3 +44,19 @@ libinput_category_create(void)
        wl_list_insert(&rc.libinput_categories, &l->link);
        return l;
 }
+
+/*
+ * The default category is the first one with type == DEFAULT_DEVICE and
+ * no name. After rcxml_read(), a default category always exists.
+ */
+struct libinput_category *
+libinput_category_get_default(void)
+{
+       struct libinput_category *l;
+       wl_list_for_each(l, &rc.libinput_categories, link) {
+               if (l->type == DEFAULT_DEVICE && !l->name) {
+                       return l;
+               }
+       }
+       return NULL;
+}
index 0821b46dd3497ab8f177aec6723e72e2d18f44ac..7627a2a9edcb72cdb12bf3d2383cc93c54c04913 100644 (file)
@@ -680,10 +680,10 @@ post_processing(void)
        if (!rc.font_osd.name) {
                rc.font_osd.name = xstrdup("sans");
        }
-       if (!wl_list_length(&rc.libinput_categories)) {
+       if (!libinput_category_get_default()) {
                /* So we still allow tap to click by default */
                struct libinput_category *l = libinput_category_create();
-               l->type = DEFAULT_DEVICE;
+               assert(l && libinput_category_get_default() == l);
        }
        if (!wl_list_length(&rc.workspace_config.workspaces)) {
                struct workspace *workspace = znew(*workspace);
index 6a6e0e5897544ec1a2254320dab3c93c1e895f8e..9380fb11cb0c0627d73f28b81a5444a70b3478f0 100644 (file)
@@ -75,14 +75,16 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
                } else if (device_category->type == current_type) {
                        dc = device_category;
                } else if (device_category->type == DEFAULT_DEVICE && !dc) {
+                       /* Match default category as last-resort */
                        dc = device_category;
                }
        }
 
-       if (!dc) {
-               wlr_log(WLR_INFO, "Skipping libinput configuration for device");
-               return;
-       }
+       /*
+        * The above logic should have always matched SOME category
+        * (the default category if none other took precedence)
+        */
+       assert(dc);
 
        if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) {
                wlr_log(WLR_INFO, "tap unavailable");