From ac07b7605b52b83a3d80962bffb677c2948ff8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Thu, 24 May 2018 18:30:15 +0300 Subject: [PATCH] xdg-shell: handle seat hot-unplug --- modules/video_output/wayland/input.c | 18 ++++++++++++++++++ modules/video_output/wayland/input.h | 1 + modules/video_output/wayland/xdg-shell.c | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/modules/video_output/wayland/input.c b/modules/video_output/wayland/input.c index 8796c6f1f3..eddbd11e02 100644 --- a/modules/video_output/wayland/input.c +++ b/modules/video_output/wayland/input.c @@ -53,6 +53,7 @@ struct seat_data struct xkb_state *keystate; #endif + uint32_t name; uint32_t version; struct wl_list node; }; @@ -443,6 +444,23 @@ static void seat_destroy(struct seat_data *sd) free(sd); } +int seat_destroy_one(struct wl_list *list, uint32_t name) +{ + struct seat_data *sd; + + wl_list_for_each(sd, list, node) + { + if (sd->name == name) + { + seat_destroy(sd); + /* Note: return here so no needs for safe walk variant */ + return 0; + } + } + + return -1; +} + void seat_destroy_all(struct wl_list *list) { while (!wl_list_empty(list)) diff --git a/modules/video_output/wayland/input.h b/modules/video_output/wayland/input.h index 4f618f6614..6c34141f6e 100644 --- a/modules/video_output/wayland/input.h +++ b/modules/video_output/wayland/input.h @@ -24,4 +24,5 @@ struct wl_list; int seat_create(struct vout_window_t *wnd, struct wl_registry *, uint32_t name, uint32_t version, struct wl_list *list); +int seat_destroy_one(struct wl_list *list, uint32_t name); void seat_destroy_all(struct wl_list *list); diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c index 7c82f1b148..40dca03738 100644 --- a/modules/video_output/wayland/xdg-shell.c +++ b/modules/video_output/wayland/xdg-shell.c @@ -445,10 +445,14 @@ static void registry_global_remove_cb(void *data, struct wl_registry *registry, uint32_t name) { vout_window_t *wnd = data; + vout_window_sys_t *sys = wnd->sys; char idstr[11]; msg_Dbg(wnd, "global remove %3"PRIu32, name); + if (seat_destroy_one(&sys->seats, name) == 0) + return; + /* If the global was an output, this will remove it. Otherwise, no-op. */ sprintf(idstr, "%"PRIu32, name); vout_window_ReportOutputDevice(wnd, idstr, NULL); -- GitLab