[PATCH 03/10] compositor: Move the logic of moving outputs into the core
Ander Conselvan de Oliveira
conselvan2 at gmail.com
Fri Dec 13 12:10:51 PST 2013
From: "Zhang, Xiong Y" <xiong.y.zhang at intel.com>
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 at intel.com>
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
---
src/compositor-drm.c | 8 --------
src/compositor-x11.c | 20 +++-----------------
src/compositor.c | 23 +++++++++++++++++++++++
3 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 44deaab..f85298a 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -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);
}
}
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 9a36b59..2ef1b5d 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -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);
diff --git a/src/compositor.c b/src/compositor.c
index 0e739e3..36985d7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -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);
--
1.7.9.5
More information about the wayland-devel
mailing list