#include #include #include "xdg-shell-protocol.h" #include "wlr-layer-shell-unstable-v1-protocol.h" /// A normal window #define OUTPUT_WINDOW 0 /// A desktop layer (wallpaper) #define OUTPUT_LAYER 1 #define DEFAULT_WIDTH 400 #define DEFAULT_HEIGHT 400 struct surface { int width, height; /// Wating to be redrawn. bool dirty; struct wl_surface *wl_surface; struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; struct wl_egl_window *egl_window; struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1; struct wl_output *wl_output; EGLSurface egl_surface; }; struct surface_list { struct surface data; struct surface_list *next; }; struct client_state { int running; int output_type; /* Globals */ struct wl_display *wl_display; struct wl_registry *wl_registry; struct wl_compositor *wl_compositor; struct xdg_wm_base *xdg_wm_base; struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1; struct surface_list *surface_list; /// Next in queue to check if it wants to be rendered. struct surface_list *surface_list_next; EGLDisplay egl_display; EGLConfig egl_config; EGLContext egl_context; }; #define EVENT_NONE 0 #define EVENT_DRAW 1 struct event { int type; union { /// EVENT_DRAW struct { int width, height; struct surface *surface; } draw; } data; }; void wayland_init(struct client_state *state, int output_type); void commit(struct client_state *state); /// Provide pointer to be filled. struct event wait_for_event(struct client_state *state); void swap_buffers(struct client_state *state, struct surface *surface);