[PATCH 4/4] xwayland: Destroy xwl_output when wl_output gets removed

Dima Ryazanov dima at gmail.com
Tue May 12 10:21:21 PDT 2015


This makes Xwayland correctly handle a monitor getting unplugged.

Signed-off-by: Dima Ryazanov <dima at gmail.com>
---
 hw/xwayland/xwayland-output.c |  1 +
 hw/xwayland/xwayland.c        | 16 ++++++++++++++++
 hw/xwayland/xwayland.h        |  1 +
 3 files changed, 18 insertions(+)

diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 4949363..4ee74fb 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -165,6 +165,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
 
     xwl_output->output = wl_registry_bind(xwl_screen->registry, id,
                                           &wl_output_interface, 2);
+    xwl_output->server_output_id = id;
     wl_output_add_listener(xwl_output->output, &output_listener, xwl_output);
 
     snprintf(name, sizeof name, "XWAYLAND%d", serial++);
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index e99fbac..a763b02 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -379,6 +379,19 @@ xwl_screen_post_damage(struct xwl_screen *xwl_screen)
 }
 
 static void
+xwl_screen_destroy_output(struct xwl_screen *xwl_screen, uint32_t id)
+{
+    struct xwl_output *xwl_output;
+
+    xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
+        if (xwl_output->server_output_id == id) {
+            xwl_output_destroy(xwl_output);
+            break;
+        }
+    }
+}
+
+static void
 registry_global(void *data, struct wl_registry *registry, uint32_t id,
                 const char *interface, uint32_t version)
 {
@@ -429,6 +442,9 @@ global_remove(void *data, struct wl_registry *registry, uint32_t name)
         if (xwl_global->name != name)
             continue;
 
+        if (strcmp(xwl_global->interface, "wl_output") == 0)
+            xwl_screen_destroy_output(xwl_screen, name);
+
         xorg_list_del(&xwl_global->link);
         free(xwl_global->interface);
         free(xwl_global);
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 2ba5312..c4342a4 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -138,6 +138,7 @@ struct xwl_seat {
 struct xwl_output {
     struct xorg_list link;
     struct wl_output *output;
+    uint32_t server_output_id;
     struct xwl_screen *xwl_screen;
     RROutputPtr randr_output;
     RRCrtcPtr randr_crtc;
-- 
2.4.0



More information about the xorg-devel mailing list