parser: implement move

This commit is contained in:
Michael Stapelberg 2010-06-30 22:23:32 +02:00
parent 565ef78b12
commit 6d152103f5
3 changed files with 42 additions and 0 deletions

View File

@ -19,4 +19,6 @@ enum { WINDOW_ADD = 0, WINDOW_REMOVE = 1 };
void con_fix_percent(Con *con, int action); void con_fix_percent(Con *con, int action);
void con_toggle_fullscreen(Con *con); void con_toggle_fullscreen(Con *con);
void con_move_to_workspace(Con *con, Con *workspace);
#endif #endif

View File

@ -495,6 +495,24 @@ move:
* we should not need any of both */ * we should not need any of both */
tree_move(($<number>3 == TOK_BEFORE ? 'p' : 'n'), ($<chr>5 == 'v' ? VERT : HORIZ)); tree_move(($<number>3 == TOK_BEFORE ? 'p' : 'n'), ($<chr>5 == 'v' ? VERT : HORIZ));
} }
| TOK_MOVE WHITESPACE TOK_WORKSPACE WHITESPACE STR
{
owindow *current;
printf("should move window to workspace %s\n", $<string>5);
/* get the workspace */
Con *ws = workspace_get($<string>5);
/* check if the match is empty, not if the result is empty */
if (match_is_empty(&current_match))
con_move_to_workspace(focused, ws);
else {
TAILQ_FOREACH(current, &owindows, owindows) {
printf("matching: %p / %s\n", current->con, current->con->name);
con_move_to_workspace(current->con, ws);
}
}
}
; ;
before_after: before_after:

View File

@ -315,3 +315,25 @@ void con_toggle_fullscreen(Con *con) {
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id, xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id,
atoms[_NET_WM_STATE], ATOM, 32, num, values); atoms[_NET_WM_STATE], ATOM, 32, num, values);
} }
/*
* TODO: is there a better place for this function?
*
*/
void con_move_to_workspace(Con *con, Con *workspace) {
/* 1: get the focused container of this workspace by going down as far as
* possible */
Con *next = workspace;
while (!TAILQ_EMPTY(&(next->focus_head)))
next = TAILQ_FIRST(&(next->focus_head));
/* 2: we go up one level, but only when next is a normal container */
if (next->type != CT_WORKSPACE)
next = next->parent;
DLOG("Re-attaching container to %p / %s\n", next, next->name);
/* 3: re-attach the con to the parent of this focused container */
con_detach(con);
con_attach(con, next);
}