Operate on floating split container when a child is focused

This commit is contained in:
Ryan Dwyer 2018-07-26 22:42:58 +10:00
parent 902a1402ba
commit 936168e740
3 changed files with 27 additions and 2 deletions

View File

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

View File

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

View File

@ -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) {