Skip to content
Snippets Groups Projects
Commit d0466e84 authored by Olivier Fourdan's avatar Olivier Fourdan :tools:
Browse files

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: default avatarOlivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
parent c03e582f
No related merge requests found
...@@ -520,13 +520,64 @@ static const struct wl_surface_listener surface_listener = { ...@@ -520,13 +520,64 @@ static const struct wl_surface_listener surface_listener = {
xwl_window_surface_leave xwl_window_surface_leave
}; };
static Bool
xwl_create_root_surface(struct xwl_window *xwl_window)
{
struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
WindowPtr window = xwl_window->window;
struct wl_region *region;
xwl_window->xdg_surface =
xdg_wm_base_get_xdg_surface(xwl_screen->xdg_wm_base, xwl_window->surface);
if (xwl_window->xdg_surface == NULL) {
ErrorF("Failed creating xdg_wm_base xdg_surface\n");
goto err_surf;
}
xwl_window->xdg_toplevel =
xdg_surface_get_toplevel(xwl_window->xdg_surface);
if (xwl_window->xdg_surface == NULL) {
ErrorF("Failed creating xdg_toplevel\n");
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);
wl_surface_commit(xwl_window->surface);
region = wl_compositor_create_region(xwl_screen->compositor);
if (region == NULL) {
ErrorF("Failed creating region\n");
goto err_surf;
}
wl_region_add(region, 0, 0,
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 static Bool
ensure_surface_for_window(WindowPtr window) ensure_surface_for_window(WindowPtr window)
{ {
ScreenPtr screen = window->drawable.pScreen; ScreenPtr screen = window->drawable.pScreen;
struct xwl_screen *xwl_screen; struct xwl_screen *xwl_screen;
struct xwl_window *xwl_window; struct xwl_window *xwl_window;
struct wl_region *region;
WindowPtr toplevel; WindowPtr toplevel;
if (xwl_window_from_window(window)) if (xwl_window_from_window(window))
...@@ -555,40 +606,8 @@ ensure_surface_for_window(WindowPtr window) ...@@ -555,40 +606,8 @@ ensure_surface_for_window(WindowPtr window)
goto err; goto err;
} }
if (!xwl_screen->rootless) { if (!xwl_screen->rootless && !xwl_create_root_surface(xwl_window))
xwl_window->xdg_surface = goto err;
xdg_wm_base_get_xdg_surface(xwl_screen->xdg_wm_base, xwl_window->surface);
if (xwl_window->xdg_surface == NULL) {
ErrorF("Failed creating xdg_wm_base xdg_surface\n");
goto err_surf;
}
xwl_window->xdg_toplevel =
xdg_surface_get_toplevel(xwl_window->xdg_surface);
if (xwl_window->xdg_surface == NULL) {
ErrorF("Failed creating xdg_toplevel\n");
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);
wl_surface_commit(xwl_window->surface);
region = wl_compositor_create_region(xwl_screen->compositor);
if (region == NULL) {
ErrorF("Failed creating region\n");
goto err_surf;
}
wl_region_add(region, 0, 0,
window->drawable.width, window->drawable.height);
wl_surface_set_opaque_region(xwl_window->surface, region);
wl_region_destroy(region);
}
wl_display_flush(xwl_screen->display); wl_display_flush(xwl_screen->display);
...@@ -624,12 +643,6 @@ ensure_surface_for_window(WindowPtr window) ...@@ -624,12 +643,6 @@ ensure_surface_for_window(WindowPtr window)
return TRUE; 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: err:
free(xwl_window); free(xwl_window);
return FALSE; return FALSE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment