From: Michael Stapelberg Date: Wed, 30 Jun 2010 13:54:34 +0000 (+0200) Subject: parser: implement explicit "mode floating"/"mode tiling" X-Git-Tag: tree-pr1~172 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bd9e5c0bc4257e1a48d3d9608cf46ba2c0e64888;p=i3%2Fi3 parser: implement explicit "mode floating"/"mode tiling" --- 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 */