mirror of
https://codeberg.org/dwl/dwl.git
synced 2026-04-07 08:21:07 -04:00
use keycodes instead keysyms
This commit is contained in:
parent
25a96a8190
commit
bcaa992d37
3 changed files with 290 additions and 71 deletions
16
dwl.c
16
dwl.c
|
|
@ -139,7 +139,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
uint32_t mod;
|
||||
xkb_keysym_t keysym;
|
||||
xkb_keycode_t keycode;
|
||||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
} Key;
|
||||
|
|
@ -284,7 +284,7 @@ static void incogaps(const Arg *arg);
|
|||
static void incohgaps(const Arg *arg);
|
||||
static void incovgaps(const Arg *arg);
|
||||
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_keycode_t keycode);
|
||||
static void keypress(struct wl_listener *listener, void *data);
|
||||
static void keypressmod(struct wl_listener *listener, void *data);
|
||||
static void killclient(const Arg *arg);
|
||||
|
|
@ -1795,7 +1795,7 @@ inputdevice(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
int
|
||||
keybinding(uint32_t mods, xkb_keysym_t sym)
|
||||
keybinding(uint32_t mods, xkb_keycode_t keycode)
|
||||
{
|
||||
/*
|
||||
* Here we handle compositor keybindings. This is when the compositor is
|
||||
|
|
@ -1806,7 +1806,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) &&
|
||||
sym == k->keysym && k->func) {
|
||||
keycode == k->keycode && k->func) {
|
||||
k->func(&k->arg);
|
||||
handled = 1;
|
||||
}
|
||||
|
|
@ -1817,17 +1817,12 @@ keybinding(uint32_t mods, xkb_keysym_t sym)
|
|||
void
|
||||
keypress(struct wl_listener *listener, void *data)
|
||||
{
|
||||
int i;
|
||||
/* This event is raised when a key is pressed or released. */
|
||||
Keyboard *kb = wl_container_of(listener, kb, key);
|
||||
struct wlr_event_keyboard_key *event = data;
|
||||
|
||||
/* Translate libinput keycode -> xkbcommon */
|
||||
uint32_t keycode = event->keycode + 8;
|
||||
/* Get a list of keysyms based on the keymap for this keyboard */
|
||||
const xkb_keysym_t *syms;
|
||||
int nsyms = xkb_state_key_get_syms(
|
||||
kb->device->keyboard->xkb_state, keycode, &syms);
|
||||
|
||||
int handled = 0;
|
||||
uint32_t mods = wlr_keyboard_get_modifiers(kb->device->keyboard);
|
||||
|
|
@ -1838,8 +1833,7 @@ keypress(struct wl_listener *listener, void *data)
|
|||
* attempt to process a compositor keybinding. */
|
||||
if (!input_inhibit_mgr->active_inhibitor
|
||||
&& event->state == WL_KEYBOARD_KEY_STATE_PRESSED)
|
||||
for (i = 0; i < nsyms; i++)
|
||||
handled = keybinding(mods, syms[i]) || handled;
|
||||
handled = keybinding(mods, keycode);
|
||||
|
||||
if (!handled) {
|
||||
/* Pass unhandled keycodes along to the client. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue