[PATCH v2 3/3] xwayland: Destroy xwl_output when wl_output gets removed
Dima Ryazanov
dima at gmail.com
Fri May 15 22:38:28 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 | 10 +++++++++-
hw/xwayland/xwayland.h | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c
index 41937b8..9ef8a48 100644
--- a/hw/xwayland/xwayland-output.c
+++ b/hw/xwayland/xwayland-output.c
@@ -163,6 +163,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 7e8d667..7c2eaed 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -410,7 +410,15 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
static void
global_remove(void *data, struct wl_registry *registry, uint32_t name)
{
- /* Nothing to do here, wl_compositor and wl_shm should not be removed */
+ struct xwl_screen *xwl_screen = data;
+ struct xwl_output *xwl_output;
+
+ xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
+ if (xwl_output->server_output_id == name) {
+ xwl_output_destroy(xwl_output);
+ break;
+ }
+ }
}
static const struct wl_registry_listener registry_listener = {
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index cfb343d..70875e7 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -130,6 +130,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 wayland-devel
mailing list