+ count++;
+ }
+
+ if (count > 1)
+ LOG("WARNING: Your criteria for the focus command matches %d containers, "
+ "while only exactly one container can be focused at a time.\n", count);
+
+ tree_render();
+ }
+ | TOK_FOCUS direction
+ {
+ int direction = $2;
+ switch (direction) {
+ case TOK_LEFT:
+ LOG("Focusing left\n");
+ tree_next('p', HORIZ);
+ break;
+ case TOK_RIGHT:
+ LOG("Focusing right\n");
+ tree_next('n', HORIZ);
+ break;
+ case TOK_UP:
+ LOG("Focusing up\n");
+ tree_next('p', VERT);
+ break;
+ case TOK_DOWN:
+ LOG("Focusing down\n");
+ tree_next('n', VERT);
+ break;
+ default:
+ ELOG("Invalid focus direction (%d)\n", direction);
+ break;
+ }
+
+ tree_render();
+ }
+ | TOK_FOCUS window_mode
+ {
+ printf("should focus: ");
+
+ if ($2 == TOK_TILING)
+ printf("tiling\n");
+ else if ($2 == TOK_FLOATING)
+ printf("floating\n");
+ else printf("mode toggle\n");
+
+ Con *ws = con_get_workspace(focused);
+ Con *current;
+ if (ws != NULL) {
+ int to_focus = $2;
+ if ($2 == TOK_MODE_TOGGLE) {
+ current = TAILQ_FIRST(&(ws->focus_head));
+ if (current != NULL && current->type == CT_FLOATING_CON)
+ to_focus = TOK_TILING;
+ else to_focus = TOK_FLOATING;
+ }
+ TAILQ_FOREACH(current, &(ws->focus_head), focused) {
+ if ((to_focus == TOK_FLOATING && current->type != CT_FLOATING_CON) ||
+ (to_focus == TOK_TILING && current->type == CT_FLOATING_CON))
+ continue;
+
+ con_focus(con_descend_focused(current));
+ break;
+ }