diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-08-02 16:19:07 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-08-02 16:19:07 +0000 |
| commit | 4d7993b36fa3f97e26c527c37b36eb9321b79791 (patch) | |
| tree | 391b9125d821de5010b5f383813135882d54293d /input.c | |
| parent | term: implement reset (diff) | |
cell: pack more efficiently and store glyph as a wchar
The 'attributes' struct is now 8 bytes and naturally packed (used to
be 9 bytes, artificially packed).
'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes,
artificially packed).
Furthermore, the glyph is stored as a wchar instead of a char*. This
makes it easier (faster) to do glyph lookup when rendering.
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 55 |
1 files changed, 31 insertions, 24 deletions
@@ -60,12 +60,6 @@ static void keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys) { - LOG_DBG("enter"); -#if 0 - uint32_t *key; - wl_array_for_each(key, keys) - xkb_state_update_key(xkb_state, *key, 1); -#endif struct terminal *term = data; term->input_serial = serial; term_focus_in(term); @@ -76,7 +70,6 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, struct wl_surface *surface) { struct terminal *term = data; - term_focus_out(term); mtx_lock(&term->kbd.repeat.mutex); if (term->kbd.repeat.cmd != REPEAT_EXIT) { @@ -84,6 +77,35 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, cnd_signal(&term->kbd.repeat.cond); } mtx_unlock(&term->kbd.repeat.mutex); + + term_focus_out(term); +} + +static void +start_repeater(struct terminal *term, uint32_t key) +{ + mtx_lock(&term->kbd.repeat.mutex); + if (!term->kbd.repeat.dont_re_repeat) { + if (term->kbd.repeat.cmd != REPEAT_EXIT) { + term->kbd.repeat.cmd = REPEAT_START; + term->kbd.repeat.key = key; + cnd_signal(&term->kbd.repeat.cond); + } + } + mtx_unlock(&term->kbd.repeat.mutex); +} + +static void +stop_repeater(struct terminal *term, uint32_t key) +{ + mtx_lock(&term->kbd.repeat.mutex); + if (term->kbd.repeat.key == key) { + if (term->kbd.repeat.cmd != REPEAT_EXIT) { + term->kbd.repeat.cmd = REPEAT_STOP; + cnd_signal(&term->kbd.repeat.cond); + } + } + mtx_unlock(&term->kbd.repeat.mutex); } static void @@ -97,14 +119,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, const xkb_mod_mask_t shift = 1 << term->kbd.mod_shift; if (state == XKB_KEY_UP) { - mtx_lock(&term->kbd.repeat.mutex); - if (term->kbd.repeat.key == key) { - if (term->kbd.repeat.cmd != REPEAT_EXIT) { - term->kbd.repeat.cmd = REPEAT_STOP; - cnd_signal(&term->kbd.repeat.cond); - } - } - mtx_unlock(&term->kbd.repeat.mutex); + stop_repeater(term, key); return; } @@ -261,15 +276,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, } } - mtx_lock(&term->kbd.repeat.mutex); - if (!term->kbd.repeat.dont_re_repeat) { - if (term->kbd.repeat.cmd != REPEAT_EXIT) { - term->kbd.repeat.cmd = REPEAT_START; - term->kbd.repeat.key = key - 8; - cnd_signal(&term->kbd.repeat.cond); - } - } - mtx_unlock(&term->kbd.repeat.mutex); + start_repeater(term, key - 8); } static void |
