diff --git a/src/cmdparse.y b/src/cmdparse.y index aa440046..49e0e4d7 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -448,7 +448,11 @@ mode: toggle_floating_mode(focused, false); } else { printf("should switch mode to %s\n", ($3 == TOK_FLOATING ? "floating" : "tiling")); - /* TODO: actually switch mode (not toggle) */ + if ($3 == TOK_FLOATING) { + floating_enable(focused, false); + } else { + floating_disable(focused, false); + } } } ; diff --git a/src/floating.c b/src/floating.c index d6009320..8f144113 100644 --- a/src/floating.c +++ b/src/floating.c @@ -17,6 +17,11 @@ extern xcb_connection_t *conn; void floating_enable(Con *con, bool automatic) { + if (con_is_floating(con)) { + LOG("Container is already in floating mode, not doing anything.\n"); + return; + } + /* 1: detach the container from its parent */ /* TODO: refactor this with tree_close() */ TAILQ_REMOVE(&(con->parent->nodes_head), con, nodes); @@ -45,6 +50,11 @@ void floating_enable(Con *con, bool automatic) { } void floating_disable(Con *con, bool automatic) { + if (!con_is_floating(con)) { + LOG("Container isn't floating, not doing anything.\n"); + return; + } + assert(con->old_parent != NULL); /* 1: detach from parent container */