mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-09-07 11:44:43 +00:00
fix some key binding events being passed to clients
This commit is contained in:
parent
4456f4536a
commit
1f82a5bc08
15
client.h
15
client.h
@ -291,11 +291,18 @@ client_is_unmanaged(Client *c)
|
||||
static inline void
|
||||
client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
|
||||
{
|
||||
if (kb)
|
||||
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
|
||||
kb->num_keycodes, &kb->modifiers);
|
||||
else
|
||||
uint32_t filtered[WLR_KEYBOARD_KEYS_CAP];
|
||||
size_t size = 0;
|
||||
if (!kb) {
|
||||
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < kb->num_keycodes; i++) {
|
||||
uint32_t key = kb->keycodes[i];
|
||||
if (!consumed[key])
|
||||
filtered[size++] = key;
|
||||
}
|
||||
wlr_seat_keyboard_notify_enter(seat, s, filtered, size, &kb->modifiers);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
35
dwl.c
35
dwl.c
@ -291,7 +291,7 @@ static void gpureset(struct wl_listener *listener, void *data);
|
||||
static void handlesig(int signo);
|
||||
static void incnmaster(const Arg *arg);
|
||||
static void inputdevice(struct wl_listener *listener, void *data);
|
||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
static const Key * keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||
static void keypress(struct wl_listener *listener, void *data);
|
||||
static void keypressmod(struct wl_listener *listener, void *data);
|
||||
static int keyrepeat(void *data);
|
||||
@ -405,6 +405,7 @@ static struct wlr_output_layout *output_layout;
|
||||
static struct wlr_box sgeom;
|
||||
static struct wl_list mons;
|
||||
static Monitor *selmon;
|
||||
static bool consumed[KEY_MAX + 1];
|
||||
|
||||
/* global event handlers */
|
||||
static struct wl_listener cursor_axis = {.notify = axisnotify};
|
||||
@ -1602,7 +1603,7 @@ inputdevice(struct wl_listener *listener, void *data)
|
||||
wlr_seat_set_capabilities(seat, caps);
|
||||
}
|
||||
|
||||
int
|
||||
const Key *
|
||||
keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
{
|
||||
/*
|
||||
@ -1613,12 +1614,10 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
const Key *k;
|
||||
for (k = keys; k < END(keys); k++) {
|
||||
if (CLEANMASK(mods) == CLEANMASK(k->mod)
|
||||
&& sym == k->keysym && k->func) {
|
||||
k->func(&k->arg);
|
||||
return 1;
|
||||
}
|
||||
&& sym == k->keysym && k->func)
|
||||
return k;
|
||||
}
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1644,8 +1643,14 @@ keypress(struct wl_listener *listener, void *data)
|
||||
/* On _press_ if there is no active screen locker,
|
||||
* attempt to process a compositor keybinding. */
|
||||
if (!locked && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
for (i = 0; i < nsyms; i++)
|
||||
handled = keybinding(mods, syms[i]) || handled;
|
||||
for (i = 0; i < nsyms; i++) {
|
||||
const Key *key = keybinding(mods, syms[i]);
|
||||
if (key) {
|
||||
consumed[event->keycode] = true;
|
||||
key->func(&key->arg);
|
||||
handled = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (handled && group->wlr_group->keyboard.repeat_info.delay > 0) {
|
||||
@ -1662,6 +1667,11 @@ keypress(struct wl_listener *listener, void *data)
|
||||
if (handled)
|
||||
return;
|
||||
|
||||
if (consumed[event->keycode]) {
|
||||
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
||||
consumed[event->keycode] = false;
|
||||
return; // don't pass to the client the release event of a handled key-press
|
||||
}
|
||||
wlr_seat_set_keyboard(seat, &group->wlr_group->keyboard);
|
||||
/* Pass unhandled keycodes along to the client. */
|
||||
wlr_seat_keyboard_notify_key(seat, event->time_msec,
|
||||
@ -1692,8 +1702,11 @@ keyrepeat(void *data)
|
||||
wl_event_source_timer_update(group->key_repeat_source,
|
||||
1000 / group->wlr_group->keyboard.repeat_info.rate);
|
||||
|
||||
for (i = 0; i < group->nsyms; i++)
|
||||
keybinding(group->mods, group->keysyms[i]);
|
||||
for (i = 0; i < group->nsyms; i++) {
|
||||
const Key *key = keybinding(group->mods, group->keysyms[i]);
|
||||
if (key)
|
||||
key->func(&key->arg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user