xwayland: Destroy xwl_output when wl_output gets removed

This makes Xwayland correctly handle a monitor getting unplugged.

[Marek]: use xorg_list_for_each_entry_safe

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
This commit is contained in:
Dima Ryazanov 2015-05-15 22:38:28 -07:00 committed by Marek Chalupa
parent 6ca496b7c3
commit 550984c95e
3 changed files with 12 additions and 1 deletions

View File

@ -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, xwl_output->output = wl_registry_bind(xwl_screen->registry, id,
&wl_output_interface, 2); &wl_output_interface, 2);
xwl_output->server_output_id = id;
wl_output_add_listener(xwl_output->output, &output_listener, xwl_output); wl_output_add_listener(xwl_output->output, &output_listener, xwl_output);
snprintf(name, sizeof name, "XWAYLAND%d", serial++); snprintf(name, sizeof name, "XWAYLAND%d", serial++);

View File

@ -410,7 +410,16 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
static void static void
global_remove(void *data, struct wl_registry *registry, uint32_t name) 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, *tmp_xwl_output;
xorg_list_for_each_entry_safe(xwl_output, tmp_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 = { static const struct wl_registry_listener registry_listener = {

View File

@ -142,6 +142,7 @@ struct xwl_seat {
struct xwl_output { struct xwl_output {
struct xorg_list link; struct xorg_list link;
struct wl_output *output; struct wl_output *output;
uint32_t server_output_id;
struct xwl_screen *xwl_screen; struct xwl_screen *xwl_screen;
RROutputPtr randr_output; RROutputPtr randr_output;
RRCrtcPtr randr_crtc; RRCrtcPtr randr_crtc;