diff --git a/wayland.c b/wayland.c index 5fdb0d5..33594ef 100644 --- a/wayland.c +++ b/wayland.c @@ -3,6 +3,9 @@ #include #include "wayland.h" +/// Starting values. +int width = 700, height = 700; + static void wl_buffer_release(void *data, struct wl_buffer *wl_buffer) { /* Sent by the compositor when it's no longer using this buffer */ wl_buffer_destroy(wl_buffer); @@ -38,12 +41,12 @@ static void xdg_toplevel_configure ( ) { struct client_state *state = data; - state->width = width; - state->height = height; // resize egl window struct surface_list *next = state->surface_list; while (next->data.xdg_toplevel != xdg_toplevel) { next = next->next; } + next->data.width = width; + next->data.height = height; wl_egl_window_resize(next->data.egl_window, width, height, 0, 0); } @@ -67,10 +70,10 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = { static void zwlr_layer_surface_v1_configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) { struct client_state *state = data; - state->width = width; - state->height = height; struct surface_list *next = state->surface_list; while (next->data.zwlr_layer_surface_v1 != zwlr_layer_surface_v1) { next = next->next; } + next->data.width = width; + 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); } @@ -251,7 +254,7 @@ static void egl_init(struct client_state *state) { struct surface_list *next = state->surface_list; while (next != NULL) { next->data.egl_window = wl_egl_window_create(next->data.wl_surface, - state->width, state->height); + next->data.width, next->data.height); if (next->data.egl_window == EGL_NO_SURFACE) { fprintf(stderr, "Can't create egl window\n"); exit(1); @@ -277,9 +280,6 @@ static void egl_init(struct client_state *state) { /// Initializes wayland and creates an opengl context void wayland_init(struct client_state *state, int output_type) { - int width = 700, height = 700; - state->width = width; - state->height = height; state->running = 1; state->output_type = output_type; state->wl_display = wl_display_connect(NULL); diff --git a/wayland.h b/wayland.h index 19727af..eedfa46 100644 --- a/wayland.h +++ b/wayland.h @@ -9,6 +9,8 @@ #define OUTPUT_LAYER 1 struct surface { + int width, height; + struct wl_surface *wl_surface; struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; @@ -25,7 +27,6 @@ struct surface_list { }; struct client_state { - int width, height; int running; int output_type; /* Globals */