From bd9e5c0bc4257e1a48d3d9608cf46ba2c0e64888 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 30 Jun 2010 15:54:34 +0200 Subject: [PATCH] parser: implement explicit "mode floating"/"mode tiling" --- src/cmdparse.y | 6 +++++- src/floating.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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 */ -- 2.39.5