examples: send xdg_toplevel configure events

Commit 811ca199c4 ("xdg-shell: drop automatic surface configuration")
has updated tinywl for the breaking change, but missed examples.
master
Simon Ser 9 months ago
parent 7a8e2cd8ed
commit 65bf7d1679

@ -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);
}

@ -204,6 +204,12 @@ static void output_surface_handle_commit(struct wl_listener *listener,
struct output_surface *output_surface =
wl_container_of(listener, output_surface, commit);
struct wlr_xdg_toplevel *xdg_toplevel =
wlr_xdg_toplevel_try_from_wlr_surface(output_surface->wlr_surface);
if (xdg_toplevel != NULL && xdg_toplevel->base->initial_commit) {
wlr_xdg_toplevel_set_size(xdg_toplevel, 0, 0);
}
struct wlr_buffer *buffer = NULL;
if (output_surface->wlr_surface->buffer != NULL) {
buffer = wlr_buffer_lock(&output_surface->wlr_surface->buffer->base);

@ -94,9 +94,16 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
static void surface_handle_commit(struct wl_listener *listener, void *data) {
struct surface *surface = wl_container_of(listener, surface, commit);
wlr_scene_rect_set_size(surface->border,
surface->wlr->current.width + 2 * border_width,
surface->wlr->current.height + 2 * border_width);
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) {

Loading…
Cancel
Save