diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index 41061e3448f038416015c30cb206a5003f2edeeb..919c0a0ca92dcdd17a8d35122f0376af7ea43a73 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -413,6 +413,33 @@ static const struct xdg_surface_listener xdg_surface_listener = { xdg_surface_handle_configure, }; +static void +xwl_window_surface_enter(void *data, + struct wl_surface *wl_surface, + struct wl_output *wl_output) +{ + struct xwl_window *xwl_window = data; + + if (xwl_window->wl_output != wl_output) + xwl_window->wl_output = wl_output; +} + +static void +xwl_window_surface_leave(void *data, + struct wl_surface *wl_surface, + struct wl_output *wl_output) +{ + struct xwl_window *xwl_window = data; + + if (xwl_window->wl_output == wl_output) + xwl_window->wl_output = NULL; +} + +static const struct wl_surface_listener surface_listener = { + xwl_window_surface_enter, + xwl_window_surface_leave +}; + static Bool ensure_surface_for_window(WindowPtr window) { @@ -456,6 +483,9 @@ ensure_surface_for_window(WindowPtr window) goto err_surf; } + wl_surface_add_listener(xwl_window->surface, + &surface_listener, xwl_window); + xdg_surface_add_listener(xwl_window->xdg_surface, &xdg_surface_listener, xwl_window); diff --git a/hw/xwayland/xwayland-window.h b/hw/xwayland/xwayland-window.h index d94f072049bde4d86d6005378c0215158772adfd..9739af17c5d5bde66faa005ff069f5ce70b70b07 100644 --- a/hw/xwayland/xwayland-window.h +++ b/hw/xwayland/xwayland-window.h @@ -51,6 +51,7 @@ struct xwl_window { struct xorg_list window_buffers_available; struct xorg_list window_buffers_unavailable; OsTimerPtr window_buffers_timer; + struct wl_output *wl_output; #ifdef GLAMOR_HAS_GBM struct xorg_list frame_callback_list; Bool present_flipped;