[weston v2 7/8] xwayland: Fix the race condition when mapping a surface
Tomeu Vizoso
tomeu at tomeuvizoso.net
Wed Jul 3 06:58:21 PDT 2013
From: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Make sure XCB_MAP_NOTIFY has been received and the window id has been
set before mapping the shell surface. It fixes race condition making the
surface appears at wrong coordinates or with wrong size.
---
src/xwayland/window-manager.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/xwayland/window-manager.c b/src/xwayland/window-manager.c
index ff2d4e6..792e09c 100644
--- a/src/xwayland/window-manager.c
+++ b/src/xwayland/window-manager.c
@@ -116,6 +116,7 @@ struct weston_wm_window {
int decorate;
int override_redirect;
int fullscreen;
+ int mapped;
};
static struct weston_wm_window *
@@ -124,6 +125,9 @@ get_wm_window(struct weston_surface *surface);
static void
weston_wm_window_schedule_repaint(struct weston_wm_window *window);
+static void
+xserver_map_shell_surface(struct weston_wm *wm, struct weston_wm_window *window);
+
static int __attribute__ ((format (printf, 1, 2)))
wm_log(const char *fmt, ...)
{
@@ -158,7 +162,6 @@ wm_log_continue(const char *fmt, ...)
#endif
}
-
const char *
get_atom_name(xcb_connection_t *c, xcb_atom_t atom)
{
@@ -803,6 +806,14 @@ static void
weston_wm_handle_map_notify(struct weston_wm *wm, xcb_generic_event_t *event)
{
xcb_map_notify_event_t *map_notify = (xcb_map_notify_event_t *) event;
+ struct weston_wm_window *window;
+
+ window = hash_table_lookup(wm->window_hash, map_notify->window);
+
+ if (window->surface != NULL)
+ xserver_map_shell_surface(wm, window);
+ else
+ window->mapped = 1;
if (our_resource(wm, map_notify->window)) {
wm_log("XCB_MAP_NOTIFY (window %d, ours)\n",
@@ -994,6 +1005,8 @@ weston_wm_window_create(struct weston_wm *wm,
window->override_redirect = override;
window->width = width;
window->height = height;
+ window->surface = NULL;
+ window->mapped = 0;
hash_table_insert(wm->window_hash, id, window);
}
@@ -1937,7 +1950,9 @@ xserver_set_window_id(struct wl_client *client, struct wl_resource *resource,
&window->surface_destroy_listener);
weston_wm_window_schedule_repaint(window);
- xserver_map_shell_surface(wm, window);
+
+ if (window->mapped)
+ xserver_map_shell_surface(wm, window);
}
const struct xserver_interface xserver_implementation = {
--
1.8.3.1
More information about the wayland-devel
mailing list