mirror of
https://codeberg.org/dwl/dwl-patches.git
synced 2025-09-07 19:54:50 +00:00
Update perinputconfig patch
This commit is contained in:
parent
f8598a91b4
commit
12a6e0d90e
@ -5,8 +5,8 @@ Tip to find the names: Grep for `device_name` and add a line after it to print t
|
||||
|
||||
### Download
|
||||
- [git branch](https://codeberg.org/nullsystem/dwl/src/branch/main_perinputconfig)
|
||||
- [2024-03-31](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig.patch)
|
||||
- [2024-06-08](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig.patch)
|
||||
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/perinputconfig/perinputconfig-v0.5.patch)
|
||||
|
||||
### Authors
|
||||
- [nullsystem](https://codeberg.org/nullsystem)
|
||||
- [nullsystem](https://codeberg.org/nullsystem)
|
||||
|
@ -1,21 +1,40 @@
|
||||
From a73544fecf1f4076957b24bfa01af03d250bc28d Mon Sep 17 00:00:00 2001
|
||||
From c268707811fb5d8244115f23a0430f024e4e11a9 Mon Sep 17 00:00:00 2001
|
||||
From: nullsystem <nullsystem.aongp@slmail.me>
|
||||
Date: Sun, 31 Mar 2024 13:53:38 +0100
|
||||
Subject: [PATCH 1/2] perinputconfig - set configuration per input
|
||||
Date: Sat, 8 Jun 2024 11:30:34 +0100
|
||||
Subject: [PATCH] perinputconfig - 2024-06-08 Update
|
||||
|
||||
- Array replaced singular variables for configuration
|
||||
- Only applies to enable-state, acceleration profile, and speed
|
||||
- Like EX: Rules, requires NULL/default set at the end
|
||||
* Array replaced singular variables for configuration
|
||||
* Only applies to enable-state, acceleration profile, and speed
|
||||
* Like EX: Rules, requires NULL/default set at the end
|
||||
* Keyboards can now also set by name
|
||||
---
|
||||
config.def.h | 28 ++++++++++++++++++----------
|
||||
dwl.c | 20 +++++++++++++++++---
|
||||
2 files changed, 35 insertions(+), 13 deletions(-)
|
||||
config.def.h | 36 +++++++++++++---------
|
||||
dwl.c | 87 +++++++++++++++++++++++++++++++++++++++++++---------
|
||||
2 files changed, 95 insertions(+), 28 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 9009517..84c0f6b 100644
|
||||
index a784eb4..c733137 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -83,23 +83,31 @@ LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
|
||||
@@ -49,12 +49,13 @@ static const MonitorRule monrules[] = {
|
||||
};
|
||||
|
||||
/* keyboard */
|
||||
-static const struct xkb_rule_names xkb_rules = {
|
||||
- /* can specify fields: rules, model, layout, variant, options */
|
||||
+/* NOTE: Always include a fallback rule at the end (name as NULL) */
|
||||
+static const KeyboardRule kbrules[] = {
|
||||
+ /* name rules model layout variant options */
|
||||
/* example:
|
||||
- .options = "ctrl:nocaps",
|
||||
+ { "keyboard", NULL, NULL, "us,de", NULL, "ctrl:nocaps" },
|
||||
*/
|
||||
- .options = NULL,
|
||||
+ { NULL, NULL, NULL, NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
static const int repeat_rate = 25;
|
||||
@@ -84,24 +85,31 @@ LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
|
||||
static const enum libinput_config_click_method click_method = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
|
||||
|
||||
/* You can choose between:
|
||||
@ -36,15 +55,15 @@ index 9009517..84c0f6b 100644
|
||||
+accel_profile: You can choose between:
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
|
||||
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
|
||||
+
|
||||
+NOTE: Always include a fallback rule at the end (name as NULL)
|
||||
*/
|
||||
-*/
|
||||
-static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
|
||||
-static const double accel_speed = 0.0;
|
||||
|
||||
-/* You can choose between:
|
||||
-LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle
|
||||
-LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
|
||||
-*/
|
||||
+NOTE: Always include a fallback rule at the end (name as NULL)
|
||||
*/
|
||||
-static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
+static const InputRule inputrules[] = {
|
||||
+ /* name send_events_mode accel_profile accel_speed*/
|
||||
@ -58,10 +77,10 @@ index 9009517..84c0f6b 100644
|
||||
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 5867b0c..ebc0180 100644
|
||||
index 6f041a0..0673a05 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -239,6 +239,13 @@ typedef struct {
|
||||
@@ -240,6 +240,22 @@ typedef struct {
|
||||
struct wl_listener destroy;
|
||||
} SessionLock;
|
||||
|
||||
@ -71,11 +90,116 @@ index 5867b0c..ebc0180 100644
|
||||
+ enum libinput_config_accel_profile accel_profile;
|
||||
+ double accel_speed;
|
||||
+} InputRule;
|
||||
+
|
||||
+typedef struct {
|
||||
+ const char *name;
|
||||
+ const char *rules;
|
||||
+ const char *model;
|
||||
+ const char *layout;
|
||||
+ const char *variant;
|
||||
+ const char *options;
|
||||
+} KeyboardRule;
|
||||
+
|
||||
/* function declarations */
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void applyrules(Client *c);
|
||||
@@ -991,10 +998,17 @@ createnotify(struct wl_listener *listener, void *data)
|
||||
@@ -259,7 +275,7 @@ static void commitnotify(struct wl_listener *listener, void *data);
|
||||
static void createdecoration(struct wl_listener *listener, void *data);
|
||||
static void createidleinhibitor(struct wl_listener *listener, void *data);
|
||||
static void createkeyboard(struct wlr_keyboard *keyboard);
|
||||
-static KeyboardGroup *createkeyboardgroup(void);
|
||||
+static KeyboardGroup *createkeyboardgroup(struct xkb_rule_names *new_xkb_rules);
|
||||
static void createlayersurface(struct wl_listener *listener, void *data);
|
||||
static void createlocksurface(struct wl_listener *listener, void *data);
|
||||
static void createmon(struct wl_listener *listener, void *data);
|
||||
@@ -396,7 +412,7 @@ static struct wlr_session_lock_v1 *cur_lock;
|
||||
static struct wl_listener lock_listener = {.notify = locksession};
|
||||
|
||||
static struct wlr_seat *seat;
|
||||
-static KeyboardGroup *kb_group;
|
||||
+static struct wl_list kb_groups;
|
||||
static struct wlr_surface *held_grab;
|
||||
static unsigned int cursor_mode;
|
||||
static Client *grabc;
|
||||
@@ -671,6 +687,8 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
||||
void
|
||||
cleanup(void)
|
||||
{
|
||||
+ KeyboardGroup *kb_group;
|
||||
+
|
||||
#ifdef XWAYLAND
|
||||
wlr_xwayland_destroy(xwayland);
|
||||
xwayland = NULL;
|
||||
@@ -683,7 +701,8 @@ cleanup(void)
|
||||
wlr_xcursor_manager_destroy(cursor_mgr);
|
||||
wlr_output_layout_destroy(output_layout);
|
||||
|
||||
- destroykeyboardgroup(&kb_group->destroy, NULL);
|
||||
+ wl_list_for_each(kb_group, &kb_groups, link)
|
||||
+ destroykeyboardgroup(&kb_group->destroy, NULL);
|
||||
|
||||
wl_display_destroy(dpy);
|
||||
/* Destroy after the wayland display (when the monitors are already destroyed)
|
||||
@@ -803,6 +822,30 @@ createidleinhibitor(struct wl_listener *listener, void *data)
|
||||
void
|
||||
createkeyboard(struct wlr_keyboard *keyboard)
|
||||
{
|
||||
+ KeyboardGroup *kb_group;
|
||||
+ const char *device_name = "";
|
||||
+ const KeyboardRule *krule = NULL;
|
||||
+ struct libinput_device *device = NULL;
|
||||
+
|
||||
+ if (wlr_input_device_is_libinput(&keyboard->base)
|
||||
+ && (device = wlr_libinput_get_device_handle(&keyboard->base))) {
|
||||
+ device_name = libinput_device_get_name(device);
|
||||
+ }
|
||||
+ for (krule = kbrules; krule < END(kbrules); krule++) {
|
||||
+ if (!krule->name || strstr(device_name, krule->name))
|
||||
+ break;
|
||||
+ }
|
||||
+ if (krule) {
|
||||
+ struct xkb_rule_names xkb_rules;
|
||||
+ xkb_rules.rules = krule->rules;
|
||||
+ xkb_rules.model = krule->model;
|
||||
+ xkb_rules.layout = krule->layout;
|
||||
+ xkb_rules.variant = krule->variant;
|
||||
+ xkb_rules.options = krule->options;
|
||||
+ kb_group = createkeyboardgroup(&xkb_rules);
|
||||
+ } else
|
||||
+ wl_list_for_each(kb_group, &kb_groups, link);
|
||||
+
|
||||
/* Set the keymap to match the group keymap */
|
||||
wlr_keyboard_set_keymap(keyboard, kb_group->wlr_group->keyboard.keymap);
|
||||
|
||||
@@ -811,11 +854,16 @@ createkeyboard(struct wlr_keyboard *keyboard)
|
||||
}
|
||||
|
||||
KeyboardGroup *
|
||||
-createkeyboardgroup(void)
|
||||
+createkeyboardgroup(struct xkb_rule_names *new_xkb_rules)
|
||||
{
|
||||
KeyboardGroup *group = ecalloc(1, sizeof(*group));
|
||||
struct xkb_context *context;
|
||||
struct xkb_keymap *keymap;
|
||||
+ struct xkb_rule_names xkb_rules;
|
||||
+
|
||||
+ memset(&xkb_rules, 0, sizeof(struct xkb_rule_names));
|
||||
+ if (new_xkb_rules)
|
||||
+ xkb_rules = *new_xkb_rules;
|
||||
|
||||
group->wlr_group = wlr_keyboard_group_create();
|
||||
group->wlr_group->data = group;
|
||||
@@ -845,6 +893,9 @@ createkeyboardgroup(void)
|
||||
* all of them. Set this combined wlr_keyboard as the seat keyboard.
|
||||
*/
|
||||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||
+
|
||||
+ wl_list_init(&group->destroy.link);
|
||||
+ wl_list_insert(&kb_groups, &group->link);
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -1042,9 +1093,15 @@ createnotify(struct wl_listener *listener, void *data)
|
||||
void
|
||||
createpointer(struct wlr_pointer *pointer)
|
||||
{
|
||||
@ -83,17 +207,15 @@ index 5867b0c..ebc0180 100644
|
||||
struct libinput_device *device;
|
||||
if (wlr_input_device_is_libinput(&pointer->base)
|
||||
&& (device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||
|
||||
+ const char *device_name = libinput_device_get_name(device);
|
||||
+ for (irule = inputrules; irule < END(inputrules); irule++) {
|
||||
+ if (!irule->name || strstr(device_name, irule->name))
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
|
||||
if (libinput_device_config_tap_get_finger_count(device)) {
|
||||
libinput_device_config_tap_set_enabled(device, tap_to_click);
|
||||
libinput_device_config_tap_set_drag_enabled(device, tap_and_drag);
|
||||
@@ -1021,11 +1035,11 @@ createpointer(struct wlr_pointer *pointer)
|
||||
@@ -1072,11 +1129,11 @@ createpointer(struct wlr_pointer *pointer)
|
||||
libinput_device_config_click_set_method (device, click_method);
|
||||
|
||||
if (libinput_device_config_send_events_get_modes(device))
|
||||
@ -108,268 +230,66 @@ index 5867b0c..ebc0180 100644
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.44.0
|
||||
|
||||
|
||||
From c5a456791e508f5258707a85fc2f78d8cf94397d Mon Sep 17 00:00:00 2001
|
||||
From: nullsystem <nullsystem.aongp@slmail.me>
|
||||
Date: Sun, 31 Mar 2024 18:27:20 +0100
|
||||
Subject: [PATCH 2/2] perinputconfig - extend to keyboards
|
||||
|
||||
- keyboards can now also set by name
|
||||
- multiple of keyboard groups
|
||||
---
|
||||
config.def.h | 9 +++--
|
||||
dwl.c | 107 ++++++++++++++++++++++++++++++++++++++++++++-------
|
||||
2 files changed, 98 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 84c0f6b..97f73da 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -48,12 +48,13 @@ static const MonitorRule monrules[] = {
|
||||
};
|
||||
|
||||
/* keyboard */
|
||||
-static const struct xkb_rule_names xkb_rules = {
|
||||
- /* can specify fields: rules, model, layout, variant, options */
|
||||
+/* NOTE: Always include a fallback rule at the end (name as NULL) */
|
||||
+static const KeyboardRule kbrules[] = {
|
||||
+ /* name rules model layout variant options */
|
||||
/* example:
|
||||
- .options = "ctrl:nocaps",
|
||||
+ { "keyboard", NULL, NULL, "us,de", NULL, "ctrl:nocaps" },
|
||||
*/
|
||||
- .options = NULL,
|
||||
+ { NULL, NULL, NULL, NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
static const int repeat_rate = 25;
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index ebc0180..481a9be 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -246,6 +246,15 @@ typedef struct {
|
||||
double accel_speed;
|
||||
} InputRule;
|
||||
|
||||
+typedef struct {
|
||||
+ const char *name;
|
||||
+ const char *rules;
|
||||
+ const char *model;
|
||||
+ const char *layout;
|
||||
+ const char *variant;
|
||||
+ const char *options;
|
||||
+} KeyboardRule;
|
||||
+
|
||||
/* function declarations */
|
||||
static void applybounds(Client *c, struct wlr_box *bbox);
|
||||
static void applyrules(Client *c);
|
||||
@@ -264,6 +273,7 @@ static void commitlayersurfacenotify(struct wl_listener *listener, void *data);
|
||||
static void commitnotify(struct wl_listener *listener, void *data);
|
||||
static void createdecoration(struct wl_listener *listener, void *data);
|
||||
static void createidleinhibitor(struct wl_listener *listener, void *data);
|
||||
+static size_t createkbgroup(struct xkb_keymap *keymap);
|
||||
static void createkeyboard(struct wlr_keyboard *keyboard);
|
||||
static void createlayersurface(struct wl_listener *listener, void *data);
|
||||
static void createlocksurface(struct wl_listener *listener, void *data);
|
||||
@@ -400,7 +410,8 @@ static struct wlr_session_lock_v1 *cur_lock;
|
||||
static struct wl_listener lock_listener = {.notify = locksession};
|
||||
|
||||
static struct wlr_seat *seat;
|
||||
-static KeyboardGroup kb_group = {0};
|
||||
+static KeyboardGroup *kb_groups;
|
||||
+static size_t kb_groups_length = 0;
|
||||
static KeyboardGroup vkb_group = {0};
|
||||
static struct wlr_surface *held_grab;
|
||||
static unsigned int cursor_mode;
|
||||
@@ -662,6 +673,8 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
||||
void
|
||||
cleanup(void)
|
||||
{
|
||||
+ size_t i;
|
||||
+
|
||||
#ifdef XWAYLAND
|
||||
wlr_xwayland_destroy(xwayland);
|
||||
xwayland = NULL;
|
||||
@@ -675,13 +688,16 @@ cleanup(void)
|
||||
wlr_output_layout_destroy(output_layout);
|
||||
|
||||
/* Remove event source that use the dpy event loop before destroying dpy */
|
||||
- wl_event_source_remove(kb_group.key_repeat_source);
|
||||
+ for (i = 0; i < kb_groups_length; i++)
|
||||
+ wl_event_source_remove(kb_groups[i].key_repeat_source);
|
||||
wl_event_source_remove(vkb_group.key_repeat_source);
|
||||
|
||||
wl_display_destroy(dpy);
|
||||
/* Destroy after the wayland display (when the monitors are already destroyed)
|
||||
to avoid destroying them with an invalid scene output. */
|
||||
wlr_scene_node_destroy(&scene->tree.node);
|
||||
+
|
||||
+ free(kb_groups);
|
||||
@@ -1277,7 +1334,6 @@ destroykeyboardgroup(struct wl_listener *listener, void *data)
|
||||
wl_list_remove(&group->key.link);
|
||||
wl_list_remove(&group->modifiers.link);
|
||||
wl_list_remove(&group->destroy.link);
|
||||
- free(group);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -793,15 +809,69 @@ createidleinhibitor(struct wl_listener *listener, void *data)
|
||||
checkidleinhibitor(NULL);
|
||||
}
|
||||
Monitor *
|
||||
@@ -1467,6 +1523,7 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
* available. */
|
||||
struct wlr_input_device *device = data;
|
||||
uint32_t caps;
|
||||
+ KeyboardGroup *group;
|
||||
|
||||
+size_t
|
||||
+createkbgroup(struct xkb_keymap *keymap)
|
||||
+{
|
||||
+ size_t i = kb_groups_length++;
|
||||
+
|
||||
+ kb_groups[i].wlr_group = wlr_keyboard_group_create();
|
||||
+ kb_groups[i].wlr_group->data = &kb_groups[i];
|
||||
+ wlr_keyboard_set_keymap(&kb_groups[i].wlr_group->keyboard, keymap);
|
||||
+ wlr_keyboard_set_repeat_info(&kb_groups[i].wlr_group->keyboard, repeat_rate, repeat_delay);
|
||||
+
|
||||
+ /* Set up listeners for keyboard events */
|
||||
+ LISTEN(&kb_groups[i].wlr_group->keyboard.events.key, &kb_groups[i].key, keypress);
|
||||
+ LISTEN(&kb_groups[i].wlr_group->keyboard.events.modifiers, &kb_groups[i].modifiers, keypressmod);
|
||||
+ kb_groups[i].key_repeat_source = wl_event_loop_add_timer(
|
||||
+ wl_display_get_event_loop(dpy), keyrepeat, &kb_groups[i]);
|
||||
+
|
||||
+ return i;
|
||||
+}
|
||||
+
|
||||
void
|
||||
createkeyboard(struct wlr_keyboard *keyboard)
|
||||
{
|
||||
+ const KeyboardRule *krule = NULL;
|
||||
+ struct libinput_device *device = NULL;
|
||||
+ struct xkb_keymap *keymap = NULL;
|
||||
+ struct xkb_context *context = NULL;
|
||||
+ struct xkb_rule_names xkb_rules;
|
||||
+ size_t kb_groups_i = 0;
|
||||
+
|
||||
+ if (wlr_input_device_is_libinput(&keyboard->base)
|
||||
+ && (device = wlr_libinput_get_device_handle(&keyboard->base))) {
|
||||
+ const char *device_name = libinput_device_get_name(device);
|
||||
+ for (krule = kbrules; krule < END(kbrules); krule++) {
|
||||
+ if (!krule->name || strstr(device_name, krule->name))
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (krule->name) {
|
||||
+ xkb_rules.rules = krule->rules;
|
||||
+ xkb_rules.model = krule->model;
|
||||
+ xkb_rules.layout = krule->layout;
|
||||
+ xkb_rules.variant = krule->variant;
|
||||
+ xkb_rules.options = krule->options;
|
||||
+
|
||||
+ context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
+ if ((keymap = xkb_keymap_new_from_names(context, &xkb_rules,
|
||||
+ XKB_KEYMAP_COMPILE_NO_FLAGS))) {
|
||||
+ kb_groups_i = createkbgroup(keymap);
|
||||
+ } else {
|
||||
+ fprintf(stderr, "failed to compile keymap for %s\n", krule->name);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Set the keymap to match the group keymap */
|
||||
- wlr_keyboard_set_keymap(keyboard, kb_group.wlr_group->keyboard.keymap);
|
||||
+ wlr_keyboard_set_keymap(keyboard, kb_groups[kb_groups_i].wlr_group->keyboard.keymap);
|
||||
wlr_keyboard_set_repeat_info(keyboard, repeat_rate, repeat_delay);
|
||||
|
||||
/* Add the new keyboard to the group */
|
||||
- wlr_keyboard_group_add_keyboard(kb_group.wlr_group, keyboard);
|
||||
+ wlr_keyboard_group_add_keyboard(kb_groups[kb_groups_i].wlr_group, keyboard);
|
||||
+
|
||||
+ xkb_keymap_unref(keymap);
|
||||
+ xkb_context_unref(context);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1000,6 +1070,7 @@ createpointer(struct wlr_pointer *pointer)
|
||||
{
|
||||
const InputRule *irule;
|
||||
struct libinput_device *device;
|
||||
+
|
||||
if (wlr_input_device_is_libinput(&pointer->base)
|
||||
&& (device = wlr_libinput_get_device_handle(&pointer->base))) {
|
||||
|
||||
@@ -1436,7 +1507,7 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
@@ -1485,8 +1542,11 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
* there are no pointer devices, so we always include that capability. */
|
||||
/* TODO do we actually require a cursor? */
|
||||
caps = WL_SEAT_CAPABILITY_POINTER;
|
||||
- if (!wl_list_empty(&kb_group.wlr_group->devices))
|
||||
+ if (!wl_list_empty(&kb_groups[0].wlr_group->devices))
|
||||
caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
- if (!wl_list_empty(&kb_group->wlr_group->devices))
|
||||
- caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
+ wl_list_for_each(group, &kb_groups, link)
|
||||
+ if (!wl_list_empty(&group->wlr_group->devices)) {
|
||||
+ caps |= WL_SEAT_CAPABILITY_KEYBOARD;
|
||||
+ break;
|
||||
+ }
|
||||
wlr_seat_set_capabilities(seat, caps);
|
||||
}
|
||||
@@ -2285,6 +2356,8 @@ setup(void)
|
||||
{
|
||||
struct xkb_context *context;
|
||||
struct xkb_keymap *keymap;
|
||||
+ const KeyboardRule *krule;
|
||||
+ struct xkb_rule_names xkb_rules;
|
||||
|
||||
int i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
|
||||
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
|
||||
@@ -2472,8 +2545,8 @@ setup(void)
|
||||
* keyboards, keep their modifier and LED states in sync, and handle
|
||||
* keypresses
|
||||
@@ -2431,6 +2491,7 @@ setup(void)
|
||||
*/
|
||||
- kb_group.wlr_group = wlr_keyboard_group_create();
|
||||
- kb_group.wlr_group->data = &kb_group;
|
||||
+ kb_groups = ecalloc(LENGTH(kbrules), sizeof(KeyboardGroup));
|
||||
+ kb_groups_length = 0;
|
||||
wl_list_init(&clients);
|
||||
wl_list_init(&fstack);
|
||||
+ wl_list_init(&kb_groups);
|
||||
|
||||
/*
|
||||
* Virtual keyboards need to be in a different group
|
||||
@@ -2482,28 +2555,34 @@ setup(void)
|
||||
vkb_group.wlr_group = wlr_keyboard_group_create();
|
||||
vkb_group.wlr_group->data = &vkb_group;
|
||||
xdg_shell = wlr_xdg_shell_create(dpy, 6);
|
||||
LISTEN_STATIC(&xdg_shell->events.new_surface, createnotify);
|
||||
@@ -2514,8 +2575,7 @@ setup(void)
|
||||
LISTEN_STATIC(&seat->events.request_start_drag, requeststartdrag);
|
||||
LISTEN_STATIC(&seat->events.start_drag, startdrag);
|
||||
|
||||
+ /* Set the pointers from the default kbrules */
|
||||
+ for (krule = kbrules; krule < END(kbrules); krule++) {
|
||||
+ if (!krule->name)
|
||||
+ break;
|
||||
+ }
|
||||
+ xkb_rules.rules = krule->rules;
|
||||
+ xkb_rules.model = krule->model;
|
||||
+ xkb_rules.layout = krule->layout;
|
||||
+ xkb_rules.variant = krule->variant;
|
||||
+ xkb_rules.options = krule->options;
|
||||
+
|
||||
/* Prepare an XKB keymap and assign it to the keyboard group. */
|
||||
context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules,
|
||||
XKB_KEYMAP_COMPILE_NO_FLAGS)))
|
||||
die("failed to compile keymap");
|
||||
|
||||
- wlr_keyboard_set_keymap(&kb_group.wlr_group->keyboard, keymap);
|
||||
+ createkbgroup(keymap);
|
||||
wlr_keyboard_set_keymap(&vkb_group.wlr_group->keyboard, keymap);
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_context_unref(context);
|
||||
|
||||
- wlr_keyboard_set_repeat_info(&kb_group.wlr_group->keyboard, repeat_rate, repeat_delay);
|
||||
wlr_keyboard_set_repeat_info(&vkb_group.wlr_group->keyboard, repeat_rate, repeat_delay);
|
||||
|
||||
/* Set up listeners for keyboard events */
|
||||
- LISTEN(&kb_group.wlr_group->keyboard.events.key, &kb_group.key, keypress);
|
||||
- LISTEN(&kb_group.wlr_group->keyboard.events.modifiers, &kb_group.modifiers, keypressmod);
|
||||
LISTEN(&vkb_group.wlr_group->keyboard.events.key, &vkb_group.key, keypress);
|
||||
LISTEN(&vkb_group.wlr_group->keyboard.events.modifiers, &vkb_group.modifiers, keypressmod);
|
||||
|
||||
- kb_group.key_repeat_source = wl_event_loop_add_timer(
|
||||
- wl_display_get_event_loop(dpy), keyrepeat, &kb_group);
|
||||
vkb_group.key_repeat_source = wl_event_loop_add_timer(
|
||||
wl_display_get_event_loop(dpy), keyrepeat, &vkb_group);
|
||||
|
||||
@@ -2512,7 +2591,7 @@ setup(void)
|
||||
* same wlr_keyboard_group, which provides a single wlr_keyboard interface for
|
||||
* all of them. Set this combined wlr_keyboard as the seat keyboard.
|
||||
*/
|
||||
- wlr_seat_set_keyboard(seat, &kb_group.wlr_group->keyboard);
|
||||
+ wlr_seat_set_keyboard(seat, &kb_groups[0].wlr_group->keyboard);
|
||||
- kb_group = createkeyboardgroup();
|
||||
- wl_list_init(&kb_group->destroy.link);
|
||||
+ createkeyboardgroup(NULL);
|
||||
|
||||
output_mgr = wlr_output_manager_v1_create(dpy);
|
||||
LISTEN_STATIC(&output_mgr->events.apply, outputmgrapply);
|
||||
@@ -2857,10 +2917,9 @@ virtualkeyboard(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_virtual_keyboard_v1 *kb = data;
|
||||
/* virtual keyboards shouldn't share keyboard group */
|
||||
- KeyboardGroup *group = createkeyboardgroup();
|
||||
+ KeyboardGroup *group = createkeyboardgroup(NULL);
|
||||
/* Set the keymap to match the group keymap */
|
||||
wlr_keyboard_set_keymap(&kb->keyboard, group->wlr_group->keyboard.keymap);
|
||||
- LISTEN(&kb->keyboard.base.events.destroy, &group->destroy, destroykeyboardgroup);
|
||||
|
||||
/* Add the new keyboard to the group */
|
||||
wlr_keyboard_group_add_keyboard(group->wlr_group, &kb->keyboard);
|
||||
--
|
||||
2.44.0
|
||||
2.45.2
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user