From 5a18f62fee5f0a9c8abc1554222f3774179ff373 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 27 Dec 2017 06:06:29 -0500 Subject: [PATCH] add role-committed hook --- include/wlr/types/wlr_surface.h | 12 ++++++++++++ types/wlr_surface.c | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index c8e3761a..9f88d044 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -77,6 +77,10 @@ struct wlr_surface { struct wl_listener compositor_listener; void *compositor_data; + // surface commit callback for the role that runs before all others + void (*role_committed)(struct wlr_surface *surface, void *role_data); + void *role_data; + // subsurface properties struct wlr_subsurface *subsurface; struct wl_list subsurface_list; // wlr_subsurface::parent_link @@ -146,4 +150,12 @@ void wlr_surface_send_leave(struct wlr_surface *surface, void wlr_surface_send_frame_done(struct wlr_surface *surface, const struct timespec *when); +/** + * Set a callback for surface commit that runs before all the other callbacks. + * This is intended for use by the surface role. + */ +void wlr_surface_set_role_committed(struct wlr_surface *surface, + void (*role_committed)(struct wlr_surface *surface, void *role_data), + void *role_data); + #endif diff --git a/types/wlr_surface.c b/types/wlr_surface.c index ad0c6f68..8e024177 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -428,6 +428,10 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) { } } + if (surface->role_committed) { + surface->role_committed(surface, surface->role_data); + } + // TODO: add the invalid bitfield to this callback wl_signal_emit(&surface->events.commit, surface); } @@ -943,3 +947,10 @@ void wlr_surface_send_frame_done(struct wlr_surface *surface, wl_resource_destroy(cb->resource); } } + +void wlr_surface_set_role_committed(struct wlr_surface *surface, + void (*role_committed)(struct wlr_surface *surface, void *role_data), + void *role_data) { + surface->role_committed = role_committed; + surface->role_data = role_data; +}