|
|
|
@ -231,19 +231,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
set_focused_container(view);
|
|
|
|
|
} else if (strcasecmp(argv[0], "mode_toggle") == 0) {
|
|
|
|
|
if (get_focused_view(active_workspace)->is_floating) {
|
|
|
|
|
if (active_workspace->children->length > 0) {
|
|
|
|
|
set_focused_container(get_focused_view(active_workspace->children->items[0]));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (active_workspace->floating->length > 0) {
|
|
|
|
|
swayc_t *floating = active_workspace->floating->items[active_workspace->floating->length-1];
|
|
|
|
|
set_focused_container(get_focused_view(floating));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -272,6 +260,8 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool cmd_focus(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
static int floating_toggled_index = 0;
|
|
|
|
|
static int tiled_toggled_index = 0;
|
|
|
|
|
if (!checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -285,7 +275,44 @@ static bool cmd_focus(struct sway_config *config, int argc, char **argv) {
|
|
|
|
|
return move_focus(MOVE_DOWN);
|
|
|
|
|
} else if (strcasecmp(argv[0], "parent") == 0) {
|
|
|
|
|
return move_focus(MOVE_PARENT);
|
|
|
|
|
} else if (strcasecmp(argv[0], "mode_toggle") == 0) {
|
|
|
|
|
int i;
|
|
|
|
|
swayc_t *focused = get_focused_view(active_workspace);
|
|
|
|
|
if (focused->is_floating) {
|
|
|
|
|
if (active_workspace->children->length > 0) {
|
|
|
|
|
for (i = 0;i < active_workspace->floating->length; i++) {
|
|
|
|
|
if (active_workspace->floating->items[i] == focused) {
|
|
|
|
|
floating_toggled_index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (active_workspace->children->length > tiled_toggled_index) {
|
|
|
|
|
set_focused_container(get_focused_view(active_workspace->children->items[tiled_toggled_index]));
|
|
|
|
|
} else {
|
|
|
|
|
set_focused_container(get_focused_view(active_workspace->children->items[0]));
|
|
|
|
|
tiled_toggled_index = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (active_workspace->floating->length > 0) {
|
|
|
|
|
for (i = 0;i < active_workspace->children->length; i++) {
|
|
|
|
|
if (active_workspace->children->items[i] == focused) {
|
|
|
|
|
tiled_toggled_index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (active_workspace->floating->length > floating_toggled_index) {
|
|
|
|
|
swayc_t *floating = active_workspace->floating->items[floating_toggled_index];
|
|
|
|
|
set_focused_container(get_focused_view(floating));
|
|
|
|
|
} else {
|
|
|
|
|
swayc_t *floating = active_workspace->floating->items[active_workspace->floating->length - 1];
|
|
|
|
|
set_focused_container(get_focused_view(floating));
|
|
|
|
|
tiled_toggled_index = active_workspace->floating->length - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|