aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-03-22 18:28:13 +0100
committerSimon Ser <contact@emersion.fr>2021-03-25 19:34:47 +0100
commit7ac76aba8abaa5fbd82db8453ac6f2450142da9f (patch)
treeeb10136e759ff7d50c788a48886510690ae5e106
parent78d21fa131d746a7ae5890657654161692da63b6 (diff)
surface: introduce commit sequence numbers
Very similar to output commit sequence numbers. Can be useful to reference a specific commit.
-rw-r--r--include/wlr/types/wlr_surface.h3
-rw-r--r--types/wlr_surface.c4
2 files changed, 7 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h
index ef2f2dac..d247df0c 100644
--- a/include/wlr/types/wlr_surface.h
+++ b/include/wlr/types/wlr_surface.h
@@ -31,6 +31,9 @@ enum wlr_surface_state_field {
struct wlr_surface_state {
uint32_t committed; // enum wlr_surface_state_field
+ // Sequence number of the surface state. Incremented on each commit, may
+ // overflow.
+ uint32_t seq;
struct wl_resource *buffer_resource;
int32_t dx, dy; // relative to previous position
diff --git a/types/wlr_surface.c b/types/wlr_surface.c
index 7d567c9c..80313192 100644
--- a/types/wlr_surface.c
+++ b/types/wlr_surface.c
@@ -295,6 +295,7 @@ static void surface_state_copy(struct wlr_surface_state *state,
}
state->committed |= next->committed;
+ state->seq = next->seq;
}
/**
@@ -418,6 +419,7 @@ static void surface_commit_pending(struct wlr_surface *surface) {
surface_state_copy(&surface->previous, &surface->current);
surface_state_move(&surface->current, &surface->pending);
+ surface->pending.seq = surface->current.seq + 1;
if (invalid_buffer) {
surface_apply_damage(surface);
@@ -491,6 +493,7 @@ static void subsurface_commit(struct wlr_subsurface *subsurface) {
if (subsurface_is_synchronized(subsurface)) {
surface_state_move(&subsurface->cached, &surface->pending);
subsurface->has_cache = true;
+ surface->pending.seq = subsurface->cached.seq + 1;
} else {
if (subsurface->has_cache) {
surface_state_move(&surface->pending, &subsurface->cached);
@@ -692,6 +695,7 @@ struct wlr_surface *wlr_surface_create(struct wl_client *client,
surface_state_init(&surface->current);
surface_state_init(&surface->pending);
surface_state_init(&surface->previous);
+ surface->pending.seq = 1;
wl_signal_init(&surface->events.commit);
wl_signal_init(&surface->events.destroy);