compositor: introduce unified map logic

This commit is contained in:
Kirill Primak 2023-03-04 22:13:52 +03:00 committed by Isaac Freund
parent 6668c822b3
commit 6b40e08148
2 changed files with 58 additions and 0 deletions

View file

@ -76,6 +76,7 @@ struct wlr_surface_role {
void (*commit)(struct wlr_surface *surface);
void (*precommit)(struct wlr_surface *surface,
const struct wlr_surface_state *state);
void (*unmap)(struct wlr_surface *surface);
void (*destroy)(struct wlr_surface *surface);
};
@ -135,6 +136,8 @@ struct wlr_surface {
struct wl_list cached; // wlr_surface_state.cached_link
bool mapped;
const struct wlr_surface_role *role; // the lifetime-bound role or NULL
void *role_data; // role-specific data
@ -142,6 +145,20 @@ struct wlr_surface {
struct wl_signal client_commit;
struct wl_signal precommit; // const struct wlr_surface_state *
struct wl_signal commit;
/**
* The `map` event signals that the surface has a non-null buffer
* committed and is ready to be displayed.
*/
struct wl_signal map;
/**
* The `unmap` event signals that the surface shouldn't be displayed
* anymore. This can happen when a null buffer is committed,
* the associated role object is destroyed, or when the role-specific
* conditions for the surface to be mapped no longer apply.
*/
struct wl_signal unmap;
struct wl_signal new_subsurface;
struct wl_signal destroy;
} events;
@ -200,6 +217,20 @@ bool wlr_surface_set_role(struct wlr_surface *surface,
*/
void wlr_surface_destroy_role_object(struct wlr_surface *surface);
/**
* Map the surface. If the surface is already mapped, this is no-op.
*
* This function must only be used by surface role implementations.
*/
void wlr_surface_map(struct wlr_surface *surface);
/**
* Unmap the surface. If the surface is already unmapped, this is no-op.
*
* This function must only be used by surface role implementations.
*/
void wlr_surface_unmap(struct wlr_surface *surface);
/**
* Whether or not this surface currently has an attached buffer. A surface has
* an attached buffer when it commits with a non-null buffer in its pending