[PATCH weston v3 1/6] compositor: Untangle mapedness from outputs

Armin Krezović krezovic.armin at gmail.com
Thu Jun 30 04:04:28 UTC 2016


Currently, weston assumes a surface/view is mapped if
it has an output assigned. In a zero outputs scenario,
this isn't really desirable.

This patch introduces a new flag to weston_surface and
weston_view, which has to be set manually to indicate
that a surface/view is mapped.

v2:

- Remove usage of new flags from
  weston_{view,surface}_is_mapped at this point. They
  will be added after all the implicit mappings have
  been introduced
- Unmap a surface before unmapping a view so the input
  foci is cleaned up properly
- Remove implicit view mapping from view_list_add
- Cosmetic fixes

v3:

- Rebased to apply on git master

Signed-off-by: Armin Krezović <krezovic.armin at gmail.com>
---
 libweston/compositor.c  | 15 ++++++---------
 libweston/compositor.h  |  4 ++++
 libweston/data-device.c |  2 ++
 libweston/input.c       |  2 ++
 4 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 37d94ec..93371b1 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -1735,6 +1735,7 @@ weston_view_unmap(struct weston_view *view)
 	weston_view_damage_below(view);
 	view->output = NULL;
 	view->plane = NULL;
+	view->is_mapped = false;
 	weston_layer_entry_remove(&view->layer_link);
 	wl_list_remove(&view->link);
 	wl_list_init(&view->link);
@@ -1764,6 +1765,7 @@ weston_surface_unmap(struct weston_surface *surface)
 {
 	struct weston_view *view;
 
+	surface->is_mapped = false;
 	wl_list_for_each(view, &surface->views, surface_link)
 		weston_view_unmap(view);
 	surface->output = NULL;
@@ -2128,6 +2130,7 @@ view_list_add_subsurface_view(struct weston_compositor *compositor,
 
 	view->parent_view = parent;
 	weston_view_update_transform(view);
+	view->is_mapped = true;
 
 	if (wl_list_empty(&sub->surface->subsurface_list)) {
 		wl_list_insert(compositor->view_list.prev, &view->link);
@@ -3241,7 +3244,6 @@ subsurface_get_label(struct weston_surface *surface, char *buf, size_t len)
 static void
 subsurface_configure(struct weston_surface *surface, int32_t dx, int32_t dy)
 {
-	struct weston_compositor *compositor = surface->compositor;
 	struct weston_view *view;
 
 	wl_list_for_each(view, &surface->views, surface_link)
@@ -3253,8 +3255,9 @@ subsurface_configure(struct weston_surface *surface, int32_t dx, int32_t dy)
 	 * mapped, parent is not in a visible layer, so this sub-surface
 	 * will not be drawn either.
 	 */
+
 	if (!weston_surface_is_mapped(surface)) {
-		struct weston_output *output;
+		surface->is_mapped = true;
 
 		/* Cannot call weston_view_update_transform(),
 		 * because that would call it also for the parent surface,
@@ -3262,17 +3265,11 @@ subsurface_configure(struct weston_surface *surface, int32_t dx, int32_t dy)
 		 * inconsistent state, where the window could never be
 		 * mapped.
 		 *
-		 * Instead just assign any output, to make
+		 * Instead just force the is_mapped flag on, to make
 		 * weston_surface_is_mapped() return true, so that when the
 		 * parent surface does get mapped, this one will get
 		 * included, too. See view_list_add().
 		 */
-		assert(!wl_list_empty(&compositor->output_list));
-		output = container_of(compositor->output_list.next,
-				      struct weston_output, link);
-
-		surface->output = output;
-		weston_surface_update_output_mask(surface, 1u << output->id);
 	}
 }
 
diff --git a/libweston/compositor.h b/libweston/compositor.h
index 9e5155c..8770982 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -964,6 +964,8 @@ struct weston_view {
 
 	/* Per-surface Presentation feedback flags, controlled by backend. */
 	uint32_t psf_flags;
+
+	bool is_mapped;
 };
 
 struct weston_surface_state {
@@ -1082,6 +1084,8 @@ struct weston_surface {
 	const char *role_name;
 
 	struct weston_timeline_object timeline;
+
+	bool is_mapped;
 };
 
 struct weston_subsurface {
diff --git a/libweston/data-device.c b/libweston/data-device.c
index f04f030..44a08f9 100644
--- a/libweston/data-device.c
+++ b/libweston/data-device.c
@@ -421,6 +421,8 @@ drag_surface_configure(struct weston_drag *drag,
 		weston_layer_entry_insert(list, &drag->icon->layer_link);
 		weston_view_update_transform(drag->icon);
 		pixman_region32_clear(&es->pending.input);
+		es->is_mapped = true;
+		drag->icon->is_mapped = true;
 	}
 
 	drag->dx += sx;
diff --git a/libweston/input.c b/libweston/input.c
index 08378d1..5ccc75f 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1950,6 +1950,8 @@ pointer_cursor_surface_configure(struct weston_surface *es,
 		weston_layer_entry_insert(&es->compositor->cursor_layer.view_list,
 					  &pointer->sprite->layer_link);
 		weston_view_update_transform(pointer->sprite);
+		es->is_mapped = true;
+		pointer->sprite->is_mapped = true;
 	}
 }
 
-- 
2.9.0



More information about the wayland-devel mailing list