diff options
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -385,6 +385,7 @@ static void setsel(struct wl_listener *listener, void *data); static void setup(void); static void spawn(const Arg *arg); static void startdrag(struct wl_listener *listener, void *data); +static void switchxkbrule(const Arg *arg); static int statusin(int fd, unsigned int mask, void *data); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -463,6 +464,7 @@ static struct wl_listener lock_listener = {.notify = locksession}; static struct wlr_seat *seat; static KeyboardGroup *kb_group; static unsigned int cursor_mode; +static unsigned int xkb_rule_index = 0; static Client *grabc; static int grabcx, grabcy; /* client-relative */ @@ -1104,7 +1106,7 @@ createkeyboardgroup(void) /* 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, + if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules[xkb_rule_index], XKB_KEYMAP_COMPILE_NO_FLAGS))) die("failed to compile keymap"); @@ -3094,6 +3096,21 @@ statusin(int fd, unsigned int mask, void *data) } void +switchxkbrule(const Arg *arg) +{ + struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + struct xkb_keymap *keymap; + + xkb_rule_index = (xkb_rule_index + 1) % LENGTH(xkb_rules); + if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules[xkb_rule_index], + XKB_KEYMAP_COMPILE_NO_FLAGS))) + die("failed to compile keymap"); + wlr_keyboard_set_keymap(&kb_group->wlr_group->keyboard, keymap); + xkb_keymap_unref(keymap); + xkb_context_unref(context); +} + +void tag(const Arg *arg) { Client *sel = focustop(selmon); |