diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-10-23 03:09:38 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-10-23 11:56:29 +0200 |
commit | 9d99bb956fea8922f8e0196d67eabbd510c53f1f (patch) | |
tree | 446b69802f7a1278710bb90d56f017d2d29ff439 /sway/input | |
parent | 5e514e6474754ea6a4b4d1bfc5738457a0fb41cf (diff) |
Fix keymap being NULL and segfaulting on dev add
Moved `libinput_config` to the callers of
`sway_input_configure_libinput_device` so that we send the event after
the added event.
Diffstat (limited to 'sway/input')
-rw-r--r-- | sway/input/input-manager.c | 11 | ||||
-rw-r--r-- | sway/input/libinput.c | 8 |
2 files changed, 12 insertions, 7 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 4a0bce0e..26eefc8a 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c @@ -236,7 +236,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) { apply_input_type_config(input_device); - sway_input_configure_libinput_device(input_device); + bool config_changed = sway_input_configure_libinput_device(input_device); wl_signal_add(&device->events.destroy, &input_device->device_destroy); input_device->device_destroy.notify = handle_device_destroy; @@ -274,6 +274,10 @@ static void handle_new_input(struct wl_listener *listener, void *data) { } ipc_event_input("added", input_device); + + if (config_changed) { + ipc_event_input("libinput_config", input_device); + } } static void handle_inhibit_activate(struct wl_listener *listener, void *data) { @@ -528,11 +532,14 @@ static void retranslate_keysyms(struct input_config *input_config) { static void input_manager_configure_input( struct sway_input_device *input_device) { - sway_input_configure_libinput_device(input_device); + bool config_changed = sway_input_configure_libinput_device(input_device); struct sway_seat *seat = NULL; wl_list_for_each(seat, &server.input->seats, link) { seat_configure_device(seat, input_device); } + if (config_changed) { + ipc_event_input("libinput_config", input_device); + } } void input_manager_configure_all_inputs(void) { diff --git a/sway/input/libinput.c b/sway/input/libinput.c index 3c0f359d..1bac72c9 100644 --- a/sway/input/libinput.c +++ b/sway/input/libinput.c @@ -187,10 +187,10 @@ static bool set_calibration_matrix(struct libinput_device *dev, float mat[6]) { return changed; } -void sway_input_configure_libinput_device(struct sway_input_device *input_device) { +bool sway_input_configure_libinput_device(struct sway_input_device *input_device) { struct input_config *ic = input_device_get_config(input_device); if (!ic || !wlr_input_device_is_libinput(input_device->wlr_device)) { - return; + return false; } struct libinput_device *device = @@ -259,9 +259,7 @@ void sway_input_configure_libinput_device(struct sway_input_device *input_device changed |= set_calibration_matrix(device, ic->calibration_matrix.matrix); } - if (changed) { - ipc_event_input("libinput_config", input_device); - } + return changed; } void sway_input_reset_libinput_device(struct sway_input_device *input_device) { |