[PATCH] fullscreen-shell: Remap surface when attaching primary output

Armin Krezović krezovic.armin at gmail.com
Thu Jun 30 17:55:01 UTC 2016


When a surface gets created and no outputs are present,
it won't get properly configured. This happens because
call to configure_presented_surface() depends on a call
to fs_output_set_surface() which requires a valid output.

This patch makes the code save the surface when no
outputs are present and reconfigure it when an output
gets attached, so it gets properly displayed.

Signed-off-by: Armin Krezović <krezovic.armin at gmail.com>
---
 fullscreen-shell/fullscreen-shell.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c
index 9716dc5..f58df2f 100644
--- a/fullscreen-shell/fullscreen-shell.c
+++ b/fullscreen-shell/fullscreen-shell.c
@@ -46,6 +46,8 @@ struct fullscreen_shell {
 	struct wl_listener output_created_listener;
 
 	struct wl_listener seat_created_listener;
+
+	struct wl_list unmapped_surfaces;
 };
 
 struct fs_output {
@@ -83,6 +85,12 @@ struct pointer_focus_listener {
 	struct wl_listener seat_destroyed;
 };
 
+struct fs_surface_list {
+	struct weston_surface *surface;
+	enum zwp_fullscreen_shell_v1_present_method method;
+	struct wl_list link;
+};
+
 static void
 pointer_focus_changed(struct wl_listener *listener, void *data)
 {
@@ -245,10 +253,15 @@ pending_surface_destroyed(struct wl_listener *listener, void *data)
 	fsout->pending.surface = NULL;
 }
 
+static void
+configure_presented_surface(struct weston_surface *surface, int32_t sx,
+			    int32_t sy);
+
 static struct fs_output *
 fs_output_create(struct fullscreen_shell *shell, struct weston_output *output)
 {
 	struct fs_output *fsout;
+	struct fs_surface_list *surf, *next;
 
 	fsout = zalloc(sizeof *fsout);
 	if (!fsout)
@@ -271,6 +284,14 @@ fs_output_create(struct fullscreen_shell *shell, struct weston_output *output)
 	weston_layer_entry_insert(&shell->layer.view_list,
 		       &fsout->black_view->layer_link);
 	wl_list_init(&fsout->transform.link);
+
+	wl_list_for_each_safe(surf, next, &shell->unmapped_surfaces, link) {
+		fs_output_set_surface(fsout, surf->surface, surf->method, 0, 0);
+		configure_presented_surface(surf->surface, 0, 0);
+		wl_list_remove(&surf->link);
+		free(surf);
+	}
+
 	return fsout;
 }
 
@@ -676,6 +697,7 @@ fullscreen_shell_present_surface(struct wl_client *client,
 	struct weston_surface *surface;
 	struct weston_seat *seat;
 	struct fs_output *fsout;
+	struct fs_surface_list *surf;
 
 	surface = surface_res ? wl_resource_get_user_data(surface_res) : NULL;
 
@@ -692,7 +714,13 @@ fullscreen_shell_present_surface(struct wl_client *client,
 				       "Invalid presentation method");
 	}
 
-	if (output_res) {
+	if (wl_list_empty(&shell->output_list)) {
+		surf = zalloc(sizeof *surf);
+		surf->surface = surface;
+		surf->method = method;
+		wl_list_init(&surf->link);
+		wl_list_insert(shell->unmapped_surfaces.prev, &surf->link);
+	} else if (output_res) {
 		output = wl_resource_get_user_data(output_res);
 		fsout = fs_output_for_output(output);
 		fs_output_set_surface(fsout, surface, method, 0, 0);
@@ -831,6 +859,7 @@ module_init(struct weston_compositor *compositor,
 		return -1;
 
 	shell->compositor = compositor;
+	wl_list_init(&shell->unmapped_surfaces);
 
 	shell->client_destroyed.notify = client_destroyed;
 
-- 
2.9.0



More information about the wayland-devel mailing list