[weston,v3,2/3] xwm: use _XWAYLAND_ALLOW_COMMITS

Louis-Francis Ratté-Boulianne lfrb at collabora.com
Tue Apr 11 17:14:10 UTC 2017


On Wed, 2017-01-18 at 15:37 +0200, Pekka Paalanen wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> 
> This patch uses the new feature proposed for Xwayland in the patch
> series https://patchwork.freedesktop.org/series/16610/ .
> 
> When the frame window is created, immediately forbid Xwayland commits
> on
> it. This prevents commits before the decorations have been drawn and
> the
> initial pending state has been set. Commits are enabled right after
> drawing and setting.
> 
> This ensures that the decorations are fully drawn when a window is
> mapped. This also solves the initial commit/pending race, but the
> race
> is on again after mapping.
> 
> If Xwayland does not implement the needed support, we are just
> setting a
> window property with no effect.
> 
> This patch is the final piece for solving T7622, excluding the
> _NET_WM_SYNC_REQUEST handling.
> 
> Task: https://phabricator.freedesktop.org/T7622
> Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

It seems to fix the race just fine.

Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>

> ---
>  xwayland/window-manager.c | 40
> ++++++++++++++++++++++++++++++++++++++--
>  xwayland/xwayland.h       |  1 +
>  2 files changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
> index ac875a3..2608075 100644
> --- a/xwayland/window-manager.c
> +++ b/xwayland/window-manager.c
> @@ -873,6 +873,37 @@ weston_wm_window_activate(struct wl_listener
> *listener, void *data)
>  
>  }
>  
> +/** Control Xwayland wl_surface.commit behaviour
> + *
> + * This function sets the "_XWAYLAND_ALLOW_COMMITS" property of the
> frame window
> + * (not the content window!) to \p allow.
> + *
> + * If the property is set to \c true, Xwayland will commit whenever
> it likes.
> + * If the property is set to \c false, Xwayland will not commit.
> + * If the property is not set at all, Xwayland assumes it is \c
> true.
> + *
> + * \param window The XWM window to control.
> + * \param allow Whether Xwayland is allowed to wl_surface.commit for
> the window.
> + */
> +static void
> +weston_wm_window_set_allow_commits(struct weston_wm_window *window,
> bool allow)
> +{
> +	struct weston_wm *wm = window->wm;
> +	uint32_t property[1];
> +
> +	assert(window->frame_id != XCB_WINDOW_NONE);
> +
> +	property[0] = allow ? 1 : 0;
> +
> +	xcb_change_property(wm->conn,
> +			    XCB_PROP_MODE_REPLACE,
> +			    window->frame_id,
> +			    wm->atom.allow_commits,
> +			    XCB_ATOM_CARDINAL,
> +			    32, /* format */
> +			    1, property);
> +}
> +
>  #define ICCCM_WITHDRAWN_STATE	0
>  #define ICCCM_NORMAL_STATE	1
>  #define ICCCM_ICONIC_STATE	3
> @@ -1048,6 +1079,7 @@ weston_wm_handle_map_request(struct weston_wm
> *wm, xcb_generic_event_t *event)
>  	       window->width, window->height,
>  	       window->map_request_x, window->map_request_y);
>  
> +	weston_wm_window_set_allow_commits(window, false);
>  	weston_wm_window_set_wm_state(window, ICCCM_NORMAL_STATE);
>  	weston_wm_window_set_net_wm_state(window);
>  	weston_wm_window_set_virtual_desktop(window, 0);
> @@ -2220,6 +2252,7 @@ weston_wm_get_resources(struct weston_wm *wm)
>  		{ "XdndFinished",	F(atom.xdnd_finished) },
>  		{ "XdndTypeList",	F(atom.xdnd_type_list) },
>  		{ "XdndActionCopy",	F(atom.xdnd_action_copy)
> },
> +		{ "_XWAYLAND_ALLOW_COMMITS",	F(atom.allow_com
> mits) },
>  		{ "WL_SURFACE_ID",	F(atom.wl_surface_id) }
>  	};
>  #undef F
> @@ -2741,10 +2774,13 @@ xserver_map_shell_surface(struct
> weston_wm_window *window,
>  		}
>  	}
>  
> -	if (window->frame_id == XCB_WINDOW_NONE)
> +	if (window->frame_id == XCB_WINDOW_NONE) {
>  		weston_wm_window_set_pending_state_OR(window);
> -	else
> +	} else {
>  		weston_wm_window_set_pending_state(window);
> +		weston_wm_window_set_allow_commits(window, true);
> +		xcb_flush(wm->conn);
> +	}
>  }
>  
>  const struct weston_xwayland_surface_api surface_api = {
> diff --git a/xwayland/xwayland.h b/xwayland/xwayland.h
> index b1225f5..ca75f5b 100644
> --- a/xwayland/xwayland.h
> +++ b/xwayland/xwayland.h
> @@ -154,6 +154,7 @@ struct weston_wm {
>  		xcb_atom_t		 xdnd_type_list;
>  		xcb_atom_t		 xdnd_action_copy;
>  		xcb_atom_t		 wl_surface_id;
> +		xcb_atom_t		 allow_commits;
>  	} atom;
>  };
>  


More information about the wayland-devel mailing list