aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar Andri Yngvason <andri@yngvason.is>2020-01-03 15:38:29 +0000
committerLibravatar Simon Ser <contact@emersion.fr>2020-01-05 19:57:05 +0100
commitfd24b1afd874d6da8ae603c1d0919078803f132d (patch)
tree3f1a6631c2995c2abdfa57dbfc12d0c28ad03296 /swaybar
parentswaynag: Add multi-seat support (diff)
downloadsway-fd24b1afd874d6da8ae603c1d0919078803f132d.tar.gz
sway-fd24b1afd874d6da8ae603c1d0919078803f132d.tar.zst
sway-fd24b1afd874d6da8ae603c1d0919078803f132d.zip
swaybar: Fix input device removal
Before swaybar would exit with a protocol error when a pointer or touch device was removed.
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/input.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/swaybar/input.c b/swaybar/input.c
index 8b83eab4..7f68caec 100644
--- a/swaybar/input.c
+++ b/swaybar/input.c
@@ -405,15 +405,14 @@ static const struct wl_touch_listener touch_listener = {
405static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat, 405static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
406 enum wl_seat_capability caps) { 406 enum wl_seat_capability caps) {
407 struct swaybar_seat *seat = data; 407 struct swaybar_seat *seat = data;
408 if (seat->pointer.pointer != NULL) { 408
409 bool have_pointer = caps & WL_SEAT_CAPABILITY_POINTER;
410 bool have_touch = caps & WL_SEAT_CAPABILITY_TOUCH;
411
412 if (!have_pointer && seat->pointer.pointer != NULL) {
409 wl_pointer_release(seat->pointer.pointer); 413 wl_pointer_release(seat->pointer.pointer);
410 seat->pointer.pointer = NULL; 414 seat->pointer.pointer = NULL;
411 } 415 } else if (have_pointer && seat->pointer.pointer == NULL) {
412 if (seat->touch.touch != NULL) {
413 wl_touch_release(seat->touch.touch);
414 seat->touch.touch = NULL;
415 }
416 if ((caps & WL_SEAT_CAPABILITY_POINTER)) {
417 seat->pointer.pointer = wl_seat_get_pointer(wl_seat); 416 seat->pointer.pointer = wl_seat_get_pointer(wl_seat);
418 if (seat->bar->running && !seat->pointer.cursor_surface) { 417 if (seat->bar->running && !seat->pointer.cursor_surface) {
419 seat->pointer.cursor_surface = 418 seat->pointer.cursor_surface =
@@ -422,7 +421,10 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
422 } 421 }
423 wl_pointer_add_listener(seat->pointer.pointer, &pointer_listener, seat); 422 wl_pointer_add_listener(seat->pointer.pointer, &pointer_listener, seat);
424 } 423 }
425 if ((caps & WL_SEAT_CAPABILITY_TOUCH)) { 424 if (!have_touch && seat->touch.touch != NULL) {
425 wl_touch_release(seat->touch.touch);
426 seat->touch.touch = NULL;
427 } else if (have_touch && seat->touch.touch == NULL) {
426 seat->touch.touch = wl_seat_get_touch(wl_seat); 428 seat->touch.touch = wl_seat_get_touch(wl_seat);
427 wl_touch_add_listener(seat->touch.touch, &touch_listener, seat); 429 wl_touch_add_listener(seat->touch.touch, &touch_listener, seat);
428 } 430 }