surface: better buffer position handling

This commit is contained in:
emersion 2018-06-25 22:38:40 +01:00
parent e6399c61b7
commit adf0423f7c
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
3 changed files with 14 additions and 8 deletions

View File

@ -23,7 +23,7 @@ struct wlr_surface_state {
uint32_t committed; // enum wlr_surface_state_field uint32_t committed; // enum wlr_surface_state_field
struct wl_resource *buffer; 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 surface_damage, buffer_damage;
pixman_region32_t opaque, input; pixman_region32_t opaque, input;
enum wl_output_transform transform; enum wl_output_transform transform;
@ -32,6 +32,7 @@ struct wlr_surface_state {
int width, height; // in surface-local coordinates int width, height; // in surface-local coordinates
int buffer_width, buffer_height; int buffer_width, buffer_height;
int sx, sy; // in surface-local coordinates
struct wl_listener buffer_destroy_listener; struct wl_listener buffer_destroy_listener;
}; };

View File

@ -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, static void drag_icon_handle_surface_commit(struct wlr_surface *surface,
void *role_data) { void *role_data) {
struct wlr_drag_icon *icon = role_data; struct wlr_drag_icon *icon = role_data;
icon->sx += icon->surface->current.sx; icon->sx += icon->surface->current.dx;
icon->sy += icon->surface->current.sy; icon->sy += icon->surface->current.dy;
drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface)); drag_icon_set_mapped(icon, wlr_surface_has_buffer(surface));
} }

View File

@ -64,12 +64,12 @@ static void surface_destroy(struct wl_client *client,
static void surface_attach(struct wl_client *client, static void surface_attach(struct wl_client *client,
struct wl_resource *resource, 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); struct wlr_surface *surface = wlr_surface_from_resource(resource);
surface->pending.committed |= WLR_SURFACE_STATE_BUFFER; surface->pending.committed |= WLR_SURFACE_STATE_BUFFER;
surface->pending.sx = sx; surface->pending.dx = dx;
surface->pending.sy = sy; surface->pending.dy = dy;
surface_state_set_buffer(&surface->pending, buffer); 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)) { if ((next->committed & WLR_SURFACE_STATE_BUFFER)) {
surface_state_set_buffer(state, next->buffer); surface_state_set_buffer(state, next->buffer);
surface_state_reset_buffer(next); surface_state_reset_buffer(next);
state->sx = next->sx; state->dx = next->dx;
state->sy = next->sy; state->dy = next->dy;
next->dx = next->dy = 0;
state->sx += state->dx;
state->sy += state->dy;
update_size = true; update_size = true;
} else {
state->dx = state->dy = 0;
} }
if (update_size) { if (update_size) {
update_damage = surface_update_size(surface, state); update_damage = surface_update_size(surface, state);