[PATCH weston 1/2] libweston-desktop/xdg_shell_v6: Add surface as needed

Quentin Glidic sardemff7+wayland at sardemff7.net
Sun Sep 11 09:36:29 UTC 2016


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

Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
---
This is a temporary fix, as xdg_shell v6 initial configure will help us
doing a better job. However this requires an ABI/API break, so we'll wait
for the next release cycle.

 libweston-desktop/xdg-shell-v6.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index 70e9132..fbf3e69 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -283,6 +283,18 @@ static const struct zxdg_positioner_v6_interface weston_desktop_xdg_positioner_i
 static void
 weston_desktop_xdg_surface_schedule_configure(struct weston_desktop_xdg_surface *surface);
 
+static void
+weston_desktop_xdg_toplevel_ensure_added(struct weston_desktop_xdg_toplevel *toplevel)
+{
+	if (toplevel->added)
+		return;
+
+	weston_desktop_api_surface_added(toplevel->base.desktop,
+					 toplevel->base.desktop_surface);
+	weston_desktop_xdg_surface_schedule_configure(&toplevel->base);
+	toplevel->added = true;
+}
+
 static void
 weston_desktop_xdg_toplevel_protocol_set_parent(struct wl_client *wl_client,
 						struct wl_resource *resource,
@@ -296,6 +308,8 @@ weston_desktop_xdg_toplevel_protocol_set_parent(struct wl_client *wl_client,
 
 	if (parent_resource != NULL)
 		parent = wl_resource_get_user_data(parent_resource);
+
+	weston_desktop_xdg_toplevel_ensure_added(toplevel);
 	weston_desktop_api_set_parent(toplevel->base.desktop, dsurface, parent);
 }
 
@@ -416,6 +430,7 @@ weston_desktop_xdg_toplevel_protocol_set_maximized(struct wl_client *wl_client,
 	struct weston_desktop_xdg_toplevel *toplevel =
 		weston_desktop_surface_get_implementation_data(dsurface);
 
+	weston_desktop_xdg_toplevel_ensure_added(toplevel);
 	weston_desktop_api_maximized_requested(toplevel->base.desktop, dsurface, true);
 }
 
@@ -428,6 +443,7 @@ weston_desktop_xdg_toplevel_protocol_unset_maximized(struct wl_client *wl_client
 	struct weston_desktop_xdg_toplevel *toplevel =
 		weston_desktop_surface_get_implementation_data(dsurface);
 
+	weston_desktop_xdg_toplevel_ensure_added(toplevel);
 	weston_desktop_api_maximized_requested(toplevel->base.desktop, dsurface, false);
 }
 
@@ -445,6 +461,7 @@ weston_desktop_xdg_toplevel_protocol_set_fullscreen(struct wl_client *wl_client,
 	if (output_resource != NULL)
 		output = wl_resource_get_user_data(output_resource);
 
+	weston_desktop_xdg_toplevel_ensure_added(toplevel);
 	weston_desktop_api_fullscreen_requested(toplevel->base.desktop, dsurface,
 						true, output);
 }
@@ -458,6 +475,7 @@ weston_desktop_xdg_toplevel_protocol_unset_fullscreen(struct wl_client *wl_clien
 	struct weston_desktop_xdg_toplevel *toplevel =
 		weston_desktop_surface_get_implementation_data(dsurface);
 
+	weston_desktop_xdg_toplevel_ensure_added(toplevel);
 	weston_desktop_api_fullscreen_requested(toplevel->base.desktop, dsurface,
 						false, NULL);
 }
@@ -471,6 +489,7 @@ weston_desktop_xdg_toplevel_protocol_set_minimized(struct wl_client *wl_client,
 	struct weston_desktop_xdg_toplevel *toplevel =
 		weston_desktop_surface_get_implementation_data(dsurface);
 
+	weston_desktop_xdg_toplevel_ensure_added(toplevel);
 	weston_desktop_api_minimized_requested(toplevel->base.desktop, dsurface);
 }
 
@@ -584,10 +603,7 @@ weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel *toplev
 	bool reconfigure = false;
 
 	if (!wsurface->buffer_ref.buffer && !toplevel->added) {
-		weston_desktop_api_surface_added(toplevel->base.desktop,
-					         toplevel->base.desktop_surface);
-		weston_desktop_xdg_surface_schedule_configure(&toplevel->base);
-		toplevel->added = true;
+		weston_desktop_xdg_toplevel_ensure_added(toplevel);
 		return;
 	}
 	if (!wsurface->buffer_ref.buffer)
-- 
2.10.0



More information about the wayland-devel mailing list