void cmd_focus_window_mode(I3_CMD, const char *window_mode) {
DLOG("window_mode = %s\n", window_mode);
+ 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;
+ }
+
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 *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));
- break;
- }
+ con_focus(con_descend_focused(current));
+ success = true;
+ break;
}
- cmd_output->needs_tree_render = true;
- // XXX: default reply for now, make this a better reply
- ysuccess(true);
+ if (success) {
+ cmd_output->needs_tree_render = true;
+ ysuccess(true);
+ } else {
+ yerror("Failed to find a %s container in workspace.", to_floating ? "floating" : "tiling");
+ }
}
/*