summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2019-01-07 15:33:31 +0100
committerOlivier Fourdan <ofourdan@redhat.com>2019-09-10 14:50:57 +0200
commit12db645c7fc0539752a881df7ac2bcd09e3cb17b (patch)
tree7526581da572843ad3593ab41d23dadb525512ac
parente0af09061f9e8397ca564ec3bbedea51974455d4 (diff)
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 <carlosg@gnome.org> (cherry picked from commit c2e8ae964052944312c5023ca7ea5c41a92990e5)
-rw-r--r--hw/xwayland/xwayland.c64
1 files 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)
@@ -615,6 +601,42 @@ err:
}
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)
{
ScreenPtr screen = window->drawable.pScreen;