Add error reply to cmd_focus_window_mode

next
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) {
DLOG("window_mode = %s\n", window_mode);
Con *ws = con_get_workspace(focused);
if (ws != NULL) {
if (strcmp(window_mode, "mode_toggle") == 0) {
if (con_inside_floating(focused))
window_mode = "tiling";
else
window_mode = "floating";
}
Con *current;
TAILQ_FOREACH(current, &(ws->focus_head), focused) {
if ((strcmp(window_mode, "floating") == 0 && current->type != CT_FLOATING_CON) ||
(strcmp(window_mode, "tiling") == 0 && current->type == CT_FLOATING_CON))
continue;
con_focus(con_descend_focused(current));
break;
}
bool to_floating = false;
if (strcmp(window_mode, "mode_toggle") == 0) {
to_floating = !con_inside_floating(focused);
} else if (strcmp(window_mode, "floating") == 0) {
to_floating = true;
} else if (strcmp(window_mode, "tiling") == 0) {
to_floating = false;
}
cmd_output->needs_tree_render = true;
// XXX: default reply for now, make this a better reply
ysuccess(true);
Con *ws = con_get_workspace(focused);
Con *current;
bool success = false;
TAILQ_FOREACH(current, &(ws->focus_head), focused) {
if ((to_floating && current->type != CT_FLOATING_CON) ||
(!to_floating && current->type == CT_FLOATING_CON))
continue;
con_focus(con_descend_focused(current));
success = true;
break;
}
if (success) {
cmd_output->needs_tree_render = true;
ysuccess(true);
} else {
yerror("Failed to find a %s container in workspace.", to_floating ? "floating" : "tiling");
}
}
/*