mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-26 17:54:14 +00:00
Compare commits
2 Commits
82e3bd95fc
...
e23fec173a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e23fec173a | ||
|
|
6cff4367ae |
26
dwl.c
26
dwl.c
@ -294,7 +294,7 @@ 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 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, bool run_func);
|
||||||
static void keypress(struct wl_listener *listener, void *data);
|
static void keypress(struct wl_listener *listener, void *data);
|
||||||
static void keypressmod(struct wl_listener *listener, void *data);
|
static void keypressmod(struct wl_listener *listener, void *data);
|
||||||
static int keyrepeat(void *data);
|
static int keyrepeat(void *data);
|
||||||
@ -1556,7 +1556,7 @@ inputdevice(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
keybinding(uint32_t mods, xkb_keysym_t sym)
|
keybinding(uint32_t mods, xkb_keysym_t sym, bool run_func)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Here we handle compositor keybindings. This is when the compositor is
|
* Here we handle compositor keybindings. This is when the compositor is
|
||||||
@ -1567,7 +1567,8 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
|||||||
for (k = keys; k < END(keys); k++) {
|
for (k = keys; k < END(keys); k++) {
|
||||||
if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||||
&& sym == k->keysym && k->func) {
|
&& sym == k->keysym && k->func) {
|
||||||
k->func(&k->arg);
|
if (run_func)
|
||||||
|
k->func(&k->arg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1591,15 +1592,15 @@ keypress(struct wl_listener *listener, void *data)
|
|||||||
|
|
||||||
int handled = 0;
|
int handled = 0;
|
||||||
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
uint32_t mods = wlr_keyboard_get_modifiers(&group->wlr_group->keyboard);
|
||||||
static bool consumed[1024]; // max is 767 (KEY_MAX in linux input-event-codes.h)
|
|
||||||
|
|
||||||
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
|
||||||
|
|
||||||
/* On _press_ if there is no active screen locker,
|
/* On _press_ if there is no active screen locker,
|
||||||
* attempt to process a compositor keybinding. */
|
* attempt to process a compositor keybinding. */
|
||||||
if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
if (!locked) {
|
||||||
|
bool run_func = event->state == WL_KEYBOARD_KEY_STATE_PRESSED;
|
||||||
for (i = 0; i < nsyms; i++)
|
for (i = 0; i < nsyms; i++)
|
||||||
handled = keybinding(mods, syms[i]) || handled;
|
handled = keybinding(mods, syms[i], run_func) || handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
|
if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
|
||||||
@ -1613,18 +1614,9 @@ keypress(struct wl_listener *listener, void *data)
|
|||||||
wl_event_source_timer_update(group->key_repeat_source, 0);
|
wl_event_source_timer_update(group->key_repeat_source, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handled) {
|
if (handled)
|
||||||
consumed[event->keycode] = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (consumed[event->keycode]) {
|
|
||||||
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
|
||||||
consumed[event->keycode] = false;
|
|
||||||
else
|
|
||||||
fprintf(stderr, "inconsistent state for keycode %u\n", event->keycode);
|
|
||||||
return; // don't pass the release event of a handled event to the client
|
|
||||||
}
|
|
||||||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||||
/* Pass unhandled keycodes along to the client. */
|
/* Pass unhandled keycodes along to the client. */
|
||||||
wlr_seat_keyboard_notify_key(seat, event->time_msec,
|
wlr_seat_keyboard_notify_key(seat, event->time_msec,
|
||||||
@ -1656,7 +1648,7 @@ keyrepeat(void *data)
|
|||||||
1000 / group->wlr_group->keyboard.repeat_info.rate);
|
1000 / group->wlr_group->keyboard.repeat_info.rate);
|
||||||
|
|
||||||
for (i = 0; i < group->nsyms; i++)
|
for (i = 0; i < group->nsyms; i++)
|
||||||
keybinding(group->mods, group->keysyms[i]);
|
keybinding(group->mods, group->keysyms[i], true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user