compositor: Move the logic of moving outputs into the core
authorZhang, Xiong Y <xiong.y.zhang@intel.com>
Fri, 13 Dec 2013 20:10:51 +0000 (22:10 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 17 Dec 2013 00:20:51 +0000 (16:20 -0800)
Instead of having the backends move the remaining outputs when one is
destroyed, let the core compositor deal with that.

Signed-off-by: Zhang, Xiong Y <xiong.y.zhang@intel.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
src/compositor-drm.c
src/compositor-x11.c
src/compositor.c

index 44deaab..f85298a 100644 (file)
@@ -2222,7 +2222,6 @@ update_outputs(struct drm_compositor *ec, struct udev_device *drm_device)
        drmModeRes *resources;
        struct drm_output *output, *next;
        int x = 0, y = 0;
-       int x_offset = 0, y_offset = 0;
        uint32_t connected = 0, disconnects = 0;
        int i;
 
@@ -2272,17 +2271,10 @@ update_outputs(struct drm_compositor *ec, struct udev_device *drm_device)
        if (disconnects) {
                wl_list_for_each_safe(output, next, &ec->base.output_list,
                                      base.link) {
-                       if (x_offset != 0 || y_offset != 0) {
-                               weston_output_move(&output->base,
-                                                output->base.x - x_offset,
-                                                output->base.y - y_offset);
-                       }
-
                        if (disconnects & (1 << output->connector_id)) {
                                disconnects &= ~(1 << output->connector_id);
                                weston_log("connector %d disconnected\n",
                                       output->connector_id);
-                               x_offset += output->base.width;
                                drm_output_destroy(&output->base);
                        }
                }
index 9a36b59..2ef1b5d 100644 (file)
@@ -918,24 +918,10 @@ x11_compositor_find_output(struct x11_compositor *c, xcb_window_t window)
 static void
 x11_compositor_delete_window(struct x11_compositor *c, xcb_window_t window)
 {
-       struct x11_output *deleted_output, *output, *next;
-       int x_offset = 0;
-
-       deleted_output = x11_compositor_find_output(c, window);
-
-       wl_list_for_each_safe(output, next, &c->base.output_list, base.link) {
-               if (x_offset != 0) {
-                       weston_output_move(&output->base,
-                                          output->base.x - x_offset,
-                                          output->base.y);
-                       weston_output_damage(&output->base);
-               }
+       struct x11_output *output;
 
-               if (output == deleted_output) {
-                       x_offset += output->base.width;
-                       x11_output_destroy(&output->base);
-               }
-       }
+       output = x11_compositor_find_output(c, window);
+       x11_output_destroy(&output->base);
 
        xcb_flush(c->conn);
 
index 0e739e3..36985d7 100644 (file)
@@ -2993,9 +2993,32 @@ bind_output(struct wl_client *client,
                wl_output_send_done(resource);
 }
 
+/* Move other outputs when one is removed so the space remains contiguos. */
+static void
+weston_compositor_remove_output(struct weston_compositor *compositor,
+                               struct weston_output *remove_output)
+{
+       struct weston_output *output;
+       int offset = 0;
+
+       wl_list_for_each(output, &compositor->output_list, link) {
+               if (output == remove_output) {
+                       offset = output->width;
+                       continue;
+               }
+
+               if (offset > 0) {
+                       weston_output_move(output,
+                                          output->x - offset, output->y);
+                       output->dirty = 1;
+               }
+       }
+}
+
 WL_EXPORT void
 weston_output_destroy(struct weston_output *output)
 {
+       weston_compositor_remove_output(output->compositor, output);
        wl_list_remove(&output->link);
 
        wl_signal_emit(&output->destroy_signal, output);