]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config: use wl_list_append() for libinput categories
authorJohan Malm <jgm323@gmail.com>
Mon, 1 Jan 2024 17:18:28 +0000 (17:18 +0000)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 1 Jan 2024 22:04:21 +0000 (22:04 +0000)
...to make it more intuitive.

Also, do not check for existance of name when type==DEFAULT because name
will only exist when type==NONE.

src/config/libinput.c
src/seat.c

index e55e990b3e3ad8421707712b50b574f6cee4a7f4..4b61d54660a0202756ecd8d946c8e84006d86a84 100644 (file)
@@ -3,6 +3,7 @@
 #include <strings.h>
 
 #include "common/mem.h"
+#include "common/list.h"
 #include "config/libinput.h"
 #include "config/rcxml.h"
 
@@ -49,20 +50,21 @@ libinput_category_create(void)
 {
        struct libinput_category *l = znew(*l);
        libinput_category_init(l);
-       wl_list_insert(&rc.libinput_categories, &l->link);
+       wl_list_append(&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.
- */
+/* 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) {
+       /*
+        * Iterate in reverse to get the last one added in case multiple
+        * 'default' profiles were created.
+        */
+       wl_list_for_each_reverse(l, &rc.libinput_categories, link) {
+               if (l->type == DEFAULT_DEVICE) {
                        return l;
                }
        }
index f450999b9af0ce2b28cef3b1d856a3d857eec2ea..8636314c98ab2b9866999877c94c53803a504557 100644 (file)
@@ -79,7 +79,7 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
                device_type_from_wlr_device(wlr_input_device);
 
        struct libinput_category *device_category, *dc = NULL;
-       wl_list_for_each(device_category, &rc.libinput_categories, link) {
+       wl_list_for_each_reverse(device_category, &rc.libinput_categories, link) {
                if (device_category->name) {
                        if (!strcasecmp(wlr_input_device->name,
                                        device_category->name)) {