summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang, Xiong Y <xiong.y.zhang@intel.com>2013-12-13 22:10:54 +0200
committerKristian Høgsberg <krh@bitplanet.net>2013-12-16 16:46:22 -0800
commit010d0b169589ca5af5bb38fa1dba09a8885cc405 (patch)
treef685c86c12c84964077712c67b52871f4169a585
parentf301241d1ad1cdb87fd68b5ea783a6fbeb37aed9 (diff)
compositor: Ensure views are visible if their output was unplugged
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@intel.com> Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
-rw-r--r--src/compositor.c59
-rw-r--r--src/compositor.h1
2 files changed, 58 insertions, 2 deletions
diff --git a/src/compositor.c b/src/compositor.c
index 2f2c8389..e4eb56dc 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(&region);
- 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 530de71f..84b0f79f 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 {