[PATCH weston v2 12/24] xwm: move set_title and set_pid

Pekka Paalanen ppaalanen at gmail.com
Wed Dec 21 14:40:10 UTC 2016


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Move the calls to set_title() and set_pid() out of
weston_wm_window_read_properties() and into the three callers, each
slightly different.

xserver_map_shell_surface(): already calls these functions after
creating the shell surface, so need to add calls.

weston_wm_handle_map_request(): can be called only on unmapped (in X11)
Windows, so no need to add calls.

weston_wm_window_draw_decoration(): window->shsurf and window->surface
are either both set or both NULL, so the check for window->shsurf is
removed when moving the set_title() and set_pid() calls under a
window->surface check.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 xwayland/window-manager.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index e2b1ebf..fb83795 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -456,8 +456,6 @@ static void
 weston_wm_window_read_properties(struct weston_wm_window *window)
 {
 	struct weston_wm *wm = window->wm;
-	const struct weston_desktop_xwayland_interface *xwayland_interface =
-		wm->server->compositor->xwayland_interface;
 
 #define F(field) (&window->field)
 	const struct {
@@ -599,11 +597,6 @@ weston_wm_window_read_properties(struct weston_wm_window *window)
 		if (!window->machine || strcmp(window->machine, name))
 			window->pid = 0;
 	}
-
-	if (window->shsurf && window->name)
-		xwayland_interface->set_title(window->shsurf, window->name);
-	if (window->shsurf && window->pid > 0)
-		xwayland_interface->set_pid(window->shsurf, window->pid);
 }
 
 #undef TYPE_WM_PROTOCOLS
@@ -1027,6 +1020,19 @@ weston_wm_handle_map_request(struct weston_wm *wm, xcb_generic_event_t *event)
 
 	weston_wm_window_read_properties(window);
 
+	/* For a new Window, MapRequest happens before the Window is realized
+	 * in Xwayland. We do the real xcb_map_window() here as a response to
+	 * MapRequest. The Window will get realized (wl_surface created in
+	 * Wayland and WL_SURFACE_ID sent in X11) when it has been mapped for
+	 * real.
+	 *
+	 * MapRequest only happens for (X11) unmapped Windows. On UnmapNotify,
+	 * we reset shsurf to NULL, so even if X11 connection races far ahead
+	 * of the Wayland connection and the X11 client is repeatedly mapping
+	 * and unmapping, we will never have shsurf set on MapRequest.
+	 */
+	assert(!window->shsurf);
+
 	window->map_request_x = window->x;
 	window->map_request_y = window->y;
 
@@ -1190,6 +1196,10 @@ weston_wm_window_draw_decoration(void *data)
 
 		xwayland_interface->set_window_geometry(window->shsurf,
 							input_x, input_y, input_w, input_h);
+		if (window->name)
+			xwayland_interface->set_title(window->shsurf, window->name);
+		if (window->pid > 0)
+			xwayland_interface->set_pid(window->shsurf, window->pid);
 	}
 }
 
-- 
2.10.2



More information about the wayland-devel mailing list