void con_fix_percent(Con *con, int action);
void con_toggle_fullscreen(Con *con);
+void con_move_to_workspace(Con *con, Con *workspace);
+
#endif
* we should not need any of both */
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(¤t_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:
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id,
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);
+}