diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-07-29 00:10:16 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-07-29 00:10:16 -0400 |
commit | 0c64938fd369bb5269f7796514a20f8e1a6e0896 (patch) | |
tree | 7f5dbf4504064ae02f50d9f045ecabd21ee499c0 | |
parent | 45c18a6e254955fd2e659125545f9dff1de894e2 (diff) |
Implement togglekblayoutandoptions patch (fixed)
-rw-r--r-- | config.h | 19 | ||||
-rw-r--r-- | dwl.c | 21 |
2 files changed, 32 insertions, 8 deletions
@@ -84,13 +84,16 @@ static const MonitorRule monrules[] = { }; /* keyboard */ -static const struct xkb_rule_names xkb_rules = { - /* can specify fields: rules, model, layout, variant, options */ - /* example: - .options = "ctrl:nocaps", - */ - .options = NULL, -}; +static const struct xkb_rule_names xkb_rules[] = { + { + .layout = "us" + /* .variant = "dvp", */ + /* .options = "compose:102,numpad:shift3,kpdl:semi,keypad:atm,caps:super" */ + }, + { + .layout = "ca" + }, + }; static const int repeat_rate = 50; static const int repeat_delay = 300; @@ -172,6 +175,8 @@ static const Key keys[] = { { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_plus, incgaps, {.i = +1 } }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_underscore, togglegaps, {0} }, { MODKEY, XKB_KEY_equal, defaultgaps, {0} }, + { WLR_MODIFIER_ALT, XKB_KEY_Return, incxkbrules, {0} }, + // { WLR_MODIFIER_ALT, XKB_KEY_Return, incxkbrules, {.i = +1} }, // { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_H, incogaps, {.i = +1 } }, // { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_L, incogaps, {.i = -1 } }, // { MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL, XKB_KEY_h, incigaps, {.i = +1 } }, @@ -378,6 +378,7 @@ static void setup(void); static void spawn(const Arg *arg); static void startdrag(struct wl_listener *listener, void *data); static int status_in(int fd, unsigned int mask, void *data); +static void incxkbrules(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); @@ -450,6 +451,7 @@ static struct wl_listener lock_listener = {.notify = locksession}; static struct wlr_seat *seat; static KeyboardGroup *kb_group; +static unsigned int kblayout = 0; static unsigned int cursor_mode; static Client *grabc; static Client initial_grabc; @@ -1065,7 +1067,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[kblayout], XKB_KEYMAP_COMPILE_NO_FLAGS))) die("failed to compile keymap"); @@ -1091,6 +1093,23 @@ createkeyboardgroup(void) } void +incxkbrules(const Arg *arg) +{ + struct xkb_context *context; + struct xkb_keymap *keymap; + kblayout = (kblayout+1)%LENGTH(xkb_rules); + + context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + if (!(keymap = xkb_keymap_new_from_names(context, &xkb_rules[kblayout], + 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 createlayersurface(struct wl_listener *listener, void *data) { struct wlr_layer_surface_v1 *layer_surface = data; |