[PATCH weston] libweston-desktop/xwayland: Make sure racy surfaces are properly mapped

Quentin Glidic sardemff7+wayland at sardemff7.net
Mon May 15 13:29:29 UTC 2017


From: Quentin Glidic <sardemff7+git at sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
 libweston-desktop/xwayland.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index 4f4b453f..4dcb5f03 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -61,6 +61,7 @@ struct weston_desktop_xwayland_surface {
 	const struct weston_xwayland_client_interface *client_interface;
 	struct weston_geometry next_geometry;
 	bool has_next_geometry;
+	bool committed;
 	bool added;
 	enum weston_desktop_xwayland_surface_state state;
 };
@@ -99,6 +100,14 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf
 			weston_desktop_api_surface_added(surface->desktop,
 							 surface->surface);
 			surface->added = true;
+			if (surface->state == NONE && surface->committed)
+				/* We had a race, and wl_surface.commit() was
+				 * faster, just fake a commit to map the
+				 * surface */
+				weston_desktop_api_committed(surface->desktop,
+							     surface->surface,
+							     0, 0);
+
 		} else if (surface->added) {
 			weston_desktop_api_surface_removed(surface->desktop,
 							   surface->surface);
@@ -134,6 +143,7 @@ weston_desktop_xwayland_surface_committed(struct weston_desktop_surface *dsurfac
 	struct weston_geometry oldgeom;
 
 	assert(dsurface == surface->surface);
+	surface->committed = true;
 
 #ifdef WM_DEBUG
 	weston_log("%s: xwayland surface %p\n", __func__, surface);
-- 
2.12.2



More information about the wayland-devel mailing list