From 979ff58a24f79d8d1f5deb0a58f74afb5d2a4cfe Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Wed, 12 Oct 2022 04:05:33 -0400 Subject: [PATCH] Port 0.16 wlr_output_layout_get_box changes Fixes memory leaks. --- cage.c | 5 +++-- view.c | 9 +++++---- xdg_shell.c | 16 +++++++++------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cage.c b/cage.c index 896334b..d24fc17 100644 --- a/cage.c +++ b/cage.c @@ -536,8 +536,9 @@ main(int argc, char *argv[]) } /* Place the cursor in the center of the output layout. */ - struct wlr_box *layout_box = wlr_output_layout_get_box(server.output_layout, NULL); - wlr_cursor_warp(server.seat->cursor, NULL, layout_box->width / 2, layout_box->height / 2); + struct wlr_box layout_box; + wlr_output_layout_get_box(server.output_layout, NULL, &layout_box); + wlr_cursor_warp(server.seat->cursor, NULL, layout_box.width / 2, layout_box.height / 2); wl_display_run(server.wl_display); diff --git a/view.c b/view.c index 6551142..788af3d 100644 --- a/view.c +++ b/view.c @@ -88,12 +88,13 @@ view_center(struct cg_view *view, struct wlr_box *layout_box) void view_position(struct cg_view *view) { - struct wlr_box *layout_box = wlr_output_layout_get_box(view->server->output_layout, NULL); + struct wlr_box layout_box; + wlr_output_layout_get_box(view->server->output_layout, NULL, &layout_box); - if (view_is_primary(view) || view_extends_output_layout(view, layout_box)) { - view_maximize(view, layout_box); + if (view_is_primary(view) || view_extends_output_layout(view, &layout_box)) { + view_maximize(view, &layout_box); } else { - view_center(view, layout_box); + view_center(view, &layout_box); } } diff --git a/xdg_shell.c b/xdg_shell.c index b5f5c9b..b0fa185 100644 --- a/xdg_shell.c +++ b/xdg_shell.c @@ -72,13 +72,14 @@ popup_unconstrain(struct cg_view *view, struct wlr_xdg_popup *popup) struct wlr_output_layout *output_layout = server->output_layout; struct wlr_output *wlr_output = wlr_output_layout_output_at(output_layout, view->lx + popup_box->x, view->ly + popup_box->y); - struct wlr_box *output_box = wlr_output_layout_get_box(output_layout, wlr_output); + struct wlr_box output_box; + wlr_output_layout_get_box(output_layout, wlr_output, &output_box); struct wlr_box output_toplevel_box = { - .x = output_box->x - view->lx, - .y = output_box->y - view->ly, - .width = output_box->width, - .height = output_box->height, + .x = output_box.x - view->lx, + .y = output_box.y - view->ly, + .width = output_box.width, + .height = output_box.height, }; wlr_xdg_popup_unconstrain_from_box(popup, &output_toplevel_box); @@ -166,8 +167,9 @@ handle_xdg_shell_surface_request_fullscreen(struct wl_listener *listener, void * * Certain clients do not like figuring out their own window geometry if they * display in fullscreen mode, so we set it here. */ - struct wlr_box *layout_box = wlr_output_layout_get_box(xdg_shell_view->view.server->output_layout, NULL); - wlr_xdg_toplevel_set_size(xdg_shell_view->xdg_toplevel, layout_box->width, layout_box->height); + struct wlr_box layout_box; + wlr_output_layout_get_box(xdg_shell_view->view.server->output_layout, NULL, &layout_box); + wlr_xdg_toplevel_set_size(xdg_shell_view->xdg_toplevel, layout_box.width, layout_box.height); wlr_xdg_toplevel_set_fullscreen(xdg_shell_view->xdg_toplevel, xdg_shell_view->xdg_toplevel->requested.fullscreen);