[PATCH weston 2/4] compositor: Remove weston_output::move_signal
Ander Conselvan de Oliveira
ander.conselvan.de.oliveira at intel.com
Wed Jan 29 08:47:52 PST 2014
Since that signal is per output, it is necessary to track in which
output a view is in so that the signal is handled properly.
Instead, add a compositor wide output moved signal, that is handled by
the shell. The shell iterates over the layers it owns to move views
appropriately.
---
desktop-shell/shell.c | 34 ++++++++++++++++++++++++++++++++++
desktop-shell/shell.h | 1 +
src/compositor.c | 42 +++++-------------------------------------
src/compositor.h | 2 +-
4 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c275543..ae06382 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -5472,6 +5472,37 @@ handle_output_create(struct wl_listener *listener, void *data)
}
static void
+handle_output_move(struct wl_listener *listener, void *data)
+{
+ struct desktop_shell *shell;
+ struct weston_output *output;
+ struct weston_layer *layer;
+ struct weston_view *view;
+ float x, y;
+
+ shell = container_of(listener, struct desktop_shell,
+ output_move_listener);
+ output = data;
+
+ /* Move all views in the layers owned by the shell */
+ wl_list_for_each(layer, shell->fullscreen_layer.link.prev, link) {
+ wl_list_for_each(view, &layer->view_list, layer_link) {
+ if (view->output != output)
+ continue;
+
+ x = view->geometry.x + output->move_x;
+ y = view->geometry.y + output->move_y;
+ weston_view_set_position(view, x, y);
+ }
+
+ /* We don't start from the beggining of the layer list, so
+ * make sure we don't wrap around it. */
+ if (layer == &shell->background_layer)
+ break;
+ }
+}
+
+static void
setup_output_destroy_handler(struct weston_compositor *ec,
struct desktop_shell *shell)
{
@@ -5484,6 +5515,9 @@ setup_output_destroy_handler(struct weston_compositor *ec,
shell->output_create_listener.notify = handle_output_create;
wl_signal_add(&ec->output_created_signal,
&shell->output_create_listener);
+
+ shell->output_move_listener.notify = handle_output_move;
+ wl_signal_add(&ec->output_moved_signal, &shell->output_move_listener);
}
static void
diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
index dbb2854..4d4f00a 100644
--- a/desktop-shell/shell.h
+++ b/desktop-shell/shell.h
@@ -184,6 +184,7 @@ struct desktop_shell {
enum animation_type focus_animation_type;
struct wl_listener output_create_listener;
+ struct wl_listener output_move_listener;
struct wl_list output_list;
char *client;
diff --git a/src/compositor.c b/src/compositor.c
index 18018b1..ff7ee7b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -347,26 +347,6 @@ static struct weston_subsurface *
weston_surface_to_subsurface(struct weston_surface *surface);
static void
-weston_view_output_move_handler(struct wl_listener *listener,
- void *data)
-{
- struct weston_view *ev;
- struct weston_output *output = data;
-
- ev = container_of(listener, struct weston_view,
- output_move_listener);
-
- /* the child window's view->geometry is a relative coordinate to
- * parent view, no need to move child_view. */
- if (ev->geometry.parent)
- return;
-
- weston_view_set_position(ev,
- ev->geometry.x + output->move_x,
- ev->geometry.y + output->move_y);
-}
-
-static void
weston_view_output_destroy_handler(struct wl_listener *listener,
void *data)
{
@@ -414,10 +394,8 @@ weston_view_output_destroy_handler(struct wl_listener *listener,
if (ev->surface->output_destroyed)
ev->surface->output_destroyed(ev->surface);
- wl_list_remove(&ev->output_move_listener.link);
wl_list_remove(&ev->output_destroy_listener.link);
- wl_list_init(&ev->output_move_listener.link);
wl_list_init(&ev->output_destroy_listener.link);
}
@@ -456,8 +434,6 @@ weston_view_create(struct weston_surface *surface)
view->output = NULL;
- view->output_move_listener.notify = weston_view_output_move_handler;
- wl_list_init(&view->output_move_listener.link);
view->output_destroy_listener.notify =
weston_view_output_destroy_handler;
wl_list_init(&view->output_destroy_listener.link);
@@ -911,20 +887,14 @@ weston_view_assign_output(struct weston_view *ev)
}
pixman_region32_fini(®ion);
- if (ev->output_mask != 0) {
- wl_list_remove(&ev->output_move_listener.link);
+ if (ev->output_mask != 0)
wl_list_remove(&ev->output_destroy_listener.link);
- }
- if (mask != 0) {
- wl_signal_add(&new_output->move_signal,
- &ev->output_move_listener);
+ if (mask != 0)
wl_signal_add(&new_output->destroy_signal,
&ev->output_destroy_listener);
- } else {
- wl_list_init(&ev->output_move_listener.link);
+ else
wl_list_init(&ev->output_destroy_listener.link);
- }
ev->output = new_output;
ev->output_mask = mask;
@@ -1379,8 +1349,6 @@ weston_view_unmap(struct weston_view *view)
wl_list_init(&view->layer_link);
wl_list_remove(&view->link);
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;
@@ -3342,7 +3310,7 @@ weston_output_move(struct weston_output *output, int x, int y)
output->dirty = 1;
/* Move views on this output. */
- wl_signal_emit(&output->move_signal, output);
+ wl_signal_emit(&output->compositor->output_moved_signal, output);
/* Notify clients of the change for output position. */
wl_resource_for_each(resource, &output->resource_list)
@@ -3378,7 +3346,6 @@ weston_output_init(struct weston_output *output, struct weston_compositor *c,
wl_signal_init(&output->frame_signal);
wl_signal_init(&output->destroy_signal);
- wl_signal_init(&output->move_signal);
wl_list_init(&output->animation_list);
wl_list_init(&output->resource_list);
@@ -3641,6 +3608,7 @@ weston_compositor_init(struct weston_compositor *ec,
wl_signal_init(&ec->seat_created_signal);
wl_signal_init(&ec->output_created_signal);
wl_signal_init(&ec->output_destroyed_signal);
+ wl_signal_init(&ec->output_moved_signal);
wl_signal_init(&ec->session_signal);
ec->session_active = 1;
diff --git a/src/compositor.h b/src/compositor.h
index ced792f..c8e38fb 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -580,6 +580,7 @@ struct weston_compositor {
struct wl_signal seat_created_signal;
struct wl_signal output_created_signal;
struct wl_signal output_destroyed_signal;
+ struct wl_signal output_moved_signal;
struct wl_event_loop *input_loop;
struct wl_event_source *input_loop_source;
@@ -820,7 +821,6 @@ struct weston_view {
*/
uint32_t output_mask;
- struct wl_listener output_move_listener;
struct wl_listener output_destroy_listener;
};
--
1.8.1.2
More information about the wayland-devel
mailing list