[PATCH 06/10] compositor: Ensure views are visible if their output was unplugged
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Fri Dec 13 12:10:54 PST 2013
From: "Zhang, Xiong Y" <xiong.y.zhang at intel.com>
Use the output destroy signal to move the views in the event the output
was unplugged.
Signed-off-by: Zhang, Xiong Y <xiong.y.zhang at intel.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
---
src/compositor.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
src/compositor.h | 1 +
2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/src/compositor.c b/src/compositor.c
index 2f2c838..e4eb56d 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -365,6 +365,52 @@ weston_view_output_move_handler(struct wl_listener *listener,
ev->geometry.y + output->move_y);
}
+static void
+weston_view_output_destroy_handler(struct wl_listener *listener,
+ void *data)
+{
+ struct weston_view *ev;
+ struct weston_compositor *ec;
+ struct weston_output *output, *first_output;
+ float x, y;
+ int visible;
+
+ ev = container_of(listener, struct weston_view,
+ output_destroy_listener);
+
+ ec = ev->surface->compositor;
+
+ /* the child window's view->geometry is a relative coordinate to
+ * parent view, no need to move child_view. */
+ if (ev->geometry.parent)
+ return;
+
+ x = ev->geometry.x;
+ y = ev->geometry.y;
+
+ /* At this point the destroyed output is not in the list anymore.
+ * If the view is still visible somewhere, we leave where it is,
+ * otherwise, move it to the first output. */
+ visible = 0;
+ wl_list_for_each(output, &ec->output_list, link) {
+ if (pixman_region32_contains_point(&output->region,
+ x, y, NULL)) {
+ visible = 1;
+ break;
+ }
+ }
+
+ if (!visible) {
+ first_output = container_of(ec->output_list.next,
+ struct weston_output, link);
+
+ x = first_output->x + first_output->width / 4;
+ y = first_output->y + first_output->height / 4;
+ }
+
+ weston_view_set_position(ev, x, y);
+}
+
WL_EXPORT struct weston_view *
weston_view_create(struct weston_surface *surface)
{
@@ -401,6 +447,8 @@ weston_view_create(struct weston_surface *surface)
view->output = NULL;
view->output_move_listener.notify = weston_view_output_move_handler;
+ view->output_destroy_listener.notify =
+ weston_view_output_destroy_handler;
return view;
}
@@ -816,12 +864,17 @@ weston_view_assign_output(struct weston_view *ev)
}
pixman_region32_fini(®ion);
- if (ev->output_mask != 0)
+ if (ev->output_mask != 0) {
wl_list_remove(&ev->output_move_listener.link);
+ wl_list_remove(&ev->output_destroy_listener.link);
+ }
- if (mask != 0)
+ if (mask != 0) {
wl_signal_add(&new_output->move_signal,
&ev->output_move_listener);
+ wl_signal_add(&new_output->destroy_signal,
+ &ev->output_destroy_listener);
+ }
ev->output = new_output;
ev->output_mask = mask;
@@ -1265,6 +1318,8 @@ weston_view_unmap(struct weston_view *view)
wl_list_init(&view->link);
wl_list_remove(&view->output_move_listener.link);
wl_list_init(&view->output_move_listener.link);
+ wl_list_remove(&view->output_destroy_listener.link);
+ wl_list_init(&view->output_destroy_listener.link);
view->output_mask = 0;
weston_surface_assign_output(view->surface);
diff --git a/src/compositor.h b/src/compositor.h
index 530de71..84b0f79 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -807,6 +807,7 @@ struct weston_view {
uint32_t output_mask;
struct wl_listener output_move_listener;
+ struct wl_listener output_destroy_listener;
};
struct weston_surface {
--
1.7.9.5
More information about the wayland-devel
mailing list