refactor tree_move() into src/move.c, change config (!), change testcase
Due to lots of cases which were added and added to tree_move(), the function was not really easy to understand. For this refactoring, I wrote tree_move() from scratch, thinking about (hopefully) all cases. The testsuite still passes. The move command also has different parameters now. Instead of the hard to understand 'before v' stuff, we use 'move [left|right|up|down]'.
This commit is contained in:
@ -487,3 +487,36 @@ void workspace_update_urgent_flag(Con *ws) {
|
||||
if (old_flag != ws->urgent)
|
||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"urgent\"}");
|
||||
}
|
||||
|
||||
void ws_force_orientation(Con *ws, orientation_t orientation) {
|
||||
/* 1: create a new split container */
|
||||
Con *split = con_new(NULL);
|
||||
split->parent = ws;
|
||||
|
||||
/* 2: copy layout and orientation from workspace */
|
||||
split->layout = ws->layout;
|
||||
split->orientation = ws->orientation;
|
||||
|
||||
Con *old_focused = TAILQ_FIRST(&(ws->focus_head));
|
||||
|
||||
/* 3: move the existing cons of this workspace below the new con */
|
||||
DLOG("Moving cons\n");
|
||||
while (!TAILQ_EMPTY(&(ws->nodes_head))) {
|
||||
Con *child = TAILQ_FIRST(&(ws->nodes_head));
|
||||
con_detach(child);
|
||||
con_attach(child, split, true);
|
||||
}
|
||||
|
||||
/* 4: switch workspace orientation */
|
||||
ws->orientation = orientation;
|
||||
|
||||
/* 5: attach the new split container to the workspace */
|
||||
DLOG("Attaching new split to ws\n");
|
||||
con_attach(split, ws, false);
|
||||
|
||||
/* 6: fix the percentages */
|
||||
con_fix_percent(ws);
|
||||
|
||||
if (old_focused)
|
||||
con_focus(old_focused);
|
||||
}
|
||||
|
Reference in New Issue
Block a user