mirror of
https://github.com/tiyn/dwl.git
synced 2025-11-13 13:59:45 +01:00
merged togglekblayoutandoptions patch
This commit is contained in:
19
config.def.h
19
config.def.h
@@ -72,13 +72,21 @@ static const MonitorRule monrules[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* keyboard */
|
/* keyboard */
|
||||||
static const struct xkb_rule_names xkb_rules = {
|
static const struct xkb_rule_names xkb_rules[] = {
|
||||||
/* can specify fields: rules, model, layout, variant, options */
|
{
|
||||||
/* example:
|
|
||||||
.options = "ctrl:nocaps",
|
|
||||||
*/
|
|
||||||
.layout = "de",
|
.layout = "de",
|
||||||
.options = NULL,
|
.options = NULL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.layout = "de",
|
||||||
|
.variant = "nodeadkeys",
|
||||||
|
.options = NULL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.layout = "de",
|
||||||
|
.variant = "ru",
|
||||||
|
.options = NULL,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* input devices */
|
/* input devices */
|
||||||
@@ -181,6 +189,7 @@ static const Key keys[] = {
|
|||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_V, setlayout, {.v = &layouts[3]} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_V, setlayout, {.v = &layouts[3]} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_S, setlayout, {.v = &layouts[4]} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_S, setlayout, {.v = &layouts[4]} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, setmfact, {.f = -0.05f} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, setmfact, {.f = -0.05f} },
|
||||||
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L, incxkbrules, {.i = +1} },
|
||||||
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_semicolon, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_semicolon, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||||
|
|||||||
44
dwl.c
44
dwl.c
@@ -263,6 +263,7 @@ static void arrange(Monitor *m);
|
|||||||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||||
struct wlr_box *usable_area, int exclusive);
|
struct wlr_box *usable_area, int exclusive);
|
||||||
static void arrangelayers(Monitor *m);
|
static void arrangelayers(Monitor *m);
|
||||||
|
static void assignkeymap(struct wlr_keyboard *keyboard);
|
||||||
static void axisnotify(struct wl_listener *listener, void *data);
|
static void axisnotify(struct wl_listener *listener, void *data);
|
||||||
static void buttonpress(struct wl_listener *listener, void *data);
|
static void buttonpress(struct wl_listener *listener, void *data);
|
||||||
static void chvt(const Arg *arg);
|
static void chvt(const Arg *arg);
|
||||||
@@ -321,6 +322,7 @@ static void fullscreennotify(struct wl_listener *listener, void *data);
|
|||||||
static void gpureset(struct wl_listener *listener, void *data);
|
static void gpureset(struct wl_listener *listener, void *data);
|
||||||
static void handlesig(int signo);
|
static void handlesig(int signo);
|
||||||
static void incnmaster(const Arg *arg);
|
static void incnmaster(const Arg *arg);
|
||||||
|
static void incxkbrules(const Arg *arg);
|
||||||
static void inputdevice(struct wl_listener *listener, void *data);
|
static void inputdevice(struct wl_listener *listener, void *data);
|
||||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||||
static void keypress(struct wl_listener *listener, void *data);
|
static void keypress(struct wl_listener *listener, void *data);
|
||||||
@@ -361,6 +363,7 @@ static void setmon(Client *c, Monitor *m, uint32_t newtags);
|
|||||||
static void setpsel(struct wl_listener *listener, void *data);
|
static void setpsel(struct wl_listener *listener, void *data);
|
||||||
static void setsel(struct wl_listener *listener, void *data);
|
static void setsel(struct wl_listener *listener, void *data);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
|
static void setxkbrules(const Arg *arg);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
static void startdrag(struct wl_listener *listener, void *data);
|
static void startdrag(struct wl_listener *listener, void *data);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
@@ -435,6 +438,7 @@ static struct wlr_session_lock_v1 *cur_lock;
|
|||||||
|
|
||||||
static struct wlr_seat *seat;
|
static struct wlr_seat *seat;
|
||||||
static KeyboardGroup *kb_group;
|
static KeyboardGroup *kb_group;
|
||||||
|
static unsigned int kblayout = 0;
|
||||||
static unsigned int cursor_mode;
|
static unsigned int cursor_mode;
|
||||||
static Client *grabc;
|
static Client *grabc;
|
||||||
static int grabcx, grabcy; /* client-relative */
|
static int grabcx, grabcy; /* client-relative */
|
||||||
@@ -657,6 +661,20 @@ arrangelayers(Monitor *m)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
assignkeymap(struct wlr_keyboard *keyboard) {
|
||||||
|
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
|
struct xkb_keymap *keymap = xkb_keymap_new_from_names(context, &xkb_rules[kblayout],
|
||||||
|
XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
|
||||||
|
if (!keymap)
|
||||||
|
die("failed to compile keymap");
|
||||||
|
|
||||||
|
wlr_keyboard_set_keymap(keyboard, keymap);
|
||||||
|
xkb_keymap_unref(keymap);
|
||||||
|
xkb_context_unref(context);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
axisnotify(struct wl_listener *listener, void *data)
|
axisnotify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
@@ -1015,21 +1033,11 @@ KeyboardGroup *
|
|||||||
createkeyboardgroup(void)
|
createkeyboardgroup(void)
|
||||||
{
|
{
|
||||||
KeyboardGroup *group = ecalloc(1, sizeof(*group));
|
KeyboardGroup *group = ecalloc(1, sizeof(*group));
|
||||||
struct xkb_context *context;
|
|
||||||
struct xkb_keymap *keymap;
|
|
||||||
|
|
||||||
group->wlr_group = wlr_keyboard_group_create();
|
group->wlr_group = wlr_keyboard_group_create();
|
||||||
group->wlr_group->data = group;
|
group->wlr_group->data = group;
|
||||||
|
|
||||||
/* Prepare an XKB keymap and assign it to the keyboard group. */
|
assignkeymap(&group->wlr_group->keyboard);
|
||||||
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(&group->wlr_group->keyboard, keymap);
|
|
||||||
xkb_keymap_unref(keymap);
|
|
||||||
xkb_context_unref(context);
|
|
||||||
|
|
||||||
wlr_keyboard_set_repeat_info(&group->wlr_group->keyboard, repeat_rate, repeat_delay);
|
wlr_keyboard_set_repeat_info(&group->wlr_group->keyboard, repeat_rate, repeat_delay);
|
||||||
|
|
||||||
@@ -1909,6 +1917,13 @@ incnmaster(const Arg *arg)
|
|||||||
arrange(selmon);
|
arrange(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
incxkbrules(const Arg *arg)
|
||||||
|
{
|
||||||
|
kblayout = (kblayout + arg->i) % LENGTH(xkb_rules);
|
||||||
|
assignkeymap(&kb_group->wlr_group->keyboard);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
inputdevice(struct wl_listener *listener, void *data)
|
inputdevice(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
@@ -3023,6 +3038,13 @@ setup(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setxkbrules(const Arg *arg)
|
||||||
|
{
|
||||||
|
kblayout = arg->i;
|
||||||
|
assignkeymap(&kb_group->wlr_group->keyboard);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user