[vlc-commits] xdg-shell: handle seat hot-unplug

Rémi Denis-Courmont git at videolan.org
Thu May 24 17:32:16 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 24 18:30:15 2018 +0300| [ac07b7605b52b83a3d80962bffb677c2948ff8ad] | committer: Rémi Denis-Courmont

xdg-shell: handle seat hot-unplug

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac07b7605b52b83a3d80962bffb677c2948ff8ad
---

 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);



More information about the vlc-commits mailing list