From 60f8b89c2b164fe16f49fde36d5c34d934a881d5 Mon Sep 17 00:00:00 2001 From: Rakarake Date: Sat, 7 Feb 2026 15:40:20 +0100 Subject: [PATCH 1/2] cleanup --- wayland.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/wayland.c b/wayland.c index 15f06b3..6823a8e 100644 --- a/wayland.c +++ b/wayland.c @@ -48,7 +48,6 @@ static void xdg_toplevel_configure ( while (next->data.xdg_toplevel != xdg_toplevel) { next = next->next; } next->data.width = width; next->data.height = height; - printf("🧟🧟🧟\n"); wl_egl_window_resize(next->data.egl_window, width, height, 0, 0); // draw new frame! next->data.dirty = true; @@ -80,7 +79,6 @@ static void zwlr_layer_surface_v1_configure(void *data, struct zwlr_layer_surfac next->data.height = height; wl_egl_window_resize(next->data.egl_window, width, height, 0, 0); zwlr_layer_surface_v1_ack_configure(zwlr_layer_surface_v1, serial); - printf("🐍🐍🐍🐍, setting layer to dirty: %p\n", &next->data); // draw new frame! next->data.dirty = true; } @@ -99,8 +97,6 @@ static const struct wl_callback_listener wl_surface_frame_listener; static void wl_surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) { - printf("FRAME CALLBACK 🐷🐷\n"); - struct surface *surface = data; struct client_state *state = surface->state; @@ -291,7 +287,6 @@ static void registry_handle_global( // frame callback struct wl_callback *cb = wl_surface_frame(wl_surface); wl_callback_add_listener(cb, &wl_surface_frame_listener, surface_location); - printf("zwlr layer callback configured 🐯🐯🐯🐯🐯🐯🐯\n"); } } @@ -443,8 +438,6 @@ struct event wait_for_event(struct client_state *state) { next->data.dirty = false; state->surface_list_next = next->next; - printf("dirty %p\n", &next->data); - if (eglMakeCurrent(state->egl_display, next->data.egl_surface, next->data.egl_surface, state->egl_context)) { } else { @@ -488,12 +481,8 @@ void print_surface_list(struct client_state *state) { void swap_buffers(struct client_state *state, struct surface *surface) { struct surface_list *next = state->surface_list; - print_surface_list(state); while (next != NULL) { - printf("going to swap buffers 🐃🐃🐃: %p, surface: %p\n", &next->data, surface); if (&next->data == surface) { - printf("swapping this buffer 🐃: %p\n", &next->data); - // Set time after eglSwapBuffers. eglSwapInterval(state->egl_display, 0); eglSwapBuffers(state->egl_display, next->data.egl_surface); @@ -501,10 +490,8 @@ void swap_buffers(struct client_state *state, struct surface *surface) { /* Request another frame */ struct wl_callback *cb = wl_surface_frame(surface->wl_surface); wl_callback_add_listener(cb, &wl_surface_frame_listener, surface); - printf("done swapping\n"); return; } - printf("next BUF: %p\n", next->next); next = next->next; } fprintf(stderr, "didn't find surface for buffer swap\n"); From fe1956236763bf1209d84e544a357694c042098f Mon Sep 17 00:00:00 2001 From: Rakarake Date: Sat, 7 Feb 2026 15:45:22 +0100 Subject: [PATCH 2/2] made pointers in wayland.h opaque --- Makefile | 2 +- wayland.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ wayland.h | 59 +++---------------------------------------------------- 3 files changed, 62 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index abc5883..6419c11 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols) WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner) glonkers: wlr-layer-shell-unstable-v1-protocol.o xdg-shell-protocol.o renderer.o wayland.o -glonkers.o: wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h renderer.h wayland.h +glonkers.o: wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h renderer.h renderer.o: renderer.h wayland.o: wayland.h 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);