From dd28e6a6d6abf06d2d16e6c91aeaf942bf225af7 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 27 Mar 2019 14:00:19 -0400 Subject: Fix xwayland configure request scratchpad crash This fixes a crash in `container_init_floating` when a xwayland view sends a configure request while in the scratchpad. `container_init_floating` gets called so the configured minimum and maximum sizes gets respected when resizing to the requested size. Since the workspace was NULL, it would SIGSEGV when attempting to get the workspace's output for the output box retrieval. This extracts the resizing portion of `container_init_floating` into a separate function. If the container is in the scratchpad, it will just be resized and skip the centering. Additionally, `container_init_floating` has been renamed to `container_floating_resize_and_center` to more accurately describe what it does. --- sway/tree/root.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'sway/tree/root.c') diff --git a/sway/tree/root.c b/sway/tree/root.c index 5dde9f22..bc9c610d 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c @@ -124,15 +124,7 @@ void root_scratchpad_show(struct sway_container *con) { struct wlr_box workspace_box; workspace_get_box(new_ws, &workspace_box); if (!wlr_box_contains_point(&workspace_box, center_lx, center_ly)) { - // Maybe resize it - if (con->width > new_ws->width || con->height > new_ws->height) { - container_init_floating(con); - } - - // Center it - double new_lx = new_ws->x + (new_ws->width - con->width) / 2; - double new_ly = new_ws->y + (new_ws->height - con->height) / 2; - container_floating_move_to(con, new_lx, new_ly); + container_floating_resize_and_center(con); } arrange_workspace(new_ws); -- cgit v1.2.3