mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-02-04 02:03:04 +00:00
keybinding: statically convert number keys from keycodes to keysyms, rm SKEYs from TAGKEYS + bindings, mv xkb_keysym_to_lower call to invocation in keypress
This commit is contained in:
parent
9b11a49cb7
commit
525d8b390b
25
config.def.h
25
config.def.h
@ -105,11 +105,11 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
|
||||
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
#define TAGKEYS(KEY,SKEY,TAG) \
|
||||
#define TAGKEYS(KEY,TAG) \
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_CTRL, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, SKEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,SKEY,toggletag, {.ui = 1 << TAG} }
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|WLR_MODIFIER_CTRL|WLR_MODIFIER_SHIFT,KEY,toggletag, {.ui = 1 << TAG} }
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
@ -119,7 +119,6 @@ static const char *termcmd[] = { "foot", NULL };
|
||||
static const char *menucmd[] = { "wmenu-run", NULL };
|
||||
|
||||
static const Key keys[] = {
|
||||
/* Note that Shift changes certain key codes: 2 -> at, etc. */
|
||||
/* modifier key function argument */
|
||||
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
|
||||
@ -144,15 +143,15 @@ static const Key keys[] = {
|
||||
{ MODKEY, XKB_KEY_period, focusmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_less, tagmon, {.i = WLR_DIRECTION_LEFT} },
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_greater, tagmon, {.i = WLR_DIRECTION_RIGHT} },
|
||||
TAGKEYS( XKB_KEY_1, XKB_KEY_exclam, 0),
|
||||
TAGKEYS( XKB_KEY_2, XKB_KEY_at, 1),
|
||||
TAGKEYS( XKB_KEY_3, XKB_KEY_numbersign, 2),
|
||||
TAGKEYS( XKB_KEY_4, XKB_KEY_dollar, 3),
|
||||
TAGKEYS( XKB_KEY_5, XKB_KEY_percent, 4),
|
||||
TAGKEYS( XKB_KEY_6, XKB_KEY_asciicircum, 5),
|
||||
TAGKEYS( XKB_KEY_7, XKB_KEY_ampersand, 6),
|
||||
TAGKEYS( XKB_KEY_8, XKB_KEY_asterisk, 7),
|
||||
TAGKEYS( XKB_KEY_9, XKB_KEY_parenleft, 8),
|
||||
TAGKEYS( XKB_KEY_1, 0),
|
||||
TAGKEYS( XKB_KEY_2, 1),
|
||||
TAGKEYS( XKB_KEY_3, 2),
|
||||
TAGKEYS( XKB_KEY_4, 3),
|
||||
TAGKEYS( XKB_KEY_5, 4),
|
||||
TAGKEYS( XKB_KEY_6, 5),
|
||||
TAGKEYS( XKB_KEY_7, 6),
|
||||
TAGKEYS( XKB_KEY_8, 7),
|
||||
TAGKEYS( XKB_KEY_9, 8),
|
||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_q, quit, {0} },
|
||||
|
||||
/* Ctrl-Alt-Backspace and Ctrl-Alt-Fx used to be handled by X server */
|
||||
|
||||
9
dwl.c
9
dwl.c
@ -1615,8 +1615,7 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
*/
|
||||
const Key *k;
|
||||
for (k = keys; k < END(keys); k++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||
&& xkb_keysym_to_lower(sym) == xkb_keysym_to_lower(k->keysym)
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod) && sym == k->keysym
|
||||
&& k->func) {
|
||||
k->func(&k->arg);
|
||||
return 1;
|
||||
@ -1646,10 +1645,12 @@ keypress(struct wl_listener *listener, void *data)
|
||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||
|
||||
/* On _press_ if there is no active screen locker,
|
||||
* attempt to process a compositor keybinding. */
|
||||
* attempt to process a compositor keybinding.
|
||||
* Number keys (10 <= keycode <= 18 for 1-9) are statically converted. */
|
||||
if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
for (i = 0; i < nsyms; i++)
|
||||
handled = keybinding(mods, syms[i]) || handled;
|
||||
handled = keybinding(mods, (10 <= keycode && keycode <= 18) ?
|
||||
keycode + 39 : xkb_keysym_to_lower(syms[i])) || handled;
|
||||
}
|
||||
|
||||
if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user