Make splitting a container which was already split a noop
This commit is contained in:
parent
18f7e1ffd1
commit
b467242d69
|
@ -41,7 +41,7 @@ typedef struct Window i3Window;
|
||||||
* Helper types
|
* Helper types
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
|
typedef enum { D_LEFT, D_RIGHT, D_UP, D_DOWN } direction_t;
|
||||||
typedef enum { HORIZ, VERT, NO_ORIENTATION } orientation_t;
|
typedef enum { NO_ORIENTATION = 0, HORIZ, VERT } orientation_t;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BIND_NONE = 0,
|
BIND_NONE = 0,
|
||||||
|
|
11
src/tree.c
11
src/tree.c
|
@ -74,6 +74,7 @@ void tree_init() {
|
||||||
ws->type = CT_WORKSPACE;
|
ws->type = CT_WORKSPACE;
|
||||||
ws->name = strdup("1");
|
ws->name = strdup("1");
|
||||||
ws->fullscreen_mode = CF_OUTPUT;
|
ws->fullscreen_mode = CF_OUTPUT;
|
||||||
|
ws->orientation = HORIZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
con_focus(ws);
|
con_focus(ws);
|
||||||
|
@ -203,9 +204,17 @@ void tree_split(Con *con, orientation_t orientation) {
|
||||||
con->orientation = orientation;
|
con->orientation = orientation;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Con *parent = con->parent;
|
||||||
|
/* if we are in a container whose parent contains only one
|
||||||
|
* child and has the same orientation like we are trying to
|
||||||
|
* set, this operation is a no-op to not confuse the user */
|
||||||
|
if (parent->orientation == orientation &&
|
||||||
|
TAILQ_NEXT(con, nodes) == TAILQ_END(&(parent->nodes_head)))
|
||||||
|
return;
|
||||||
|
|
||||||
/* 2: replace it with a new Con */
|
/* 2: replace it with a new Con */
|
||||||
Con *new = con_new(NULL);
|
Con *new = con_new(NULL);
|
||||||
Con *parent = con->parent;
|
|
||||||
TAILQ_REPLACE(&(parent->nodes_head), con, new, nodes);
|
TAILQ_REPLACE(&(parent->nodes_head), con, new, nodes);
|
||||||
TAILQ_REPLACE(&(parent->focus_head), con, new, focused);
|
TAILQ_REPLACE(&(parent->focus_head), con, new, focused);
|
||||||
new->parent = parent;
|
new->parent = parent;
|
||||||
|
|
|
@ -41,6 +41,7 @@ Con *workspace_get(const char *num) {
|
||||||
workspace = con_new(output);
|
workspace = con_new(output);
|
||||||
workspace->type = CT_WORKSPACE;
|
workspace->type = CT_WORKSPACE;
|
||||||
workspace->name = strdup(num);
|
workspace->name = strdup(num);
|
||||||
|
workspace->orientation = HORIZ;
|
||||||
|
|
||||||
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
|
ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, "{\"change\":\"init\"}");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue