resizing and closing

This commit is contained in:
Rakarake 2025-12-25 13:43:19 +01:00
parent 09ac1a0559
commit 7e2171681d
3 changed files with 30 additions and 5 deletions

View file

@ -34,6 +34,31 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = {
.ping = xdg_wm_base_ping,
};
static void xdg_toplevel_configure (
void *data,
struct xdg_toplevel *xdg_toplevel,
int32_t width,
int32_t height,
struct wl_array *states
) {
struct client_state *state = data;
state->width = width;
state->height = height;
// resize egl window
wl_egl_window_resize(state->egl_window, width, height, 0, 0);
}
static void xdg_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel) {
struct client_state *state = data;
state->running = 0;
}
static const struct xdg_toplevel_listener xdg_toplevel_listener = {
.configure = xdg_toplevel_configure,
.close = xdg_toplevel_close,
};
static void
registry_handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version)
@ -53,7 +78,6 @@ registry_handle_global(void *data, struct wl_registry *registry,
xdg_wm_base_add_listener(state->xdg_wm_base,
&xdg_wm_base_listener, state);
}
}
static void
@ -160,6 +184,7 @@ void wayland_init(struct client_state *state) {
int width = 700, height = 700;
state->width = width;
state->height = height;
state->running = 1;
state->wl_display = wl_display_connect(NULL);
state->wl_registry = wl_display_get_registry(state->wl_display);
wl_registry_add_listener(state->wl_registry, &wl_registry_listener, state);
@ -170,7 +195,8 @@ void wayland_init(struct client_state *state) {
state->xdg_wm_base, state->wl_surface);
xdg_surface_add_listener(state->xdg_surface, &xdg_surface_listener, state);
state->xdg_toplevel = xdg_surface_get_toplevel(state->xdg_surface);
xdg_toplevel_set_title(state->xdg_toplevel, "GLONKERS!");
xdg_toplevel_set_title(state->xdg_toplevel, "GLONKERS! 🕴️");
xdg_toplevel_add_listener(state->xdg_toplevel, &xdg_toplevel_listener, state);
wl_surface_commit(state->wl_surface);
egl_init(state);