xwayland: move the root window surface to its own function

Currently, when running rootful, the toplevel root surface is created in
the same function as the rest of the Wayland surfaces.

Move it to its own function to improve readability - No function change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Olivier Fourdan 2022-04-28 15:49:51 +02:00
parent c03e582f0c
commit d0466e842a

View File

@ -521,41 +521,12 @@ static const struct wl_surface_listener surface_listener = {
};
static Bool
ensure_surface_for_window(WindowPtr window)
xwl_create_root_surface(struct xwl_window *xwl_window)
{
ScreenPtr screen = window->drawable.pScreen;
struct xwl_screen *xwl_screen;
struct xwl_window *xwl_window;
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
WindowPtr window = xwl_window->window;
struct wl_region *region;
WindowPtr toplevel;
if (xwl_window_from_window(window))
return TRUE;
xwl_screen = xwl_screen_get(screen);
if (xwl_screen->rootless) {
if (window->redirectDraw != RedirectDrawManual)
return TRUE;
}
else {
if (window->parent)
return TRUE;
}
xwl_window = calloc(1, sizeof *xwl_window);
if (xwl_window == NULL)
return FALSE;
xwl_window->xwl_screen = xwl_screen;
xwl_window->window = window;
xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor);
if (xwl_window->surface == NULL) {
ErrorF("wl_display_create_surface failed\n");
goto err;
}
if (!xwl_screen->rootless) {
xwl_window->xdg_surface =
xdg_wm_base_get_xdg_surface(xwl_screen->xdg_wm_base, xwl_window->surface);
if (xwl_window->xdg_surface == NULL) {
@ -588,7 +559,55 @@ ensure_surface_for_window(WindowPtr window)
window->drawable.width, window->drawable.height);
wl_surface_set_opaque_region(xwl_window->surface, region);
wl_region_destroy(region);
return TRUE;
err_surf:
if (xwl_window->xdg_toplevel)
xdg_toplevel_destroy(xwl_window->xdg_toplevel);
if (xwl_window->xdg_surface)
xdg_surface_destroy(xwl_window->xdg_surface);
wl_surface_destroy(xwl_window->surface);
return FALSE;
}
static Bool
ensure_surface_for_window(WindowPtr window)
{
ScreenPtr screen = window->drawable.pScreen;
struct xwl_screen *xwl_screen;
struct xwl_window *xwl_window;
WindowPtr toplevel;
if (xwl_window_from_window(window))
return TRUE;
xwl_screen = xwl_screen_get(screen);
if (xwl_screen->rootless) {
if (window->redirectDraw != RedirectDrawManual)
return TRUE;
}
else {
if (window->parent)
return TRUE;
}
xwl_window = calloc(1, sizeof *xwl_window);
if (xwl_window == NULL)
return FALSE;
xwl_window->xwl_screen = xwl_screen;
xwl_window->window = window;
xwl_window->surface = wl_compositor_create_surface(xwl_screen->compositor);
if (xwl_window->surface == NULL) {
ErrorF("wl_display_create_surface failed\n");
goto err;
}
if (!xwl_screen->rootless && !xwl_create_root_surface(xwl_window))
goto err;
wl_display_flush(xwl_screen->display);
@ -624,12 +643,6 @@ ensure_surface_for_window(WindowPtr window)
return TRUE;
err_surf:
if (xwl_window->xdg_toplevel)
xdg_toplevel_destroy(xwl_window->xdg_toplevel);
if (xwl_window->xdg_surface)
xdg_surface_destroy(xwl_window->xdg_surface);
wl_surface_destroy(xwl_window->surface);
err:
free(xwl_window);
return FALSE;