From cea8f91e18660f30c2c81a6ef4600c3f757e6fd7 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 1 Jun 2010 23:20:57 +0200 Subject: [PATCH] parser: implement 'layout' --- src/cmdparse.l | 1 + src/cmdparse.y | 27 ++++++++++++++++++++++++++- src/render.c | 3 ++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/cmdparse.l b/src/cmdparse.l index 0102d145..8850ff64 100644 --- a/src/cmdparse.l +++ b/src/cmdparse.l @@ -88,6 +88,7 @@ global { return TOK_GLOBAL; } layout { return TOK_LAYOUT; } default { return TOK_DEFAULT; } stacked { return TOK_STACKED; } +stacking { return TOK_STACKED; } tabbed { return TOK_TABBED; } border { return TOK_BORDER; } none { return TOK_NONE; } diff --git a/src/cmdparse.y b/src/cmdparse.y index 40fd65af..51690a59 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -252,8 +252,8 @@ operation: | restart /*| reload | mark - | layout | border */ + | layout | restore | move | workspace @@ -466,3 +466,28 @@ restore: tree_append_json($3); } ; + +layout: + TOK_LAYOUT WHITESPACE layout_mode + { + printf("changing layout to %d\n", $3); + owindow *current; + + /* check if the match is empty, not if the result is empty */ + if (match_is_empty(¤t_match)) + focused->layout = $3; + else { + TAILQ_FOREACH(current, &owindows, owindows) { + printf("matching: %p / %s\n", current->con, current->con->name); + current->con->layout = $3; + } + } + + } + ; + +layout_mode: + TOK_DEFAULT { $$ = L_DEFAULT; } + | TOK_STACKED { $$ = L_STACKED; } + | TOK_TABBED { $$ = L_TABBED; } + ; diff --git a/src/render.c b/src/render.c index c0dbdd5f..51e0fc26 100644 --- a/src/render.c +++ b/src/render.c @@ -124,7 +124,8 @@ void render_con(Con *con) { /* in a stacking container, we ensure the focused client is raised */ if (con->layout == L_STACKED) { Con *foc = TAILQ_FIRST(&(con->focus_head)); - x_raise_con(foc); + if (foc != TAILQ_END(&(con->focus_head))) + x_raise_con(foc); } TAILQ_FOREACH(child, &(con->floating_head), floating_windows) { -- 2.39.5