dont copy input config

This commit is contained in:
Tony Crisci 2018-04-02 13:19:58 -04:00
parent 35445b40a2
commit 22287b42bf
3 changed files with 20 additions and 18 deletions

View file

@ -14,7 +14,6 @@ extern struct sway_input_manager *input_manager;
struct sway_input_device { struct sway_input_device {
char *identifier; char *identifier;
struct wlr_input_device *wlr_device; struct wlr_input_device *wlr_device;
struct input_config *config;
struct wl_list link; struct wl_list link;
struct wl_listener device_destroy; 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, struct sway_seat *input_manager_get_seat(struct sway_input_manager *input,
const char *seat_name); 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 sway_seat *input_manager_current_seat(struct sway_input_manager *input);
struct input_config *input_device_get_config(struct sway_input_device *device);
#endif #endif

View file

@ -95,7 +95,7 @@ static bool input_has_seat_configuration(struct sway_input_manager *input) {
static void input_manager_libinput_config_pointer( static void input_manager_libinput_config_pointer(
struct sway_input_device *input_device) { struct sway_input_device *input_device) {
struct wlr_input_device *wlr_device = input_device->wlr_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; struct libinput_device *libinput_device;
if (!ic || !wlr_input_device_is_libinput(wlr_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->link);
wl_list_remove(&input_device->device_destroy.link); wl_list_remove(&input_device->device_destroy.link);
free_input_config(input_device->config);
free(input_device->identifier); free(input_device->identifier);
free(input_device); 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'", wlr_log(L_DEBUG, "adding device: '%s'",
input_device->identifier); 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) { if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
input_manager_libinput_config_pointer(input_device); 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; struct sway_input_device *input_device = NULL;
wl_list_for_each(input_device, &input->devices, link) { wl_list_for_each(input_device, &input->devices, link) {
if (strcmp(input_device->identifier, input_config->identifier) == 0) { 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) { if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) {
input_manager_libinput_config_pointer(input_device); input_manager_libinput_config_pointer(input_device);
} }
@ -410,3 +396,15 @@ struct sway_seat *input_manager_get_default_seat(
} }
return 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;
}

View file

@ -428,7 +428,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) {
struct xkb_rule_names rules; struct xkb_rule_names rules;
memset(&rules, 0, sizeof(rules)); memset(&rules, 0, sizeof(rules));
struct input_config *input_config = 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 = struct wlr_input_device *wlr_device =
keyboard->seat_device->input_device->wlr_device; keyboard->seat_device->input_device->wlr_device;