From 12db645c7fc0539752a881df7ac2bcd09e3cb17b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 7 Jan 2019 15:33:31 +0100 Subject: [PATCH xserver 14/15] xwayland: Refactor surface creation into a separate function This is just called from xwl_window_realize() ATM, but will be useful in future commits. Signed-off-by: Carlos Garnacho (cherry picked from commit c2e8ae964052944312c5023ca7ea5c41a92990e5) --- hw/xwayland/xwayland.c | 64 ++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c index 1efebd061..9a4b52fa9 100644 --- a/hw/xwayland/xwayland.c +++ b/hw/xwayland/xwayland.c @@ -518,36 +518,25 @@ send_surface_id_event(struct xwl_window *xwl_window) } static Bool -xwl_realize_window(WindowPtr window) +ensure_surface_for_window(WindowPtr window) { ScreenPtr screen = window->drawable.pScreen; struct xwl_screen *xwl_screen; struct xwl_window *xwl_window; struct wl_region *region; - Bool ret; - - xwl_screen = xwl_screen_get(screen); - - screen->RealizeWindow = xwl_screen->RealizeWindow; - ret = (*screen->RealizeWindow) (window); - xwl_screen->RealizeWindow = screen->RealizeWindow; - screen->RealizeWindow = xwl_realize_window; - if (xwl_screen->rootless && !window->parent) { - BoxRec box = { 0, 0, xwl_screen->width, xwl_screen->height }; + if (xwl_window_get(window)) + return TRUE; - RegionReset(&window->winSize, &box); - RegionNull(&window->clipList); - RegionNull(&window->borderClip); - } + xwl_screen = xwl_screen_get(screen); if (xwl_screen->rootless) { if (window->redirectDraw != RedirectDrawManual) - return ret; + return TRUE; } else { if (window->parent) - return ret; + return TRUE; } xwl_window = calloc(1, sizeof *xwl_window); @@ -595,15 +584,12 @@ xwl_realize_window(WindowPtr window) compRedirectWindow(serverClient, window, CompositeRedirectManual); - if (!register_damage(window)) - goto err_surf; - dixSetPrivate(&window->devPrivates, &xwl_window_private_key, xwl_window); xorg_list_init(&xwl_window->link_damage); xwl_window_init_allow_commits(xwl_window); - return ret; + return TRUE; err_surf: if (xwl_window->shell_surface) @@ -614,6 +600,42 @@ err: return FALSE; } +static Bool +xwl_realize_window(WindowPtr window) +{ + ScreenPtr screen = window->drawable.pScreen; + struct xwl_screen *xwl_screen; + Bool ret; + + xwl_screen = xwl_screen_get(screen); + + screen->RealizeWindow = xwl_screen->RealizeWindow; + ret = (*screen->RealizeWindow) (window); + xwl_screen->RealizeWindow = screen->RealizeWindow; + screen->RealizeWindow = xwl_realize_window; + + if (!ret) + return FALSE; + + if (xwl_screen->rootless && !window->parent) { + BoxRec box = { 0, 0, xwl_screen->width, xwl_screen->height }; + + RegionReset(&window->winSize, &box); + RegionNull(&window->clipList); + RegionNull(&window->borderClip); + } + + if (xwl_screen->rootless ? + (window->drawable.class == InputOutput && + window->parent == window->drawable.pScreen->root) : + !window->parent) { + if (!register_damage(window)) + return FALSE; + } + + return ensure_surface_for_window(window); +} + static Bool xwl_unrealize_window(WindowPtr window) { -- 2.21.0