diff options
author | Drew DeVault <[email protected]> | 2015-08-15 15:06:52 -0400 |
---|---|---|
committer | Drew DeVault <[email protected]> | 2015-08-15 15:06:52 -0400 |
commit | 648675c87a3360949fdccd9947e419214fdc6ff4 (patch) | |
tree | 870db1e093ea5d4eb53ec6a5d11a1bfbe46d3baf /sway/commands.c | |
parent | f7f739c0576b4cf2fe9e5748fcdf861c0d970523 (diff) | |
parent | 9bb2788768d5a52b1947a06dfbed65ec59a6f80c (diff) |
Merge pull request #30 from taiyu-len/master
fixed split
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sway/commands.c b/sway/commands.c index 5f378a98..6ccc92fd 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -226,6 +226,7 @@ static bool cmd_set(struct sway_config *config, int argc, char **argv) { list_add(config->symbols, var); return true; } +static void container_log(const swayc_t *c); static bool _do_split(struct sway_config *config, int argc, char **argv, int layout) { char *name = layout == L_VERT ? "splitv" : @@ -235,20 +236,27 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay } swayc_t *focused = get_focused_container(&root_container); - /* Case that focus is on an empty workspace. change its layout */ - if (focused->type == C_WORKSPACE) { + container_log(focused); + + /* Case that focus is on an workspace with 0/1 children.change its layout */ + if (focused->type == C_WORKSPACE && focused->children->length <= 1) { + sway_log(L_DEBUG, "changing workspace layout"); focused->layout = layout; - return true; } /* Case of no siblings. change parent layout */ - if (focused->parent->children->length == 1) { + else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) { + sway_log(L_DEBUG, "changing container layout"); focused->parent->layout = layout; - return true; } - /* regular case where new split container is build around focused container */ - swayc_t *parent = new_container(focused, layout); - focus_view(focused); - arrange_windows(parent, -1, -1); + /* regular case where new split container is build around focused container + * or in case of workspace, container inherits its children */ + else { + sway_log(L_DEBUG, "Adding new container around current focused container"); + swayc_t *parent = new_container(focused, layout); + focus_view(focused); + arrange_windows(parent, -1, -1); + } + container_log(focused); return true; } |