[PATCH weston 7/7] WIP xwayland: poke _XWAYLAND_ALLOW_COMMITS

Pekka Paalanen ppaalanen at gmail.com
Tue Nov 29 15:11:15 UTC 2016


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

No more jumping windows on map.

This patch uses the new feature added to Xwayland in the patch series
https://patchwork.freedesktop.org/series/15904/

When the frame window is created, immediately forbid Xwayland commits on
it. This prevents commits before the decorations have been drawn and
geometry is set. Commits are enabled right after drawing and setting.

If Xwayland does not implement the needed support, we are just setting a
window property with no effect.
---
 xwayland/window-manager.c | 38 ++++++++++++++++++++++++++++++++++++++
 xwayland/xwayland.h       |  1 +
 2 files changed, 39 insertions(+)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 10bb390..c1edd02 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -36,6 +36,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <limits.h>
+#include <assert.h>
 #include <X11/Xcursor/Xcursor.h>
 #include <linux/input.h>
 
@@ -818,6 +819,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
@@ -916,6 +948,8 @@ weston_wm_window_create_frame(struct weston_wm_window *window)
 	xcb_configure_window(wm->conn, window->id,
 			     XCB_CONFIG_WINDOW_BORDER_WIDTH, values);
 
+	weston_wm_window_set_allow_commits(window, false);
+
 	window->cairo_surface =
 		cairo_xcb_surface_create_with_xrender_format(wm->conn,
 							     wm->screen,
@@ -1123,6 +1157,9 @@ weston_wm_window_draw_decoration(void *data)
 
 		xwayland_interface->set_window_geometry(window->shsurf,
 							input_x, input_y, input_w, input_h);
+
+		weston_wm_window_set_allow_commits(window, true);
+		xcb_flush(wm->conn);
 	}
 }
 
@@ -2105,6 +2142,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_commits) },
 		{ "WL_SURFACE_ID",	F(atom.wl_surface_id) }
 	};
 #undef F
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;
 };
 
-- 
2.7.3



More information about the wayland-devel mailing list