diff --git a/examples/embedded.c b/examples/embedded.c index ff8b8851..c488e011 100644 --- a/examples/embedded.c +++ b/examples/embedded.c @@ -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); } diff --git a/examples/output-layers.c b/examples/output-layers.c index cd05d9f0..d7fadac3 100644 --- a/examples/output-layers.c +++ b/examples/output-layers.c @@ -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); diff --git a/examples/scene-graph.c b/examples/scene-graph.c index fb530c06..42198653 100644 --- a/examples/scene-graph.c +++ b/examples/scene-graph.c @@ -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) {