parser: implement explicit "mode floating"/"mode tiling"

This commit is contained in:
Michael Stapelberg 2010-06-30 15:54:34 +02:00
parent 2da4173144
commit bd9e5c0bc4
2 changed files with 15 additions and 1 deletions

View File

@ -448,7 +448,11 @@ mode:
toggle_floating_mode(focused, false); toggle_floating_mode(focused, false);
} else { } else {
printf("should switch mode to %s\n", ($<number>3 == TOK_FLOATING ? "floating" : "tiling")); printf("should switch mode to %s\n", ($<number>3 == TOK_FLOATING ? "floating" : "tiling"));
/* TODO: actually switch mode (not toggle) */ if ($<number>3 == TOK_FLOATING) {
floating_enable(focused, false);
} else {
floating_disable(focused, false);
}
} }
} }
; ;

View File

@ -17,6 +17,11 @@
extern xcb_connection_t *conn; extern xcb_connection_t *conn;
void floating_enable(Con *con, bool automatic) { 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 */ /* 1: detach the container from its parent */
/* TODO: refactor this with tree_close() */ /* TODO: refactor this with tree_close() */
TAILQ_REMOVE(&(con->parent->nodes_head), con, nodes); 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) { 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); assert(con->old_parent != NULL);
/* 1: detach from parent container */ /* 1: detach from parent container */