From 4d7993b36fa3f97e26c527c37b36eb9321b79791 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 2 Aug 2019 18:19:07 +0200 Subject: 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. --- input.c | 55 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'input.c') diff --git a/input.c b/input.c index 783d8f52..596bce1f 100644 --- a/input.c +++ b/input.c @@ -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 -- cgit v1.3