[PATCH xwayland 2/3] xwayland: Refactor surface creation into a separate function

Carlos Garnacho carlosg at gnome.org
Tue Jan 15 22:21:04 UTC 2019


This is just called from xwl_window_realize() ATM, but will be useful in
future commits.

Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
---
 hw/xwayland/xwayland.c | 65 ++++++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 25 deletions(-)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 7f70b950d..279358e07 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -522,7 +522,7 @@ send_surface_id_event(struct xwl_window *xwl_window)
 }
 
 static Bool
-xwl_realize_window(WindowPtr window)
+create_surface_for_window(WindowPtr window)
 {
     ScreenPtr screen = window->drawable.pScreen;
     struct xwl_screen *xwl_screen;
@@ -530,29 +530,10 @@ xwl_realize_window(WindowPtr 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 };
-
-        RegionReset(&window->winSize, &box);
-        RegionNull(&window->clipList);
-        RegionNull(&window->borderClip);
-    }
+    if (xwl_window_get(window))
+        return TRUE;
 
-    if (xwl_screen->rootless) {
-        if (window->redirectDraw != RedirectDrawManual)
-            return ret;
-    }
-    else {
-        if (window->parent)
-            return ret;
-    }
+    xwl_screen = xwl_screen_get(screen);
 
     xwl_window = calloc(1, sizeof *xwl_window);
     if (xwl_window == NULL)
@@ -599,8 +580,6 @@ xwl_realize_window(WindowPtr window)
 
     compRedirectWindow(serverClient, window, CompositeRedirectManual);
 
-    register_damage(window);
-
     dixSetPrivate(&window->devPrivates, &xwl_window_private_key, xwl_window);
     xorg_list_init(&xwl_window->link_damage);
 
@@ -617,6 +596,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 (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);
+    }
+
+    register_damage(window);
+
+    if (xwl_screen->rootless) {
+        if (window->redirectDraw != RedirectDrawManual)
+            return ret;
+    }
+    else {
+        if (window->parent)
+            return ret;
+    }
+
+    return create_surface_for_window(window);
+}
+
 static Bool
 xwl_unrealize_window(WindowPtr window)
 {
-- 
2.19.2



More information about the xorg-devel mailing list