From 22287b42bf323457d779b1023764ade83313b199 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Mon, 2 Apr 2018 13:19:58 -0400 Subject: [PATCH] dont copy input config --- include/sway/input/input-manager.h | 8 ++++++-- sway/input/input-manager.c | 28 +++++++++++++--------------- sway/input/keyboard.c | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 8515c7385..8e39a4a7a 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -14,7 +14,6 @@ extern struct sway_input_manager *input_manager; struct sway_input_device { char *identifier; struct wlr_input_device *wlr_device; - struct input_config *config; struct wl_list link; struct wl_listener device_destroy; }; @@ -49,7 +48,12 @@ struct sway_seat *input_manager_get_default_seat( struct sway_seat *input_manager_get_seat(struct sway_input_manager *input, const char *seat_name); -/** Gets the last seat the user interacted with */ +/** + * Gets the last seat the user interacted with + */ struct sway_seat *input_manager_current_seat(struct sway_input_manager *input); +struct input_config *input_device_get_config(struct sway_input_device *device); + + #endif diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 34d5b4cf7..34aed1154 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -95,7 +95,7 @@ static bool input_has_seat_configuration(struct sway_input_manager *input) { static void input_manager_libinput_config_pointer( struct sway_input_device *input_device) { struct wlr_input_device *wlr_device = input_device->wlr_device; - struct input_config *ic = input_device->config; + struct input_config *ic = input_device_get_config(input_device); struct libinput_device *libinput_device; if (!ic || !wlr_input_device_is_libinput(wlr_device)) { @@ -196,7 +196,6 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&input_device->link); wl_list_remove(&input_device->device_destroy.link); - free_input_config(input_device->config); free(input_device->identifier); free(input_device); } @@ -219,16 +218,6 @@ static void handle_new_input(struct wl_listener *listener, void *data) { wlr_log(L_DEBUG, "adding device: '%s'", input_device->identifier); - // find config - for (int i = 0; i < config->input_configs->length; ++i) { - struct input_config *input_config = config->input_configs->items[i]; - if (strcmp(input_config->identifier, input_device->identifier) == 0) { - free_input_config(input_device->config); - input_device->config = copy_input_config(input_config); - break; - } - } - if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { input_manager_libinput_config_pointer(input_device); } @@ -320,9 +309,6 @@ void input_manager_apply_input_config(struct sway_input_manager *input, struct sway_input_device *input_device = NULL; wl_list_for_each(input_device, &input->devices, link) { if (strcmp(input_device->identifier, input_config->identifier) == 0) { - free_input_config(input_device->config); - input_device->config = copy_input_config(input_config); - if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { input_manager_libinput_config_pointer(input_device); } @@ -410,3 +396,15 @@ struct sway_seat *input_manager_get_default_seat( } return seat; } + +struct input_config *input_device_get_config(struct sway_input_device *device) { + struct input_config *input_config = NULL; + for (int i = 0; i < config->input_configs->length; ++i) { + input_config = config->input_configs->items[i]; + if (strcmp(input_config->identifier, device->identifier) == 0) { + return input_config; + } + } + + return NULL; +} diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 996850525..410686529 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c @@ -428,7 +428,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { struct xkb_rule_names rules; memset(&rules, 0, sizeof(rules)); struct input_config *input_config = - keyboard->seat_device->input_device->config; + input_device_get_config(keyboard->seat_device->input_device); struct wlr_input_device *wlr_device = keyboard->seat_device->input_device->wlr_device;