diff --git a/wayland.c b/wayland.c index 6823a8e..e742def 100644 --- a/wayland.c +++ b/wayland.c @@ -2,8 +2,66 @@ #include #include #include + +#include +#include +#include +#include "xdg-shell-protocol.h" +#include "wlr-layer-shell-unstable-v1-protocol.h" + #include "wayland.h" +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; + + /// We need a back-pointer for callbacks. + struct client_state *state; +}; + +struct surface_list { + struct surface data; + struct surface_list *next; +}; + +struct client_state { + bool running; + int output_type; + /* Globals */ + struct wl_display *wl_display; + struct wl_registry *wl_registry; + struct wl_compositor *wl_compositor; + struct wl_shm *wl_shm; + struct xdg_wm_base *xdg_wm_base; + struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1; + struct wl_seat *wl_seat; + struct wl_pointer *wl_pointer; + + // Cursor + struct wl_surface *cursor_surface; + struct wl_cursor_image *wl_cursor_image; + + 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; +}; + + /// Starting values. int width = 700, height = 700; diff --git a/wayland.h b/wayland.h index dde6af9..04f6331 100644 --- a/wayland.h +++ b/wayland.h @@ -1,9 +1,3 @@ -#include -#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) @@ -15,55 +9,9 @@ struct client_state; -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; - - /// We need a back-pointer for callbacks. - struct client_state *state; -}; - -struct surface_list { - struct surface data; - struct surface_list *next; -}; - -struct client_state { - bool running; - int output_type; - /* Globals */ - struct wl_display *wl_display; - struct wl_registry *wl_registry; - struct wl_compositor *wl_compositor; - struct wl_shm *wl_shm; - struct xdg_wm_base *xdg_wm_base; - struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1; - struct wl_seat *wl_seat; - struct wl_pointer *wl_pointer; - - // Cursor - struct wl_surface *cursor_surface; - struct wl_cursor_image *wl_cursor_image; - - 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; -}; +struct surface; +struct surface_list; +struct client_state; #define EVENT_NONE 0 #define EVENT_DRAW 1 @@ -82,7 +30,6 @@ struct event { 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);