diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c index f0b95351d..f21b16de6 100644 --- a/src/wayland/meta-xwayland.c +++ b/src/wayland/meta-xwayland.c @@ -67,6 +67,16 @@ meta_xwayland_associate_window_with_surface (MetaWindow *window, { MetaDisplay *display = window->display; + /* If the window has an existing surface, like if we're + * undecorating or decorating the window, then we need + * to detach the window from its old surface. + */ + if (window->surface) + { + meta_wayland_surface_set_window (window->surface, NULL); + window->surface = NULL; + } + if (!meta_wayland_surface_assign_role (surface, META_TYPE_WAYLAND_SURFACE_ROLE_XWAYLAND, NULL)) @@ -97,16 +107,6 @@ associate_window_with_surface_id (MetaXWaylandManager *manager, { struct wl_resource *resource; - /* If the window has an existing surface, like if we're - * undecorating or decorating the window, then we need - * to detach the window from its old surface. - */ - if (window->surface) - { - meta_wayland_surface_set_window (window->surface, NULL); - window->surface = NULL; - } - resource = wl_client_get_object (manager->client, surface_id); if (resource) {