Add error reply to cmd_focus_window_mode

This commit is contained in:
Orestis Floros 2017-09-19 14:52:02 +03:00
parent df437aa87e
commit 2592c63603
1 changed files with 26 additions and 20 deletions

View File

@ -1257,28 +1257,34 @@ void cmd_focus_direction(I3_CMD, const char *direction) {
void cmd_focus_window_mode(I3_CMD, const char *window_mode) { void cmd_focus_window_mode(I3_CMD, const char *window_mode) {
DLOG("window_mode = %s\n", window_mode); DLOG("window_mode = %s\n", window_mode);
Con *ws = con_get_workspace(focused); bool to_floating = false;
if (ws != NULL) {
if (strcmp(window_mode, "mode_toggle") == 0) { if (strcmp(window_mode, "mode_toggle") == 0) {
if (con_inside_floating(focused)) to_floating = !con_inside_floating(focused);
window_mode = "tiling"; } else if (strcmp(window_mode, "floating") == 0) {
else to_floating = true;
window_mode = "floating"; } else if (strcmp(window_mode, "tiling") == 0) {
to_floating = false;
} }
Con *ws = con_get_workspace(focused);
Con *current; Con *current;
bool success = false;
TAILQ_FOREACH(current, &(ws->focus_head), focused) { TAILQ_FOREACH(current, &(ws->focus_head), focused) {
if ((strcmp(window_mode, "floating") == 0 && current->type != CT_FLOATING_CON) || if ((to_floating && current->type != CT_FLOATING_CON) ||
(strcmp(window_mode, "tiling") == 0 && current->type == CT_FLOATING_CON)) (!to_floating && current->type == CT_FLOATING_CON))
continue; continue;
con_focus(con_descend_focused(current)); con_focus(con_descend_focused(current));
success = true;
break; break;
} }
}
if (success) {
cmd_output->needs_tree_render = true; cmd_output->needs_tree_render = true;
// XXX: default reply for now, make this a better reply
ysuccess(true); ysuccess(true);
} else {
yerror("Failed to find a %s container in workspace.", to_floating ? "floating" : "tiling");
}
} }
/* /*