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 */
static void
libinput_category_init(struct libinput_category *l)
{
+ l->type = DEFAULT_DEVICE;
l->name = NULL;
l->pointer_speed = -2;
l->natural_scroll = -1;
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;
+}
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);
} 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");