From 3a5fce339f8dcc22db8cafdfeba7b2748df02d18 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 20 Aug 2015 17:14:26 -0400 Subject: [PATCH] Reset key buffer on reload To preserve my sanity --- include/input_state.h | 1 + sway/config.c | 3 +++ sway/input_state.c | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/include/input_state.h b/include/input_state.h index 782b4b19..a7e0c1ca 100644 --- a/include/input_state.h +++ b/include/input_state.h @@ -44,6 +44,7 @@ extern struct pointer_state { void start_floating(swayc_t *view); void reset_floating(swayc_t *view); +void input_init(void); #endif diff --git a/sway/config.c b/sway/config.c index 9f65e8a2..0afb0205 100644 --- a/sway/config.c +++ b/sway/config.c @@ -9,6 +9,7 @@ #include "commands.h" #include "config.h" #include "layout.h" +#include "input_state.h" struct sway_config *config; @@ -147,6 +148,8 @@ _continue: bool load_config(const char *file) { sway_log(L_INFO, "Loading config"); + input_init(); + char *path; if (file != NULL) { path = strdup(file); diff --git a/sway/input_state.c b/sway/input_state.c index a7f88d4a..7f312c54 100644 --- a/sway/input_state.c +++ b/sway/input_state.c @@ -8,6 +8,13 @@ static keycode key_state_array[KEY_STATE_MAX_LENGTH]; +void input_init(void) { + int i; + for (i = 0; i < KEY_STATE_MAX_LENGTH; ++i) { + key_state_array[i] = 0; + } +} + static uint8_t find_key(keycode key) { int i; for (i = 0; i < KEY_STATE_MAX_LENGTH; ++i) {