68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
#include <EGL/egl.h>
|
|
#include <wayland-egl.h>
|
|
#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
|
|
|
|
struct surface {
|
|
int width, height;
|
|
|
|
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;
|
|
|
|
// notice, surface does not own `state`, this is a backlink.
|
|
struct client_state *state;
|
|
};
|
|
|
|
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;
|
|
|
|
EGLDisplay egl_display;
|
|
EGLConfig egl_config;
|
|
EGLContext egl_context;
|
|
|
|
/// Provide this from caller.
|
|
void(*render_func)(void *data, int width, int height, double time);
|
|
};
|
|
|
|
#define EVENT_DRAW 0
|
|
|
|
struct event {
|
|
int type;
|
|
union {
|
|
/// EVENT_DRAW
|
|
struct {
|
|
int width, height;
|
|
} draw;
|
|
} data;
|
|
};
|
|
|
|
void wayland_init(struct client_state *state, int output_type);
|
|
void commit(struct client_state *state);
|
|
/// Provide pointer to be filled.
|
|
void wait_for_event(struct client_state *state, struct event *event);
|
|
|