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

Commit

Permalink
subsurface: use commit request role hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Primak committed Sep 11, 2021
1 parent 59e5824 commit 8c4face
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions types/wlr_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,30 +515,10 @@ static void subsurface_parent_commit(struct wlr_subsurface *subsurface,
}
}

static void subsurface_commit(struct wlr_subsurface *subsurface) {
struct wlr_surface *surface = subsurface->surface;

if (subsurface_is_synchronized(subsurface)) {
if (subsurface->has_cache) {
// We already lock a previous commit. The prevents any future
// commit to be applied before we release the previous commit.
return;
}
subsurface->has_cache = true;
subsurface->cached_seq = wlr_surface_lock_pending(surface);
}
}

static void surface_handle_commit(struct wl_client *client,
struct wl_resource *resource) {
struct wlr_surface *surface = wlr_surface_from_resource(resource);

struct wlr_subsurface *subsurface = wlr_surface_is_subsurface(surface) ?
wlr_subsurface_from_wlr_surface(surface) : NULL;
if (subsurface != NULL) {
subsurface_commit(subsurface);
}

if (surface->role && surface->role->commit_request) {
surface->role->commit_request(surface);
}
Expand All @@ -551,6 +531,7 @@ static void surface_handle_commit(struct wl_client *client,
surface_commit_state(surface, &surface->pending);
}

struct wlr_subsurface *subsurface;
wl_list_for_each(subsurface, &surface->current.subsurfaces_below, current.link) {
subsurface_parent_commit(subsurface, false);
}
Expand Down Expand Up @@ -1061,6 +1042,24 @@ static void subsurface_unmap(struct wlr_subsurface *subsurface) {
}
}

static void subsurface_role_commit_request(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface =
wlr_subsurface_from_wlr_surface(surface);
if (subsurface == NULL) {
return;
}

if (subsurface_is_synchronized(subsurface)) {
if (subsurface->has_cache) {
// We already lock a previous commit. The prevents any future
// commit to be applied before we release the previous commit.
return;
}
subsurface->has_cache = true;
subsurface->cached_seq = wlr_surface_lock_pending(surface);
}
}

static void subsurface_role_commit(struct wlr_surface *surface) {
struct wlr_subsurface *subsurface =
wlr_subsurface_from_wlr_surface(surface);
Expand Down Expand Up @@ -1111,6 +1110,7 @@ static void subsurface_role_precommit(struct wlr_surface *surface,

const struct wlr_surface_role subsurface_role = {
.name = "wl_subsurface",
.commit_request = subsurface_role_commit_request,
.commit = subsurface_role_commit,
.precommit = subsurface_role_precommit,
};
Expand Down

0 comments on commit 8c4face

Please sign in to comment.