From 08cfba2192f5770d975c5fe70789a81aaee4dc7e Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 26 Jul 2018 18:36:46 +1000 Subject: Allow containers to float Things worth noting: * When a fullscreen view unmaps, the check to unset fullscreen on the workspace has been moved out of view_unmap and into container_destroy, because containers can be fullscreen too * The calls to `container_reap_empty_recursive(workspace)` have been removed from `container_set_floating`. That function reaps upwards so it wouldn't do anything. I'm probably the one who originally added it... * My fix (b14bd1b0b1536039e4f46fe94515c7c44e7afc61) for the tabbed child crash has a side effect where when you close a floating container, focus is not given to the tiled container again. I've removed my fix and removed the call to `send_cursor_motion` from `seat_set_focus_warp`. We should consider calling it from somewhere earlier in the call stack. --- sway/scratchpad.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'sway/scratchpad.c') diff --git a/sway/scratchpad.c b/sway/scratchpad.c index 64636c77..181d9b3b 100644 --- a/sway/scratchpad.c +++ b/sway/scratchpad.c @@ -72,11 +72,7 @@ static void scratchpad_show(struct sway_container *con) { if (!wlr_box_contains_point(&workspace_box, center_lx, center_ly)) { // Maybe resize it if (con->width > ws->width || con->height > ws->height) { - // TODO: Do this properly once we can float C_CONTAINERs - if (con->type == C_VIEW) { - view_init_floating(con->sway_view); - arrange_windows(con); - } + container_init_floating(con); } // Center it @@ -85,6 +81,7 @@ static void scratchpad_show(struct sway_container *con) { container_floating_move_to(con, new_lx, new_ly); } + arrange_windows(ws); seat_set_focus(seat, con); container_set_dirty(con->parent); -- cgit v1.2.3 From 936168e740067a8658c7097ff76588b070faa71f Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 26 Jul 2018 22:42:58 +1000 Subject: Operate on floating split container when a child is focused --- sway/commands/floating.c | 8 ++++++++ sway/commands/scratchpad.c | 12 ++++++++++-- sway/scratchpad.c | 9 +++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) (limited to 'sway/scratchpad.c') diff --git a/sway/commands/floating.c b/sway/commands/floating.c index b67e736f..31de5ec3 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c @@ -29,6 +29,14 @@ struct cmd_results *cmd_floating(int argc, char **argv) { seat_set_focus(config->handler_context.seat, container); } + // If the container is in a floating split container, + // operate on the split container instead of the child. + if (container_is_floating_or_child(container)) { + while (container->parent->layout != L_FLOATING) { + container = container->parent; + } + } + bool wants_floating; if (strcasecmp(argv[0], "enable") == 0) { wants_floating = true; diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index ccc07c87..01a91d65 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c @@ -19,11 +19,19 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { } if (config->handler_context.using_criteria) { + struct sway_container *con = config->handler_context.current_container; + + // If the container is in a floating split container, + // operate on the split container instead of the child. + if (container_is_floating_or_child(con)) { + while (con->parent->layout != L_FLOATING) { + con = con->parent; + } + } + // If using criteria, this command is executed for every container which // matches the criteria. If this container isn't in the scratchpad, // we'll just silently return a success. - struct sway_container *con = config->handler_context.current_container; - wlr_log(WLR_INFO, "cmd_scratchpad(%s)", con->name); if (!con->scratchpad) { return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/scratchpad.c b/sway/scratchpad.c index 181d9b3b..787af6e1 100644 --- a/sway/scratchpad.c +++ b/sway/scratchpad.c @@ -110,6 +110,15 @@ void scratchpad_toggle_auto(void) { struct sway_container *ws = focus->type == C_WORKSPACE ? focus : container_parent(focus, C_WORKSPACE); + // If the focus is in a floating split container, + // operate on the split container instead of the child. + if (container_is_floating_or_child(focus)) { + while (focus->parent->layout != L_FLOATING) { + focus = focus->parent; + } + } + + // Check if the currently focused window is a scratchpad window and should // be hidden again. if (focus->scratchpad) { -- cgit v1.2.3 From 0337609667ad1d01e0e0dc19231373df3fbf7c87 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 27 Jul 2018 13:48:20 +1000 Subject: Focus child when showing a scratchpad container --- sway/scratchpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/scratchpad.c') diff --git a/sway/scratchpad.c b/sway/scratchpad.c index 787af6e1..b7d6fd99 100644 --- a/sway/scratchpad.c +++ b/sway/scratchpad.c @@ -82,7 +82,7 @@ static void scratchpad_show(struct sway_container *con) { } arrange_windows(ws); - seat_set_focus(seat, con); + seat_set_focus(seat, seat_get_focus_inactive(seat, con)); container_set_dirty(con->parent); } -- cgit v1.2.3