Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
surface: better buffer position handling
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Jun 28, 2018
1 parent 6d546ea commit 6cc7521
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion include/wlr/types/wlr_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions types/data_device/wlr_drag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
15 changes: 10 additions & 5 deletions types/wlr_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6cc7521

Please sign in to comment.