parser: implement 'layout'

This commit is contained in:
Michael Stapelberg 2010-06-01 23:20:57 +02:00
parent b467242d69
commit cea8f91e18
3 changed files with 29 additions and 2 deletions

View File

@ -88,6 +88,7 @@ global { return TOK_GLOBAL; }
layout { return TOK_LAYOUT; } layout { return TOK_LAYOUT; }
default { return TOK_DEFAULT; } default { return TOK_DEFAULT; }
stacked { return TOK_STACKED; } stacked { return TOK_STACKED; }
stacking { return TOK_STACKED; }
tabbed { return TOK_TABBED; } tabbed { return TOK_TABBED; }
border { return TOK_BORDER; } border { return TOK_BORDER; }
none { return TOK_NONE; } none { return TOK_NONE; }

View File

@ -252,8 +252,8 @@ operation:
| restart | restart
/*| reload /*| reload
| mark | mark
| layout
| border */ | border */
| layout
| restore | restore
| move | move
| workspace | workspace
@ -466,3 +466,28 @@ restore:
tree_append_json($<string>3); tree_append_json($<string>3);
} }
; ;
layout:
TOK_LAYOUT WHITESPACE layout_mode
{
printf("changing layout to %d\n", $<number>3);
owindow *current;
/* check if the match is empty, not if the result is empty */
if (match_is_empty(&current_match))
focused->layout = $<number>3;
else {
TAILQ_FOREACH(current, &owindows, owindows) {
printf("matching: %p / %s\n", current->con, current->con->name);
current->con->layout = $<number>3;
}
}
}
;
layout_mode:
TOK_DEFAULT { $<number>$ = L_DEFAULT; }
| TOK_STACKED { $<number>$ = L_STACKED; }
| TOK_TABBED { $<number>$ = L_TABBED; }
;

View File

@ -124,6 +124,7 @@ void render_con(Con *con) {
/* in a stacking container, we ensure the focused client is raised */ /* in a stacking container, we ensure the focused client is raised */
if (con->layout == L_STACKED) { if (con->layout == L_STACKED) {
Con *foc = TAILQ_FIRST(&(con->focus_head)); Con *foc = TAILQ_FIRST(&(con->focus_head));
if (foc != TAILQ_END(&(con->focus_head)))
x_raise_con(foc); x_raise_con(foc);
} }