mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-24 06:59:45 -05:00
Add wlr_subsurface for new wlr_surface API
This commit is contained in:
parent
e76d4581ce
commit
1160a83903
4 changed files with 641 additions and 122 deletions
|
|
@ -16,18 +16,13 @@ struct wlr_commit;
|
|||
struct wlr_output;
|
||||
struct wlr_surface;
|
||||
|
||||
struct wlr_subcompositor {
|
||||
struct wl_global *global;
|
||||
};
|
||||
|
||||
struct wlr_compositor {
|
||||
struct wl_display *display;
|
||||
struct wl_global *global;
|
||||
struct wlr_renderer *renderer;
|
||||
|
||||
uint32_t ids;
|
||||
|
||||
struct wlr_subcompositor subcompositor;
|
||||
|
||||
struct {
|
||||
struct wl_signal new_surface;
|
||||
struct wl_signal new_surface_2;
|
||||
|
|
@ -41,17 +36,63 @@ struct wlr_surface_2 {
|
|||
struct wl_resource *resource;
|
||||
struct wlr_compositor *compositor;
|
||||
|
||||
/*
|
||||
* This should contain the name of the protocol to prevent conflicts.
|
||||
* e.g. "xdg_toplevel".
|
||||
* Also, it should point to statically allocated memory.
|
||||
*/
|
||||
const char *role_name;
|
||||
void *role_data;
|
||||
|
||||
struct wl_list committed;
|
||||
struct wl_list frame_callbacks;
|
||||
|
||||
struct {
|
||||
struct wl_signal commit;
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct wlr_commit *pending;
|
||||
struct wl_list committed;
|
||||
|
||||
struct wl_list frame_callbacks;
|
||||
};
|
||||
|
||||
/*
|
||||
* wlr_commit
|
||||
*
|
||||
* A wlr_commit is a description for a "coherent presentation" of a surface's
|
||||
* contents, or could also be thought of as a "snaphot" of the surface at
|
||||
* commit time. It should contain all of the information to correctly display
|
||||
* a surface.
|
||||
*
|
||||
* A wlr_commit can be extended to add extra state for each commit to be
|
||||
* managed properly by the commit queue. Every wayland protocol that has state
|
||||
* synchronized by wl_surface.commit should use this extension mechanism.
|
||||
*
|
||||
* A commit can exist in 3 states:
|
||||
* - Pending: The client has not commited the contents yet.
|
||||
* - Committed: The client has commited the contents, but something is
|
||||
* inhibiting the presentation of this surface.
|
||||
* - Complete: The commit is ready to be presented.
|
||||
*
|
||||
* For a surface, there will always be exactly 1 pending commit for a surface.
|
||||
* see wlr_surface_get_pending
|
||||
*
|
||||
* Excluding the time when a before the first complete commit is ready, there
|
||||
* will always be at least 1 complete commit for a surface. The latest complete
|
||||
* commit is called the current commit.
|
||||
* see wlr_surface_get_commit
|
||||
*
|
||||
* wlr_commits are reference counted. If you wish to save the contents of a
|
||||
* commit for future use, simply do not unreference the commit. A referenced
|
||||
* wlr_commit will even persist after the surface is destroyed, which can be
|
||||
* useful for fade-out animations. Any extensions to wlr_surface should be
|
||||
* prepared for the associated wlr_surface to not be available.
|
||||
*
|
||||
* Upon commit destruction, several actions may be performed on objects which
|
||||
* will affect clients. For example, wl_buffer.release may be called for the
|
||||
* attached buffer. Holding onto too many commits for too long may cause
|
||||
* resource starvation in clients, so care should be taken to unreference
|
||||
* commits as soon as they're no longer needed.
|
||||
*/
|
||||
struct wlr_commit {
|
||||
struct wl_list link;
|
||||
struct wlr_surface_2 *surface;
|
||||
|
|
@ -103,15 +144,23 @@ struct wlr_surface_2 *wlr_surface_from_resource_2(struct wl_resource *resource);
|
|||
|
||||
struct wlr_commit *wlr_surface_get_commit(struct wlr_surface_2 *surface);
|
||||
struct wlr_commit *wlr_surface_get_pending(struct wlr_surface_2 *surface);
|
||||
struct wlr_commit *wlr_surface_get_latest(struct wlr_surface_2 *surface);
|
||||
|
||||
void wlr_surface_send_enter_2(struct wlr_surface_2 *surf, struct wlr_output *output);
|
||||
void wlr_surface_send_leave_2(struct wlr_surface_2 *surf, struct wlr_output *output);
|
||||
|
||||
struct wlr_commit *wlr_commit_ref(struct wlr_commit *commit);
|
||||
void wlr_commit_unref(struct wlr_commit *commit);
|
||||
|
||||
bool wlr_commit_is_complete(struct wlr_commit *c);
|
||||
|
||||
void wlr_commit_inhibit(struct wlr_commit *commit);
|
||||
void wlr_commit_uninhibit(struct wlr_commit *commit);
|
||||
|
||||
bool wlr_surface_set_role_2(struct wlr_surface_2 *surf, const char *name);
|
||||
void wlr_commit_set(struct wlr_commit *commit, uint32_t id, void *data);
|
||||
void *wlr_commit_get(struct wlr_commit *commit, uint32_t id);
|
||||
|
||||
bool wlr_surface_is_subsurface(struct wlr_surface *surface);
|
||||
|
||||
/**
|
||||
|
|
|
|||
52
include/wlr/types/wlr_subcompositor.h
Normal file
52
include/wlr/types/wlr_subcompositor.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef WLR_TYPES_WLR_SUBCOMPOSITOR_H
|
||||
#define WLR_TYPES_WLR_SUBCOMPOSITOR_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <wayland-server.h>
|
||||
|
||||
struct wlr_compositor;
|
||||
struct wlr_commit;
|
||||
struct wlr_surface_2;
|
||||
|
||||
struct wlr_subcompositor {
|
||||
struct wl_global *global;
|
||||
struct wlr_compositor *compositor;
|
||||
|
||||
uint32_t root_id;
|
||||
|
||||
struct {
|
||||
struct wl_signal new_subsurface;
|
||||
} events;
|
||||
|
||||
struct wl_listener new_state;
|
||||
struct wl_listener display_destroy;
|
||||
};
|
||||
|
||||
struct wlr_subsurface {
|
||||
struct wl_resource *resource;
|
||||
struct wlr_surface_2 *surface;
|
||||
struct wlr_surface_2 *parent;
|
||||
|
||||
bool synchronized;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
struct wl_listener surface_destroy;
|
||||
struct wl_listener parent_destroy;
|
||||
};
|
||||
|
||||
struct wlr_subcompositor *wlr_subcompositor_create(struct wlr_compositor *compositor);
|
||||
|
||||
struct wlr_subsurface *wlr_surface_to_subsurface(struct wlr_surface_2 *surf);
|
||||
struct wlr_surface_2 *wlr_surface_get_root_surface(struct wlr_surface_2 *surf);
|
||||
|
||||
typedef void (*wlr_subsurface_iter_t)(void *userdata,
|
||||
struct wlr_commit *commit, int32_t x, int32_t y);
|
||||
|
||||
void wlr_commit_for_each_subsurface(struct wlr_subcompositor *sc,
|
||||
struct wlr_commit *commit, wlr_subsurface_iter_t func, void *userdata);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue