summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Yaroslav de la Peña Smirnov <yps@yaroslavps.com>2022-10-23 03:09:38 +0300
committerLibravatar Simon Ser <contact@emersion.fr>2022-10-23 11:56:29 +0200
commit9d99bb956fea8922f8e0196d67eabbd510c53f1f (patch)
tree446b69802f7a1278710bb90d56f017d2d29ff439
parentinput: tweak focus behavior to allow focusing parent containers (diff)
downloadsway-9d99bb956fea8922f8e0196d67eabbd510c53f1f.tar.gz
sway-9d99bb956fea8922f8e0196d67eabbd510c53f1f.tar.zst
sway-9d99bb956fea8922f8e0196d67eabbd510c53f1f.zip
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.
-rw-r--r--include/sway/input/libinput.h2
-rw-r--r--sway/input/input-manager.c11
-rw-r--r--sway/input/libinput.c8
3 files changed, 13 insertions, 8 deletions
diff --git a/include/sway/input/libinput.h b/include/sway/input/libinput.h
index 890d632e..e4b1acc3 100644
--- a/include/sway/input/libinput.h
+++ b/include/sway/input/libinput.h
@@ -2,7 +2,7 @@
2#define _SWAY_INPUT_LIBINPUT_H 2#define _SWAY_INPUT_LIBINPUT_H
3#include "sway/input/input-manager.h" 3#include "sway/input/input-manager.h"
4 4
5void sway_input_configure_libinput_device(struct sway_input_device *device); 5bool sway_input_configure_libinput_device(struct sway_input_device *device);
6 6
7void sway_input_reset_libinput_device(struct sway_input_device *device); 7void sway_input_reset_libinput_device(struct sway_input_device *device);
8 8
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) {
236 236
237 apply_input_type_config(input_device); 237 apply_input_type_config(input_device);
238 238
239 sway_input_configure_libinput_device(input_device); 239 bool config_changed = sway_input_configure_libinput_device(input_device);
240 240
241 wl_signal_add(&device->events.destroy, &input_device->device_destroy); 241 wl_signal_add(&device->events.destroy, &input_device->device_destroy);
242 input_device->device_destroy.notify = handle_device_destroy; 242 input_device->device_destroy.notify = handle_device_destroy;
@@ -274,6 +274,10 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
274 } 274 }
275 275
276 ipc_event_input("added", input_device); 276 ipc_event_input("added", input_device);
277
278 if (config_changed) {
279 ipc_event_input("libinput_config", input_device);
280 }
277} 281}
278 282
279static void handle_inhibit_activate(struct wl_listener *listener, void *data) { 283static void handle_inhibit_activate(struct wl_listener *listener, void *data) {
@@ -528,11 +532,14 @@ static void retranslate_keysyms(struct input_config *input_config) {
528 532
529static void input_manager_configure_input( 533static void input_manager_configure_input(
530 struct sway_input_device *input_device) { 534 struct sway_input_device *input_device) {
531 sway_input_configure_libinput_device(input_device); 535 bool config_changed = sway_input_configure_libinput_device(input_device);
532 struct sway_seat *seat = NULL; 536 struct sway_seat *seat = NULL;
533 wl_list_for_each(seat, &server.input->seats, link) { 537 wl_list_for_each(seat, &server.input->seats, link) {
534 seat_configure_device(seat, input_device); 538 seat_configure_device(seat, input_device);
535 } 539 }
540 if (config_changed) {
541 ipc_event_input("libinput_config", input_device);
542 }
536} 543}
537 544
538void input_manager_configure_all_inputs(void) { 545void 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]) {
187 return changed; 187 return changed;
188} 188}
189 189
190void sway_input_configure_libinput_device(struct sway_input_device *input_device) { 190bool sway_input_configure_libinput_device(struct sway_input_device *input_device) {
191 struct input_config *ic = input_device_get_config(input_device); 191 struct input_config *ic = input_device_get_config(input_device);
192 if (!ic || !wlr_input_device_is_libinput(input_device->wlr_device)) { 192 if (!ic || !wlr_input_device_is_libinput(input_device->wlr_device)) {
193 return; 193 return false;
194 } 194 }
195 195
196 struct libinput_device *device = 196 struct libinput_device *device =
@@ -259,9 +259,7 @@ void sway_input_configure_libinput_device(struct sway_input_device *input_device
259 changed |= set_calibration_matrix(device, ic->calibration_matrix.matrix); 259 changed |= set_calibration_matrix(device, ic->calibration_matrix.matrix);
260 } 260 }
261 261
262 if (changed) { 262 return changed;
263 ipc_event_input("libinput_config", input_device);
264 }
265} 263}
266 264
267void sway_input_reset_libinput_device(struct sway_input_device *input_device) { 265void sway_input_reset_libinput_device(struct sway_input_device *input_device) {