~sircmpwn/wio

8ecffded9bf606e80ce8b2ad3d2ed929aea4f374 — Leon Plickat 5 years ago 960ffdf
`Esc` stops current action / event
1 files changed, 20 insertions(+), 0 deletions(-)

M input.c
M input.c => input.c +20 -0
@@ 23,6 23,7 @@ static void keyboard_handle_modifiers(
		&keyboard->device->keyboard->modifiers);
}

static void view_end_interactive(struct wio_server *server);
static void keyboard_handle_key(
		struct wl_listener *listener, void *data) {
	struct wio_keyboard *keyboard =


@@ 30,6 31,25 @@ static void keyboard_handle_key(
	struct wio_server *server = keyboard->server;
	struct wlr_event_keyboard_key *event = data;
	struct wlr_seat *seat = server->seat;
	xkb_keycode_t keycode = event->keycode + 8;
	const xkb_keysym_t *syms;
	int nsyms = xkb_state_key_get_syms(
		keyboard->device->keyboard->xkb_state,
		keycode, &syms);

	for (int i = 0; i < nsyms; i++) {
		if (syms[i] == XKB_KEY_Escape) {
			switch (server->input_state) {
			case INPUT_STATE_NONE:
			case INPUT_STATE_MENU:
				break;
			default:
				view_end_interactive(server);
				return;
			}
		}
	}

	wlr_seat_set_keyboard(seat, keyboard->device);
	wlr_seat_keyboard_notify_key(seat, event->time_msec,
		event->keycode, event->state);