compositor: Remove weston_output::move_signal
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.
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c6739d4..fb16b22 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -5524,6 +5524,37 @@
}
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)
{
@@ -5536,6 +5567,9 @@
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 @@
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 9ef3c4e..1968c7b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -347,26 +347,6 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 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 @@
*/
uint32_t output_mask;
- struct wl_listener output_move_listener;
struct wl_listener output_destroy_listener;
};