From adf0423f7cc2758f5c0958038d5b937f531f22d6 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 25 Jun 2018 22:38:40 +0100 Subject: surface: better buffer position handling --- include/wlr/types/wlr_surface.h | 3 ++- types/data_device/wlr_drag.c | 4 ++-- types/wlr_surface.c | 15 ++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index ca33423e..ad1ee6f6 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -23,7 +23,7 @@ struct wlr_surface_state { uint32_t committed; // enum wlr_surface_state_field struct wl_resource *buffer; - int32_t sx, sy; + int32_t dx, dy; // relative to previous position pixman_region32_t surface_damage, buffer_damage; pixman_region32_t opaque, input; enum wl_output_transform transform; @@ -32,6 +32,7 @@ struct wlr_surface_state { int width, height; // in surface-local coordinates int buffer_width, buffer_height; + int sx, sy; // in surface-local coordinates struct wl_listener buffer_destroy_listener; }; diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c index b1eafd9c..bae098c5 100644 --- a/types/data_device/wlr_drag.c +++ b/types/data_device/wlr_drag.c @@ -341,8 +341,8 @@ static void drag_icon_handle_surface_destroy(struct wl_listener *listener, static void drag_icon_handle_surface_commit(struct wlr_surface *surface, void *role_data) { struct wlr_drag_icon *icon = role_data; - icon->sx += icon->surface->current.sx; - icon->sy += icon->surface->current.sy; + icon->sx += icon->surface->current.dx; + icon->sy += icon->surface->current.dy; drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface)); } diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 29d55312..964fe964 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -64,12 +64,12 @@ static void surface_destroy(struct wl_client *client, static void surface_attach(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *buffer, int32_t sx, int32_t sy) { + struct wl_resource *buffer, int32_t dx, int32_t dy) { struct wlr_surface *surface = wlr_surface_from_resource(resource); surface->pending.committed |= WLR_SURFACE_STATE_BUFFER; - surface->pending.sx = sx; - surface->pending.sy = sy; + surface->pending.dx = dx; + surface->pending.dy = dy; surface_state_set_buffer(&surface->pending, buffer); } @@ -203,9 +203,14 @@ static void surface_move_state(struct wlr_surface *surface, if ((next->committed & WLR_SURFACE_STATE_BUFFER)) { surface_state_set_buffer(state, next->buffer); surface_state_reset_buffer(next); - state->sx = next->sx; - state->sy = next->sy; + state->dx = next->dx; + state->dy = next->dy; + next->dx = next->dy = 0; + state->sx += state->dx; + state->sy += state->dy; update_size = true; + } else { + state->dx = state->dy = 0; } if (update_size) { update_damage = surface_update_size(surface, state); -- cgit v1.2.3