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

Commit 8c4face

Browse files
author
Kirill Primak
committed
subsurface: use commit request role hook
1 parent 59e5824 commit 8c4face

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

types/wlr_surface.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -515,30 +515,10 @@ static void subsurface_parent_commit(struct wlr_subsurface *subsurface,
515515
}
516516
}
517517

518-
static void subsurface_commit(struct wlr_subsurface *subsurface) {
519-
struct wlr_surface *surface = subsurface->surface;
520-
521-
if (subsurface_is_synchronized(subsurface)) {
522-
if (subsurface->has_cache) {
523-
// We already lock a previous commit. The prevents any future
524-
// commit to be applied before we release the previous commit.
525-
return;
526-
}
527-
subsurface->has_cache = true;
528-
subsurface->cached_seq = wlr_surface_lock_pending(surface);
529-
}
530-
}
531-
532518
static void surface_handle_commit(struct wl_client *client,
533519
struct wl_resource *resource) {
534520
struct wlr_surface *surface = wlr_surface_from_resource(resource);
535521

536-
struct wlr_subsurface *subsurface = wlr_surface_is_subsurface(surface) ?
537-
wlr_subsurface_from_wlr_surface(surface) : NULL;
538-
if (subsurface != NULL) {
539-
subsurface_commit(subsurface);
540-
}
541-
542522
if (surface->role && surface->role->commit_request) {
543523
surface->role->commit_request(surface);
544524
}
@@ -551,6 +531,7 @@ static void surface_handle_commit(struct wl_client *client,
551531
surface_commit_state(surface, &surface->pending);
552532
}
553533

534+
struct wlr_subsurface *subsurface;
554535
wl_list_for_each(subsurface, &surface->current.subsurfaces_below, current.link) {
555536
subsurface_parent_commit(subsurface, false);
556537
}
@@ -1061,6 +1042,24 @@ static void subsurface_unmap(struct wlr_subsurface *subsurface) {
10611042
}
10621043
}
10631044

1045+
static void subsurface_role_commit_request(struct wlr_surface *surface) {
1046+
struct wlr_subsurface *subsurface =
1047+
wlr_subsurface_from_wlr_surface(surface);
1048+
if (subsurface == NULL) {
1049+
return;
1050+
}
1051+
1052+
if (subsurface_is_synchronized(subsurface)) {
1053+
if (subsurface->has_cache) {
1054+
// We already lock a previous commit. The prevents any future
1055+
// commit to be applied before we release the previous commit.
1056+
return;
1057+
}
1058+
subsurface->has_cache = true;
1059+
subsurface->cached_seq = wlr_surface_lock_pending(surface);
1060+
}
1061+
}
1062+
10641063
static void subsurface_role_commit(struct wlr_surface *surface) {
10651064
struct wlr_subsurface *subsurface =
10661065
wlr_subsurface_from_wlr_surface(surface);
@@ -1111,6 +1110,7 @@ static void subsurface_role_precommit(struct wlr_surface *surface,
11111110

11121111
const struct wlr_surface_role subsurface_role = {
11131112
.name = "wl_subsurface",
1113+
.commit_request = subsurface_role_commit_request,
11141114
.commit = subsurface_role_commit,
11151115
.precommit = subsurface_role_precommit,
11161116
};

0 commit comments

Comments
 (0)