From ba3cf95c0eed209feb25ac9b9de92af062630965 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Wed, 25 Jan 2012 16:22:05 +0200 Subject: [PATCH] compositor: move weston_surface::x,y into geometry weston_surface::transform.position depends on x,y, and therefore the dirty flag, so move x and y into geometry. Also add the missing dirty flags. Signed-off-by: Pekka Paalanen --- src/compositor-drm.c | 11 ++++--- src/compositor.c | 55 +++++++++++++++++++-------------- src/compositor.h | 4 ++- src/shell.c | 73 +++++++++++++++++++++++++------------------- src/tablet-shell.c | 23 ++++++++------ src/util.c | 8 ++--- 6 files changed, 101 insertions(+), 73 deletions(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 661ee324..95669b84 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -97,8 +97,8 @@ drm_output_prepare_scanout_surface(struct drm_output *output) struct weston_surface, link); if (es->visual != WESTON_RGB_VISUAL || - es->x != output->base.x || - es->y != output->base.y || + es->geometry.x != output->base.x || + es->geometry.y != output->base.y || es->width != output->base.current->width || es->height != output->base.current->height || es->image == EGL_NO_IMAGE_KHR) @@ -231,7 +231,8 @@ drm_output_set_cursor(struct weston_output *output_base, } pixman_region32_init_rect(&cursor_region, - eid->sprite->x, eid->sprite->y, + eid->sprite->geometry.x, + eid->sprite->geometry.y, eid->sprite->width, eid->sprite->height); pixman_region32_intersect_rect(&cursor_region, &cursor_region, @@ -272,8 +273,8 @@ drm_output_set_cursor(struct weston_output *output_base, } ret = drmModeMoveCursor(c->drm.fd, output->crtc_id, - eid->sprite->x - output->base.x, - eid->sprite->y - output->base.y); + eid->sprite->geometry.x - output->base.x, + eid->sprite->geometry.y - output->base.y); if (ret) { fprintf(stderr, "failed to move cursor: %s\n", strerror(-ret)); goto out; diff --git a/src/compositor.c b/src/compositor.c index 27408e7c..cee052fb 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -189,8 +189,8 @@ weston_surface_create(struct weston_compositor *compositor, surface->compositor = compositor; surface->visual = WESTON_NONE_VISUAL; surface->image = EGL_NO_IMAGE_KHR; - surface->x = x; - surface->y = y; + surface->geometry.x = x; + surface->geometry.y = y; surface->width = width; surface->height = height; surface->alpha = 255; @@ -253,8 +253,8 @@ weston_surface_update_transform(struct weston_surface *surface) surface->transform.enabled = 1; - surface->transform.position.matrix.d[12] = surface->x; - surface->transform.position.matrix.d[13] = surface->y; + surface->transform.position.matrix.d[12] = surface->geometry.x; + surface->transform.position.matrix.d[13] = surface->geometry.y; weston_matrix_init(matrix); wl_list_for_each(tform, &surface->geometry.transformation_list, link) @@ -291,8 +291,8 @@ weston_surface_to_global(struct weston_surface *surface, *x = floorf(v.f[0] / v.f[3]); *y = floorf(v.f[1] / v.f[3]); } else { - *x = sx + surface->x; - *y = sy + surface->y; + *x = sx + surface->geometry.x; + *y = sy + surface->geometry.y; } } @@ -317,8 +317,8 @@ surface_from_global_float(struct weston_surface *surface, *sx = v.f[0] / v.f[3]; *sy = v.f[1] / v.f[3]; } else { - *sx = x - surface->x; - *sy = y - surface->y; + *sx = x - surface->geometry.x; + *sy = y - surface->geometry.y; } } @@ -344,7 +344,8 @@ weston_surface_damage_rectangle(struct weston_surface *surface, pixman_region32_union_rect(&surface->damage, &surface->damage, - surface->x + x, surface->y + y, + surface->geometry.x + x, + surface->geometry.y + y, width, height); weston_compositor_schedule_repaint(compositor); } @@ -371,7 +372,7 @@ weston_surface_damage_below(struct weston_surface *surface) pixman_region32_union_rect(&below->damage, &below->damage, - surface->x, surface->y, + surface->geometry.x, surface->geometry.y, surface->width, surface->height); weston_compositor_schedule_repaint(surface->compositor); } @@ -397,8 +398,8 @@ weston_surface_configure(struct weston_surface *surface, { weston_surface_damage_below(surface); - surface->x = x; - surface->y = y; + surface->geometry.x = x; + surface->geometry.y = y; surface->width = width; surface->height = height; surface->geometry.dirty = 1; @@ -409,7 +410,8 @@ weston_surface_configure(struct weston_surface *surface, pixman_region32_fini(&surface->opaque); if (surface->visual == WESTON_RGB_VISUAL) pixman_region32_init_rect(&surface->opaque, - surface->x, surface->y, + surface->geometry.x, + surface->geometry.y, surface->width, surface->height); else pixman_region32_init(&surface->opaque); @@ -614,7 +616,8 @@ weston_surface_draw(struct weston_surface *es, struct weston_output *output) int n; pixman_region32_init_rect(&repaint, - es->x, es->y, es->width, es->height); + es->geometry.x, es->geometry.y, + es->width, es->height); pixman_region32_intersect(&repaint, &repaint, &output->region); pixman_region32_intersect(&repaint, &repaint, &es->damage); @@ -791,7 +794,8 @@ weston_output_set_cursor(struct weston_output *output, return; pixman_region32_init_rect(&cursor_region, - device->sprite->x, device->sprite->y, + device->sprite->geometry.x, + device->sprite->geometry.y, device->sprite->width, device->sprite->height); @@ -846,11 +850,13 @@ weston_output_repaint(struct weston_output *output, int msecs) wl_list_for_each(es, &ec->surface_list, link) { pixman_region32_init(&surface_overlap); pixman_region32_intersect_rect(&surface_overlap, - &overlap, es->x, es->y, + &overlap, + es->geometry.x, es->geometry.y, es->width, es->height); es->overlapped = pixman_region32_not_empty(&surface_overlap); pixman_region32_fini(&surface_overlap); - pixman_region32_union_rect(&overlap, &overlap, es->x, es->y, + pixman_region32_union_rect(&overlap, &overlap, + es->geometry.x, es->geometry.y, es->width, es->height); } @@ -981,7 +987,8 @@ weston_surface_assign_output(struct weston_surface *es) max = 0; wl_list_for_each(output, &ec->output_list, link) { pixman_region32_init_rect(®ion, - es->x, es->y, es->width, es->height); + es->geometry.x, es->geometry.y, + es->width, es->height); pixman_region32_intersect(®ion, ®ion, &output->region); e = pixman_region32_extents(®ion); @@ -1027,7 +1034,9 @@ surface_attach(struct wl_client *client, } else if (x != 0 || y != 0 || es->width != buffer->width || es->height != buffer->height) { - shell->configure(shell, es, es->x + x, es->y + y, + /* FIXME: the x,y delta should be in surface-local coords */ + shell->configure(shell, es, es->geometry.x + x, + es->geometry.y + y, buffer->width, buffer->height); } @@ -1237,8 +1246,8 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y) if (wd->sprite) { weston_surface_damage_below(wd->sprite); - wd->sprite->x = device->x - wd->hotspot_x; - wd->sprite->y = device->y - wd->hotspot_y; + wd->sprite->geometry.x = device->x - wd->hotspot_x; + wd->sprite->geometry.y = device->y - wd->hotspot_y; wd->sprite->geometry.dirty = 1; weston_surface_damage(wd->sprite); @@ -1592,8 +1601,8 @@ input_device_attach(struct wl_client *client, device->hotspot_y = y; device->sprite->width = buffer->width; device->sprite->height = buffer->height; - device->sprite->x = device->input_device.x - device->hotspot_x; - device->sprite->y = device->input_device.y - device->hotspot_y; + device->sprite->geometry.x = device->input_device.x - device->hotspot_x; + device->sprite->geometry.y = device->input_device.y - device->hotspot_y; device->sprite->geometry.dirty = 1; weston_surface_damage(device->sprite); diff --git a/src/compositor.h b/src/compositor.h index c05e5966..cb60e5f6 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -214,7 +214,7 @@ struct weston_surface { GLuint texture; pixman_region32_t damage; pixman_region32_t opaque; - int32_t x, y, width, height; + int32_t width, height; int32_t pitch; struct wl_list link; struct wl_list buffer_link; @@ -229,6 +229,8 @@ struct weston_surface { * That includes the transformations referenced from the list. */ struct { + int32_t x, y; /* surface translation on display */ + /* struct weston_transform */ struct wl_list transformation_list; diff --git a/src/shell.c b/src/shell.c index d2b23794..cae13c55 100644 --- a/src/shell.c +++ b/src/shell.c @@ -198,8 +198,8 @@ weston_surface_move(struct weston_surface *es, return -1; move->grab.interface = &move_grab_interface; - move->dx = es->x - wd->input_device.grab_x; - move->dy = es->y - wd->input_device.grab_y; + move->dx = es->geometry.x - wd->input_device.grab_x; + move->dy = es->geometry.y - wd->input_device.grab_y; move->surface = es; wl_input_device_start_grab(&wd->input_device, &move->grab, time); @@ -296,8 +296,8 @@ weston_surface_resize(struct shell_surface *shsurf, resize->grab.interface = &resize_grab_interface; resize->edges = edges; - resize->dx = es->x - wd->input_device.grab_x; - resize->dy = es->y - wd->input_device.grab_y; + resize->dx = es->geometry.x - wd->input_device.grab_x; + resize->dy = es->geometry.y - wd->input_device.grab_y; resize->width = es->width; resize->height = es->height; resize->shsurf = shsurf; @@ -342,8 +342,9 @@ reset_shell_surface_type(struct shell_surface *surface) { switch (surface->type) { case SHELL_SURFACE_FULLSCREEN: - surface->surface->x = surface->saved_x; - surface->surface->y = surface->saved_y; + surface->surface->geometry.x = surface->saved_x; + surface->surface->geometry.y = surface->saved_y; + surface->surface->geometry.dirty = 1; surface->surface->fullscreen_output = NULL; break; case SHELL_SURFACE_PANEL: @@ -399,8 +400,9 @@ shell_surface_set_transient(struct wl_client *client, /* assign to parents output */ es->output = pes->output; - es->x = pes->x + x; - es->y = pes->y + y; + es->geometry.x = pes->geometry.x + x; + es->geometry.y = pes->geometry.y + y; + es->geometry.dirty = 1; weston_surface_damage(es); shsurf->type = SHELL_SURFACE_TRANSIENT; @@ -430,10 +432,11 @@ shell_surface_set_fullscreen(struct wl_client *client, output = get_default_output(es->compositor); es->output = output; - shsurf->saved_x = es->x; - shsurf->saved_y = es->y; - es->x = (output->current->width - es->width) / 2; - es->y = (output->current->height - es->height) / 2; + shsurf->saved_x = es->geometry.x; + shsurf->saved_y = es->geometry.y; + es->geometry.x = (output->current->width - es->width) / 2; + es->geometry.y = (output->current->height - es->height) / 2; + es->geometry.dirty = 1; es->fullscreen_output = output; weston_surface_damage(es); shsurf->type = SHELL_SURFACE_FULLSCREEN; @@ -515,8 +518,9 @@ shell_map_popup(struct shell_surface *shsurf, uint32_t time) shsurf->popup.grab.interface = &popup_grab_interface; device = es->compositor->input_device; - es->x = shsurf->parent->surface->x + shsurf->popup.x; - es->y = shsurf->parent->surface->y + shsurf->popup.y; + es->geometry.x = shsurf->parent->surface->geometry.x + shsurf->popup.x; + es->geometry.y = shsurf->parent->surface->geometry.y + shsurf->popup.y; + es->geometry.dirty = 1; shsurf->popup.grab.input_device = device; shsurf->popup.time = device->grab_time; @@ -690,8 +694,8 @@ show_screensaver(struct wl_shell *shell, struct shell_surface *surface) wl_list_remove(&surface->surface->link); wl_list_insert(list, &surface->surface->link); weston_surface_configure(surface->surface, - surface->surface->x, - surface->surface->y, + surface->surface->geometry.x, + surface->surface->geometry.y, surface->surface->width, surface->surface->height); surface->surface->output = surface->output; @@ -733,8 +737,9 @@ desktop_shell_set_background(struct wl_client *client, wl_list_insert(&shell->backgrounds, &shsurf->link); - surface->x = shsurf->output->x; - surface->y = shsurf->output->y; + surface->geometry.x = shsurf->output->x; + surface->geometry.y = shsurf->output->y; + surface->geometry.dirty = 1; wl_resource_post_event(resource, DESKTOP_SHELL_CONFIGURE, @@ -771,8 +776,9 @@ desktop_shell_set_panel(struct wl_client *client, wl_list_insert(&shell->panels, &shsurf->link); - surface->x = shsurf->output->x; - surface->y = shsurf->output->y; + surface->geometry.x = shsurf->output->x; + surface->geometry.y = shsurf->output->y; + surface->geometry.dirty = 1; wl_resource_post_event(resource, DESKTOP_SHELL_CONFIGURE, @@ -830,8 +836,9 @@ resume_desktop(struct wl_shell *shell) terminate_screensaver(shell); wl_list_for_each(surface, &shell->hidden_surface_list, link) - weston_surface_configure(surface, surface->x, surface->y, - surface->width, surface->height); + weston_surface_configure(surface, surface->geometry.x, + surface->geometry.y, + surface->width, surface->height); if (wl_list_empty(&shell->backgrounds)) { list = &shell->compositor->surface_list; @@ -932,8 +939,8 @@ resize_binding(struct wl_input_device *device, uint32_t time, break; } - x = device->grab_x - surface->x; - y = device->grab_y - surface->y; + x = device->grab_x - surface->geometry.x; + y = device->grab_y - surface->geometry.y; if (x < surface->width / 3) edges |= WL_SHELL_SURFACE_RESIZE_LEFT; @@ -1223,8 +1230,9 @@ center_on_output(struct weston_surface *surface, struct weston_output *output) { struct weston_mode *mode = output->current; - surface->x = output->x + (mode->width - surface->width) / 2; - surface->y = output->y + (mode->height - surface->height) / 2; + surface->geometry.x = output->x + (mode->width - surface->width) / 2; + surface->geometry.y = output->y + (mode->height - surface->height) / 2; + surface->geometry.dirty = 1; } static void @@ -1256,8 +1264,9 @@ map(struct weston_shell *base, /* initial positioning, see also configure() */ switch (surface_type) { case SHELL_SURFACE_TOPLEVEL: - surface->x = 10 + random() % 400; - surface->y = 10 + random() % 400; + surface->geometry.x = 10 + random() % 400; + surface->geometry.y = 10 + random() % 400; + surface->geometry.dirty = 1; break; case SHELL_SURFACE_SCREENSAVER: case SHELL_SURFACE_FULLSCREEN: @@ -1314,8 +1323,9 @@ map(struct weston_shell *base, switch (surface_type) { case SHELL_SURFACE_TOPLEVEL: - surface->x = 10 + random() % 400; - surface->y = 10 + random() % 400; + surface->geometry.x = 10 + random() % 400; + surface->geometry.y = 10 + random() % 400; + surface->geometry.dirty = 1; break; case SHELL_SURFACE_POPUP: shell_map_popup(shsurf, shsurf->popup.time); @@ -1327,7 +1337,8 @@ map(struct weston_shell *base, surface->width = width; surface->height = height; if (do_configure) { - weston_surface_configure(surface, surface->x, surface->y, + weston_surface_configure(surface, surface->geometry.x, + surface->geometry.y, width, height); weston_compositor_repick(compositor); } diff --git a/src/tablet-shell.c b/src/tablet-shell.c index 51b259cc..14ac8895 100644 --- a/src/tablet-shell.c +++ b/src/tablet-shell.c @@ -110,8 +110,9 @@ tablet_shell_map(struct weston_shell *base, struct weston_surface *surface, struct tablet_shell *shell = container_of(base, struct tablet_shell, shell); - surface->x = 0; - surface->y = 0; + surface->geometry.x = 0; + surface->geometry.y = 0; + surface->geometry.dirty = 1; if (surface == shell->lockscreen_surface) { /* */ @@ -133,7 +134,8 @@ tablet_shell_map(struct weston_shell *base, struct weston_surface *surface, } wl_list_insert(&shell->compositor->surface_list, &surface->link); - weston_surface_configure(surface, surface->x, surface->y, width, height); + weston_surface_configure(surface, surface->geometry.x, + surface->geometry.y, width, height); } static void @@ -165,8 +167,9 @@ tablet_shell_set_lockscreen(struct wl_client *client, struct tablet_shell *shell = resource->data; struct weston_surface *es = surface_resource->data; - es->x = 0; - es->y = 0; + es->geometry.x = 0; + es->geometry.y = 0; + es->geometry.dirty = 1; shell->lockscreen_surface = es; shell->lockscreen_listener.func = handle_lockscreen_surface_destroy; wl_list_insert(es->surface.resource.destroy_listener_list.prev, @@ -199,8 +202,9 @@ tablet_shell_set_switcher(struct wl_client *client, * layer idea, we should be able to hit the framerate on the * fade/zoom in. */ shell->switcher_surface = es; - shell->switcher_surface->x = 0; - shell->switcher_surface->y = 0; + shell->switcher_surface->geometry.x = 0; + shell->switcher_surface->geometry.y = 0; + shell->switcher_surface->geometry.dirty = 1; shell->switcher_listener.func = handle_switcher_surface_destroy; wl_list_insert(es->surface.resource.destroy_listener_list.prev, @@ -215,8 +219,9 @@ tablet_shell_set_homescreen(struct wl_client *client, struct tablet_shell *shell = resource->data; shell->home_surface = surface_resource->data; - shell->home_surface->x = 0; - shell->home_surface->y = 0; + shell->home_surface->geometry.x = 0; + shell->home_surface->geometry.y = 0; + shell->home_surface->geometry.dirty = 1; } static void diff --git a/src/util.c b/src/util.c index c749f29d..a19df51a 100644 --- a/src/util.c +++ b/src/util.c @@ -135,12 +135,12 @@ weston_zoom_frame(struct weston_animation *animation, (zoom->stop - zoom->start) * zoom->spring.current; weston_matrix_init(&zoom->transform.matrix); weston_matrix_translate(&zoom->transform.matrix, - -(es->x + es->width / 2.0), - -(es->y + es->height / 2.0), 0); + -(es->geometry.x + es->width / 2.0), + -(es->geometry.y + es->height / 2.0), 0); weston_matrix_scale(&zoom->transform.matrix, scale, scale, scale); weston_matrix_translate(&zoom->transform.matrix, - es->x + es->width / 2.0, - es->y + es->height / 2.0, 0); + es->geometry.x + es->width / 2.0, + es->geometry.y + es->height / 2.0, 0); es->alpha = zoom->spring.current * 255; if (es->alpha > 255)