Compare commits
No commits in common. "fe1956236763bf1209d84e544a357694c042098f" and "9912c8ce5863a693147590c9e7dff84d225f2606" have entirely different histories.
fe19562367
...
9912c8ce58
3 changed files with 70 additions and 62 deletions
2
Makefile
2
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
|
||||
glonkers.o: wlr-layer-shell-unstable-v1-protocol.h xdg-shell-protocol.h renderer.h wayland.h
|
||||
renderer.o: renderer.h
|
||||
wayland.o: wayland.h
|
||||
|
||||
|
|
|
|||
71
wayland.c
71
wayland.c
|
|
@ -2,66 +2,8 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <wayland-egl.h>
|
||||
#include <wayland-cursor.h>
|
||||
#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;
|
||||
|
||||
|
|
@ -106,6 +48,7 @@ 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;
|
||||
|
|
@ -137,6 +80,7 @@ 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;
|
||||
}
|
||||
|
|
@ -155,6 +99,8 @@ 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;
|
||||
|
||||
|
|
@ -345,6 +291,7 @@ 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -496,6 +443,8 @@ 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 {
|
||||
|
|
@ -539,8 +488,12 @@ 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);
|
||||
|
|
@ -548,8 +501,10 @@ 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");
|
||||
|
|
|
|||
59
wayland.h
59
wayland.h
|
|
@ -1,3 +1,9 @@
|
|||
#include <EGL/egl.h>
|
||||
#include <wayland-egl.h>
|
||||
#include <wayland-cursor.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)
|
||||
|
|
@ -9,9 +15,55 @@
|
|||
|
||||
struct client_state;
|
||||
|
||||
struct surface;
|
||||
struct surface_list;
|
||||
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;
|
||||
};
|
||||
|
||||
#define EVENT_NONE 0
|
||||
#define EVENT_DRAW 1
|
||||
|
|
@ -30,6 +82,7 @@ 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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue