examples: send xdg_toplevel configure events

Commit 811ca199c4 ("xdg-shell: drop automatic surface configuration")
has updated tinywl for the breaking change, but missed examples.
This commit is contained in:
Simon Ser 2024-03-15 13:18:41 +01:00
parent 7a8e2cd8ed
commit 65bf7d1679
3 changed files with 45 additions and 0 deletions

View file

@ -16,6 +16,12 @@
#include "xdg-shell-client-protocol.h"
struct surface {
struct wlr_surface *wlr;
struct wl_listener commit;
struct wl_listener destroy;
};
static struct wl_display *remote_display = NULL;
static struct wl_compositor *compositor = NULL;
static struct wl_subcompositor *subcompositor = NULL;
@ -119,8 +125,34 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
wlr_scene_output_send_frame_done(scene_output, &now);
}
static void surface_handle_commit(struct wl_listener *listener, void *data) {
struct surface *surface = wl_container_of(listener, surface, commit);
struct wlr_xdg_toplevel *xdg_toplevel =
wlr_xdg_toplevel_try_from_wlr_surface(surface->wlr);
if (xdg_toplevel != NULL && xdg_toplevel->base->initial_commit) {
wlr_xdg_toplevel_set_size(xdg_toplevel, 0, 0);
}
}
static void surface_handle_destroy(struct wl_listener *listener, void *data) {
struct surface *surface = wl_container_of(listener, surface, destroy);
wl_list_remove(&surface->commit.link);
wl_list_remove(&surface->destroy.link);
free(surface);
}
static void handle_new_surface(struct wl_listener *listener, void *data) {
struct wlr_surface *wlr_surface = data;
struct surface *surface = calloc(1, sizeof(*surface));
surface->wlr = wlr_surface;
surface->commit.notify = surface_handle_commit;
wl_signal_add(&wlr_surface->events.commit, &surface->commit);
surface->destroy.notify = surface_handle_destroy;
wl_signal_add(&wlr_surface->events.destroy, &surface->destroy);
wlr_scene_surface_create(&scene->tree, wlr_surface);
}