diff options
-rw-r--r-- | include/sway/container.h | 7 | ||||
-rw-r--r-- | sway/commands/layout.c | 16 | ||||
-rw-r--r-- | sway/commands/move.c | 4 | ||||
-rw-r--r-- | sway/commands/split.c | 4 | ||||
-rw-r--r-- | sway/container.c | 15 | ||||
-rw-r--r-- | sway/handlers.c | 11 | ||||
-rw-r--r-- | sway/layout.c | 13 |
7 files changed, 26 insertions, 44 deletions
diff --git a/include/sway/container.h b/include/sway/container.h index 90825a49..5e251885 100644 --- a/include/sway/container.h +++ b/include/sway/container.h | |||
@@ -68,7 +68,6 @@ struct sway_container { | |||
68 | enum swayc_types type; | 68 | enum swayc_types type; |
69 | enum swayc_layouts layout; | 69 | enum swayc_layouts layout; |
70 | enum swayc_layouts prev_layout; | 70 | enum swayc_layouts prev_layout; |
71 | enum swayc_layouts workspace_layout; | ||
72 | 71 | ||
73 | /** | 72 | /** |
74 | * Width and height of this container, without borders or gaps. | 73 | * Width and height of this container, without borders or gaps. |
@@ -322,10 +321,4 @@ void update_visibility(swayc_t *container); | |||
322 | */ | 321 | */ |
323 | void close_views(swayc_t *container); | 322 | void close_views(swayc_t *container); |
324 | 323 | ||
325 | /** | ||
326 | * Assign layout to a container. Needed due to workspace container specifics. | ||
327 | * Workspace always needs L_HORIZ layout. | ||
328 | */ | ||
329 | swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout); | ||
330 | |||
331 | #endif | 324 | #endif |
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index a716f9be..e0af30aa 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -22,10 +22,10 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
22 | enum swayc_layouts old_layout = parent->layout; | 22 | enum swayc_layouts old_layout = parent->layout; |
23 | 23 | ||
24 | if (strcasecmp(argv[0], "default") == 0) { | 24 | if (strcasecmp(argv[0], "default") == 0) { |
25 | swayc_change_layout(parent, parent->prev_layout); | 25 | parent->layout = parent->prev_layout; |
26 | if (parent->layout == L_NONE) { | 26 | if (parent->layout == L_NONE) { |
27 | swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT); | 27 | swayc_t *output = swayc_parent_by_type(parent, C_OUTPUT); |
28 | swayc_change_layout(parent, default_layout(output)); | 28 | parent->layout = default_layout(output); |
29 | } | 29 | } |
30 | } else { | 30 | } else { |
31 | if (parent->layout != L_TABBED && parent->layout != L_STACKED) { | 31 | if (parent->layout != L_TABBED && parent->layout != L_STACKED) { |
@@ -37,22 +37,22 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
37 | parent = new_container(parent, L_TABBED); | 37 | parent = new_container(parent, L_TABBED); |
38 | } | 38 | } |
39 | 39 | ||
40 | swayc_change_layout(parent, L_TABBED); | 40 | parent->layout = L_TABBED; |
41 | } else if (strcasecmp(argv[0], "stacking") == 0) { | 41 | } else if (strcasecmp(argv[0], "stacking") == 0) { |
42 | if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)) { | 42 | if (parent->type != C_CONTAINER && !swayc_is_empty_workspace(parent)) { |
43 | parent = new_container(parent, L_STACKED); | 43 | parent = new_container(parent, L_STACKED); |
44 | } | 44 | } |
45 | 45 | ||
46 | swayc_change_layout(parent, L_STACKED); | 46 | parent->layout = L_STACKED; |
47 | } else if (strcasecmp(argv[0], "splith") == 0) { | 47 | } else if (strcasecmp(argv[0], "splith") == 0) { |
48 | swayc_change_layout(parent, L_HORIZ); | 48 | parent->layout = L_HORIZ; |
49 | } else if (strcasecmp(argv[0], "splitv") == 0) { | 49 | } else if (strcasecmp(argv[0], "splitv") == 0) { |
50 | swayc_change_layout(parent, L_VERT); | 50 | parent->layout = L_VERT; |
51 | } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { | 51 | } else if (strcasecmp(argv[0], "toggle") == 0 && argc == 2 && strcasecmp(argv[1], "split") == 0) { |
52 | if (parent->layout == L_VERT) { | 52 | if (parent->layout == L_VERT) { |
53 | swayc_change_layout(parent, L_HORIZ); | 53 | parent->layout = L_HORIZ; |
54 | } else { | 54 | } else { |
55 | swayc_change_layout(parent, L_VERT); | 55 | parent->layout = L_VERT; |
56 | } | 56 | } |
57 | } | 57 | } |
58 | } | 58 | } |
diff --git a/sway/commands/move.c b/sway/commands/move.c index 4819d9ef..48e9d562 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -37,7 +37,7 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
37 | if (!view->children || view->children->length == 0) { | 37 | if (!view->children || view->children->length == 0) { |
38 | return cmd_results_new(CMD_FAILURE, "move", "Cannot move an empty workspace"); | 38 | return cmd_results_new(CMD_FAILURE, "move", "Cannot move an empty workspace"); |
39 | } | 39 | } |
40 | view = new_container(view, view->workspace_layout); | 40 | view = new_container(view, view->layout); |
41 | } if (view->type != C_CONTAINER && view->type != C_VIEW) { | 41 | } if (view->type != C_CONTAINER && view->type != C_VIEW) { |
42 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); | 42 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); |
43 | } | 43 | } |
@@ -65,7 +65,7 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
65 | if (!view->children || view->children->length == 0) { | 65 | if (!view->children || view->children->length == 0) { |
66 | return cmd_results_new(CMD_FAILURE, "move", "Cannot move an empty workspace"); | 66 | return cmd_results_new(CMD_FAILURE, "move", "Cannot move an empty workspace"); |
67 | } | 67 | } |
68 | view = new_container(view, view->workspace_layout); | 68 | view = new_container(view, view->layout); |
69 | } else if (view->type != C_CONTAINER && view->type != C_VIEW) { | 69 | } else if (view->type != C_CONTAINER && view->type != C_VIEW) { |
70 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); | 70 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); |
71 | } else if (!(output = output_by_name(argv[3], &abs_pos))) { | 71 | } else if (!(output = output_by_name(argv[3], &abs_pos))) { |
diff --git a/sway/commands/split.c b/sway/commands/split.c index f3e58fbf..9ff1d638 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c | |||
@@ -25,11 +25,11 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) { | |||
25 | /* Case that focus is on an workspace with 0/1 children.change its layout */ | 25 | /* Case that focus is on an workspace with 0/1 children.change its layout */ |
26 | if (focused->type == C_WORKSPACE && focused->children->length <= 1) { | 26 | if (focused->type == C_WORKSPACE && focused->children->length <= 1) { |
27 | sway_log(L_DEBUG, "changing workspace layout"); | 27 | sway_log(L_DEBUG, "changing workspace layout"); |
28 | swayc_change_layout(focused, layout); | 28 | focused->layout = layout; |
29 | } else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) { | 29 | } else if (focused->type != C_WORKSPACE && focused->parent->children->length == 1) { |
30 | /* Case of no siblings. change parent layout */ | 30 | /* Case of no siblings. change parent layout */ |
31 | sway_log(L_DEBUG, "changing container layout"); | 31 | sway_log(L_DEBUG, "changing container layout"); |
32 | swayc_change_layout(focused->parent, layout); | 32 | focused->parent->layout = layout; |
33 | } else { | 33 | } else { |
34 | /* regular case where new split container is build around focused container | 34 | /* regular case where new split container is build around focused container |
35 | * or in case of workspace, container inherits its children */ | 35 | * or in case of workspace, container inherits its children */ |
diff --git a/sway/container.c b/sway/container.c index c3461acb..9d5e2690 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -27,7 +27,6 @@ static swayc_t *new_swayc(enum swayc_types type) { | |||
27 | c->handle = -1; | 27 | c->handle = -1; |
28 | c->gaps = -1; | 28 | c->gaps = -1; |
29 | c->layout = L_NONE; | 29 | c->layout = L_NONE; |
30 | c->workspace_layout = L_NONE; | ||
31 | c->type = type; | 30 | c->type = type; |
32 | if (type != C_VIEW) { | 31 | if (type != C_VIEW) { |
33 | c->children = create_list(); | 32 | c->children = create_list(); |
@@ -210,8 +209,7 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { | |||
210 | swayc_t *workspace = new_swayc(C_WORKSPACE); | 209 | swayc_t *workspace = new_swayc(C_WORKSPACE); |
211 | 210 | ||
212 | workspace->prev_layout = L_NONE; | 211 | workspace->prev_layout = L_NONE; |
213 | workspace->layout = L_HORIZ; | 212 | workspace->layout = default_layout(output); |
214 | workspace->workspace_layout = default_layout(output); | ||
215 | 213 | ||
216 | workspace->x = output->x; | 214 | workspace->x = output->x; |
217 | workspace->y = output->y; | 215 | workspace->y = output->y; |
@@ -264,7 +262,7 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) { | |||
264 | // add container to workspace chidren | 262 | // add container to workspace chidren |
265 | add_child(workspace, cont); | 263 | add_child(workspace, cont); |
266 | // give them proper layouts | 264 | // give them proper layouts |
267 | cont->layout = workspace->workspace_layout; | 265 | cont->layout = workspace->layout; |
268 | cont->prev_layout = workspace->prev_layout; | 266 | cont->prev_layout = workspace->prev_layout; |
269 | /* TODO: might break shit in move_container!!! workspace->layout = layout; */ | 267 | /* TODO: might break shit in move_container!!! workspace->layout = layout; */ |
270 | set_focused_container_for(workspace, get_focused_view(workspace)); | 268 | set_focused_container_for(workspace, get_focused_view(workspace)); |
@@ -931,12 +929,3 @@ swayc_t *swayc_tabbed_stacked_parent(swayc_t *con) { | |||
931 | } | 929 | } |
932 | return NULL; | 930 | return NULL; |
933 | } | 931 | } |
934 | |||
935 | swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout) { | ||
936 | if (container->type == C_WORKSPACE) { | ||
937 | container->workspace_layout = layout; | ||
938 | } else { | ||
939 | container->layout = layout; | ||
940 | } | ||
941 | return container; | ||
942 | } | ||
diff --git a/sway/handlers.c b/sway/handlers.c index 9a84182a..2235bc8b 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -398,6 +398,17 @@ static bool handle_view_created(wlc_handle handle) { | |||
398 | if (workspace && workspace->fullscreen) { | 398 | if (workspace && workspace->fullscreen) { |
399 | set_focused_container(workspace->fullscreen); | 399 | set_focused_container(workspace->fullscreen); |
400 | } | 400 | } |
401 | |||
402 | // if parent container is a workspace, newview its only child and | ||
403 | // layout is tabbed/stacked, add a container around newview | ||
404 | swayc_t *parent_container = newview->parent; | ||
405 | if (parent_container && parent_container->type == C_WORKSPACE && | ||
406 | parent_container->children && parent_container->children->length == 1 && | ||
407 | (parent_container->layout == L_TABBED || parent_container->layout == L_STACKED)) { | ||
408 | swayc_t *container = new_container(newview, parent_container->layout); | ||
409 | set_focused_container(newview); | ||
410 | arrange_windows(container, -1, -1); | ||
411 | } | ||
401 | } else { | 412 | } else { |
402 | swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); | 413 | swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); |
403 | wlc_handle *h = malloc(sizeof(wlc_handle)); | 414 | wlc_handle *h = malloc(sizeof(wlc_handle)); |
diff --git a/sway/layout.c b/sway/layout.c index 8565113d..4f2ea09a 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -66,11 +66,6 @@ void add_child(swayc_t *parent, swayc_t *child) { | |||
66 | if (!parent->focused) { | 66 | if (!parent->focused) { |
67 | parent->focused = child; | 67 | parent->focused = child; |
68 | } | 68 | } |
69 | |||
70 | // wrap view into a container | ||
71 | if (parent->type == C_WORKSPACE && child->type == C_VIEW) { | ||
72 | new_container(child, parent->workspace_layout); | ||
73 | } | ||
74 | } | 69 | } |
75 | 70 | ||
76 | void insert_child(swayc_t *parent, swayc_t *child, int index) { | 71 | void insert_child(swayc_t *parent, swayc_t *child, int index) { |
@@ -85,11 +80,6 @@ void insert_child(swayc_t *parent, swayc_t *child, int index) { | |||
85 | if (!parent->focused) { | 80 | if (!parent->focused) { |
86 | parent->focused = child; | 81 | parent->focused = child; |
87 | } | 82 | } |
88 | |||
89 | // wrap view into a container | ||
90 | if (parent->type == C_WORKSPACE && child->type == C_VIEW) { | ||
91 | new_container(child, parent->workspace_layout); | ||
92 | } | ||
93 | } | 83 | } |
94 | 84 | ||
95 | void add_floating(swayc_t *ws, swayc_t *child) { | 85 | void add_floating(swayc_t *ws, swayc_t *child) { |
@@ -312,8 +302,7 @@ void move_container(swayc_t *container, enum movement_direction dir) { | |||
312 | } | 302 | } |
313 | // Change parent layout if we need to | 303 | // Change parent layout if we need to |
314 | if (parent->children->length == 1 && parent->layout != layout) { | 304 | if (parent->children->length == 1 && parent->layout != layout) { |
315 | swayc_change_layout(parent, layout); | 305 | parent->layout = layout; |
316 | /* parent->layout = layout; */ | ||
317 | continue; | 306 | continue; |
318 | } | 307 | } |
319 | if (parent->type == C_WORKSPACE) { | 308 | if (parent->type == C_WORKSPACE) { |