[vlc-commits] xdg-shell: keep the registry object around

Rémi Denis-Courmont git at videolan.org
Sun May 20 19:52:34 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 20 16:11:47 2018 +0300| [e786aaae92fdab54874520856bcbb2c81787c023] | committer: Rémi Denis-Courmont

xdg-shell: keep the registry object around

This is necessary to get hotplug events: output or seat objects may
appear after the initial registry enumeration.

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

 modules/video_output/wayland/xdg-shell.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/modules/video_output/wayland/xdg-shell.c b/modules/video_output/wayland/xdg-shell.c
index e3eae6ec14..31a0d2447f 100644
--- a/modules/video_output/wayland/xdg-shell.c
+++ b/modules/video_output/wayland/xdg-shell.c
@@ -69,6 +69,7 @@
 
 struct vout_window_sys_t
 {
+    struct wl_registry *registry;
     struct wl_compositor *compositor;
     struct xdg_wm_base *wm_base;
     struct xdg_surface *surface;
@@ -349,13 +350,12 @@ static int Open(vout_window_t *wnd, const vout_window_cfg_t *cfg)
     }
 
     /* Find the interesting singleton(s) */
-    struct wl_registry *registry = wl_display_get_registry(display);
-    if (registry == NULL)
+    sys->registry = wl_display_get_registry(display);
+    if (sys->registry == NULL)
         goto error;
 
-    wl_registry_add_listener(registry, &registry_cbs, wnd);
-    wl_display_roundtrip(display);
-    wl_registry_destroy(registry);
+    wl_registry_add_listener(sys->registry, &registry_cbs, wnd);
+    wl_display_roundtrip(display); /* complete registry enumeration */
 
     if (sys->compositor == NULL || sys->wm_base == NULL)
         goto error;
@@ -447,6 +447,8 @@ error:
         xdg_wm_base_destroy(sys->wm_base);
     if (sys->compositor != NULL)
         wl_compositor_destroy(sys->compositor);
+    if (sys->registry != NULL)
+        wl_registry_destroy(sys->registry);
     wl_display_disconnect(display);
     free(sys);
     return VLC_EGENERIC;
@@ -471,6 +473,7 @@ static void Close(vout_window_t *wnd)
     wl_surface_destroy(wnd->handle.wl);
     xdg_wm_base_destroy(sys->wm_base);
     wl_compositor_destroy(sys->compositor);
+    wl_registry_destroy(sys->registry);
     wl_display_disconnect(wnd->display.wl);
     free(sys);
 }



More information about the vlc-commits mailing list