aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorawy <awy@tutamail.com>2024-08-25 16:32:55 +0300
committerawy <awy@tutamail.com>2024-08-25 16:32:55 +0300
commit406ad50dd681765e3f0cce85bcf5e1f8268c9149 (patch)
treea4ef45338e045371ac8300a7a05f5926e72af602 /dwl.c
parent6b2aaedbcffff422b239f858ff21c03dc3a7d67d (diff)
xkb-rules-switcher patch
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/dwl.c b/dwl.c
index 09d4516..aabb4a4 100644
--- a/dwl.c
+++ b/dwl.c
@@ -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);