diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/gaps.c | 306 | ||||
-rw-r--r-- | sway/commands/layout.c | 3 | ||||
-rw-r--r-- | sway/commands/workspace.c | 38 | ||||
-rw-r--r-- | sway/sway.5.scd | 24 | ||||
-rw-r--r-- | sway/tree/container.c | 2 | ||||
-rw-r--r-- | sway/tree/workspace.c | 18 |
6 files changed, 223 insertions, 168 deletions
diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c index d676e475..2e0876a9 100644 --- a/sway/commands/gaps.c +++ b/sway/commands/gaps.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #include <string.h> | 1 | #include <string.h> |
2 | #include <strings.h> | ||
2 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
3 | #include "sway/config.h" | 4 | #include "sway/config.h" |
4 | #include "sway/tree/arrange.h" | 5 | #include "sway/tree/arrange.h" |
@@ -13,172 +14,173 @@ enum gaps_op { | |||
13 | GAPS_OP_SUBTRACT | 14 | GAPS_OP_SUBTRACT |
14 | }; | 15 | }; |
15 | 16 | ||
16 | enum gaps_scope { | 17 | struct gaps_data { |
17 | GAPS_SCOPE_ALL, | 18 | bool inner; |
18 | GAPS_SCOPE_WORKSPACE, | 19 | enum gaps_op operation; |
19 | GAPS_SCOPE_CURRENT | 20 | int amount; |
20 | }; | 21 | }; |
21 | 22 | ||
22 | struct cmd_results *cmd_gaps(int argc, char **argv) { | 23 | // gaps edge_gaps on|off|toggle |
23 | struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1); | 24 | static struct cmd_results *gaps_edge_gaps(int argc, char **argv) { |
24 | if (error) { | 25 | struct cmd_results *error; |
26 | if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 2))) { | ||
25 | return error; | 27 | return error; |
26 | } | 28 | } |
27 | 29 | ||
28 | if (strcmp(argv[0], "edge_gaps") == 0) { | 30 | if (strcmp(argv[1], "on") == 0) { |
29 | if ((error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 2))) { | 31 | config->edge_gaps = true; |
30 | return error; | 32 | } else if (strcmp(argv[1], "off") == 0) { |
31 | } | 33 | config->edge_gaps = false; |
32 | 34 | } else if (strcmp(argv[1], "toggle") == 0) { | |
33 | if (strcmp(argv[1], "on") == 0) { | 35 | if (!config->active) { |
34 | config->edge_gaps = true; | ||
35 | } else if (strcmp(argv[1], "off") == 0) { | ||
36 | config->edge_gaps = false; | ||
37 | } else if (strcmp(argv[1], "toggle") == 0) { | ||
38 | if (!config->active) { | ||
39 | return cmd_results_new(CMD_INVALID, "gaps", | ||
40 | "Cannot toggle gaps while not running."); | ||
41 | } | ||
42 | config->edge_gaps = !config->edge_gaps; | ||
43 | } else { | ||
44 | return cmd_results_new(CMD_INVALID, "gaps", | 36 | return cmd_results_new(CMD_INVALID, "gaps", |
45 | "gaps edge_gaps on|off|toggle"); | 37 | "Cannot toggle gaps while not running."); |
46 | } | 38 | } |
47 | arrange_root(); | 39 | config->edge_gaps = !config->edge_gaps; |
48 | } else { | 40 | } else { |
49 | int amount_idx = 0; // the current index in argv | 41 | return cmd_results_new(CMD_INVALID, "gaps", |
50 | enum gaps_op op = GAPS_OP_SET; | 42 | "gaps edge_gaps on|off|toggle"); |
51 | enum gaps_scope scope = GAPS_SCOPE_ALL; | 43 | } |
52 | bool inner = true; | 44 | arrange_root(); |
53 | 45 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | |
54 | if (strcmp(argv[0], "inner") == 0) { | 46 | } |
55 | amount_idx++; | ||
56 | inner = true; | ||
57 | } else if (strcmp(argv[0], "outer") == 0) { | ||
58 | amount_idx++; | ||
59 | inner = false; | ||
60 | } | ||
61 | 47 | ||
62 | // If one of the long variants of the gaps command is used | 48 | // gaps inner|outer <px> |
63 | // (which starts with inner|outer) check the number of args | 49 | static struct cmd_results *gaps_set_defaults(int argc, char **argv) { |
64 | if (amount_idx > 0) { // if we've seen inner|outer | 50 | struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 2); |
65 | if (argc > 2) { // check the longest variant | 51 | if (error) { |
66 | error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 4); | 52 | return error; |
67 | if (error) { | 53 | } |
68 | return error; | ||
69 | } | ||
70 | } else { // check the next longest format | ||
71 | error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 2); | ||
72 | if (error) { | ||
73 | return error; | ||
74 | } | ||
75 | } | ||
76 | } else { | ||
77 | error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 1); | ||
78 | if (error) { | ||
79 | return error; | ||
80 | } | ||
81 | } | ||
82 | 54 | ||
83 | if (argc == 4) { | 55 | bool inner; |
84 | // Long format: all|workspace|current. | 56 | if (strcasecmp(argv[0], "inner") == 0) { |
85 | if (strcmp(argv[amount_idx], "all") == 0) { | 57 | inner = true; |
86 | amount_idx++; | 58 | } else if (strcasecmp(argv[0], "outer") == 0) { |
87 | scope = GAPS_SCOPE_ALL; | 59 | inner = false; |
88 | } else if (strcmp(argv[amount_idx], "workspace") == 0) { | 60 | } else { |
89 | amount_idx++; | 61 | return cmd_results_new(CMD_INVALID, "gaps", |
90 | scope = GAPS_SCOPE_WORKSPACE; | 62 | "Expected 'gaps inner|outer <px>'"); |
91 | } else if (strcmp(argv[amount_idx], "current") == 0) { | 63 | } |
92 | amount_idx++; | ||
93 | scope = GAPS_SCOPE_CURRENT; | ||
94 | } | ||
95 | |||
96 | // Long format: set|plus|minus | ||
97 | if (strcmp(argv[amount_idx], "set") == 0) { | ||
98 | amount_idx++; | ||
99 | op = GAPS_OP_SET; | ||
100 | } else if (strcmp(argv[amount_idx], "plus") == 0) { | ||
101 | amount_idx++; | ||
102 | op = GAPS_OP_ADD; | ||
103 | } else if (strcmp(argv[amount_idx], "minus") == 0) { | ||
104 | amount_idx++; | ||
105 | op = GAPS_OP_SUBTRACT; | ||
106 | } | ||
107 | } | ||
108 | 64 | ||
109 | char *end; | 65 | char *end; |
110 | double val = strtod(argv[amount_idx], &end); | 66 | int amount = strtol(argv[1], &end, 10); |
111 | 67 | if (strlen(end) && strcasecmp(end, "px") != 0) { | |
112 | if (strlen(end) && val == 0.0) { // invalid <amount> | 68 | return cmd_results_new(CMD_INVALID, "gaps", |
113 | // guess which variant of the command was attempted | 69 | "Expected 'gaps inner|outer <px>'"); |
114 | if (argc == 1) { | 70 | } |
115 | return cmd_results_new(CMD_INVALID, "gaps", "gaps <amount>"); | 71 | if (amount < 0) { |
116 | } | 72 | amount = 0; |
117 | if (argc == 2) { | 73 | } |
118 | return cmd_results_new(CMD_INVALID, "gaps", | ||
119 | "gaps inner|outer <amount>"); | ||
120 | } | ||
121 | return cmd_results_new(CMD_INVALID, "gaps", | ||
122 | "gaps inner|outer all|workspace|current set|plus|minus <amount>"); | ||
123 | } | ||
124 | 74 | ||
125 | if (amount_idx == 0) { // gaps <amount> | 75 | if (inner) { |
126 | config->gaps_inner = val; | 76 | config->gaps_inner = amount; |
127 | config->gaps_outer = val; | 77 | } else { |
128 | arrange_root(); | 78 | config->gaps_outer = amount; |
129 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 79 | } |
130 | } | 80 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
131 | // Other variants. The middle-length variant (gaps inner|outer <amount>) | 81 | } |
132 | // just defaults the scope to "all" and defaults the op to "set". | ||
133 | |||
134 | double total; | ||
135 | switch (op) { | ||
136 | case GAPS_OP_SUBTRACT: { | ||
137 | total = (inner ? config->gaps_inner : config->gaps_outer) - val; | ||
138 | if (total < 0) { | ||
139 | total = 0; | ||
140 | } | ||
141 | break; | ||
142 | } | ||
143 | case GAPS_OP_ADD: { | ||
144 | total = (inner ? config->gaps_inner : config->gaps_outer) + val; | ||
145 | break; | ||
146 | } | ||
147 | case GAPS_OP_SET: { | ||
148 | total = val; | ||
149 | break; | ||
150 | } | ||
151 | } | ||
152 | 82 | ||
153 | if (scope == GAPS_SCOPE_ALL) { | 83 | static void configure_gaps(struct sway_workspace *ws, void *_data) { |
154 | if (inner) { | 84 | struct gaps_data *data = _data; |
155 | config->gaps_inner = total; | 85 | int *prop = data->inner ? &ws->gaps_inner : &ws->gaps_outer; |
156 | } else { | 86 | |
157 | config->gaps_outer = total; | 87 | switch (data->operation) { |
158 | } | 88 | case GAPS_OP_SET: |
159 | arrange_root(); | 89 | *prop = data->amount; |
160 | } else { | 90 | break; |
161 | if (scope == GAPS_SCOPE_WORKSPACE) { | 91 | case GAPS_OP_ADD: |
162 | struct sway_workspace *ws = config->handler_context.workspace; | 92 | *prop += data->amount; |
163 | ws->has_gaps = true; | 93 | break; |
164 | if (inner) { | 94 | case GAPS_OP_SUBTRACT: |
165 | ws->gaps_inner = total; | 95 | *prop -= data->amount; |
166 | } else { | 96 | break; |
167 | ws->gaps_outer = total; | 97 | } |
168 | } | 98 | if (*prop < 0) { |
169 | arrange_workspace(ws); | 99 | *prop = 0; |
170 | } else { | 100 | } |
171 | struct sway_container *c = config->handler_context.container; | 101 | arrange_workspace(ws); |
172 | c->has_gaps = true; | 102 | } |
173 | if (inner) { | 103 | |
174 | c->gaps_inner = total; | 104 | // gaps inner|outer current|all set|plus|minus <px> |
175 | } else { | 105 | static struct cmd_results *gaps_set_runtime(int argc, char **argv) { |
176 | c->gaps_outer = total; | 106 | struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_EQUAL_TO, 4); |
177 | } | 107 | if (error) { |
178 | arrange_workspace(c->workspace); | 108 | return error; |
179 | } | 109 | } |
180 | } | 110 | |
111 | struct gaps_data data; | ||
112 | |||
113 | if (strcasecmp(argv[0], "inner") == 0) { | ||
114 | data.inner = true; | ||
115 | } else if (strcasecmp(argv[0], "outer") == 0) { | ||
116 | data.inner = false; | ||
117 | } else { | ||
118 | return cmd_results_new(CMD_INVALID, "gaps", | ||
119 | "Expected 'gaps inner|outer current|all set|plus|minus <px>'"); | ||
120 | } | ||
121 | |||
122 | bool all; | ||
123 | if (strcasecmp(argv[1], "current") == 0) { | ||
124 | all = false; | ||
125 | } else if (strcasecmp(argv[1], "all") == 0) { | ||
126 | all = true; | ||
127 | } else { | ||
128 | return cmd_results_new(CMD_INVALID, "gaps", | ||
129 | "Expected 'gaps inner|outer current|all set|plus|minus <px>'"); | ||
130 | } | ||
131 | |||
132 | if (strcasecmp(argv[2], "set") == 0) { | ||
133 | data.operation = GAPS_OP_SET; | ||
134 | } else if (strcasecmp(argv[2], "plus") == 0) { | ||
135 | data.operation = GAPS_OP_ADD; | ||
136 | } else if (strcasecmp(argv[2], "minus") == 0) { | ||
137 | data.operation = GAPS_OP_SUBTRACT; | ||
138 | } else { | ||
139 | return cmd_results_new(CMD_INVALID, "gaps", | ||
140 | "Expected 'gaps inner|outer current|all set|plus|minus <px>'"); | ||
141 | } | ||
142 | |||
143 | char *end; | ||
144 | data.amount = strtol(argv[3], &end, 10); | ||
145 | if (strlen(end) && strcasecmp(end, "px") != 0) { | ||
146 | return cmd_results_new(CMD_INVALID, "gaps", | ||
147 | "Expected 'gaps inner|outer current|all set|plus|minus <px>'"); | ||
148 | } | ||
149 | |||
150 | if (all) { | ||
151 | root_for_each_workspace(configure_gaps, &data); | ||
152 | } else { | ||
153 | configure_gaps(config->handler_context.workspace, &data); | ||
181 | } | 154 | } |
182 | 155 | ||
183 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 156 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
184 | } | 157 | } |
158 | |||
159 | // gaps edge_gaps on|off|toggle | ||
160 | // gaps inner|outer <px> - sets defaults for workspaces | ||
161 | // gaps inner|outer current|all set|plus|minus <px> - runtime only | ||
162 | struct cmd_results *cmd_gaps(int argc, char **argv) { | ||
163 | struct cmd_results *error = checkarg(argc, "gaps", EXPECTED_AT_LEAST, 2); | ||
164 | if (error) { | ||
165 | return error; | ||
166 | } | ||
167 | |||
168 | if (strcmp(argv[0], "edge_gaps") == 0) { | ||
169 | return gaps_edge_gaps(argc, argv); | ||
170 | } | ||
171 | |||
172 | if (argc == 2) { | ||
173 | return gaps_set_defaults(argc, argv); | ||
174 | } | ||
175 | if (argc == 4) { | ||
176 | if (config->active) { | ||
177 | return gaps_set_runtime(argc, argv); | ||
178 | } else { | ||
179 | return cmd_results_new(CMD_INVALID, "gaps", | ||
180 | "This syntax can only be used when sway is running"); | ||
181 | } | ||
182 | } | ||
183 | return cmd_results_new(CMD_INVALID, "gaps", | ||
184 | "Expected 'gaps inner|outer <px>' or " | ||
185 | "'gaps inner|outer current|all set|plus|minus <px>'"); | ||
186 | } | ||
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index ef3ec1cb..c2ce2e78 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -138,15 +138,14 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
138 | } | 138 | } |
139 | container->layout = new_layout; | 139 | container->layout = new_layout; |
140 | container_update_representation(container); | 140 | container_update_representation(container); |
141 | arrange_container(container); | ||
142 | } else { | 141 | } else { |
143 | if (old_layout != L_TABBED && old_layout != L_STACKED) { | 142 | if (old_layout != L_TABBED && old_layout != L_STACKED) { |
144 | workspace->prev_split_layout = old_layout; | 143 | workspace->prev_split_layout = old_layout; |
145 | } | 144 | } |
146 | workspace->layout = new_layout; | 145 | workspace->layout = new_layout; |
147 | workspace_update_representation(workspace); | 146 | workspace_update_representation(workspace); |
148 | arrange_workspace(workspace); | ||
149 | } | 147 | } |
148 | arrange_workspace(workspace); | ||
150 | } | 149 | } |
151 | 150 | ||
152 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 151 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 2ce7872d..63f29641 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -20,6 +20,8 @@ static struct workspace_config *workspace_config_find_or_create(char *ws_name) { | |||
20 | return NULL; | 20 | return NULL; |
21 | } | 21 | } |
22 | wsc->workspace = strdup(ws_name); | 22 | wsc->workspace = strdup(ws_name); |
23 | wsc->gaps_inner = -1; | ||
24 | wsc->gaps_outer = -1; | ||
23 | list_add(config->workspace_configs, wsc); | 25 | list_add(config->workspace_configs, wsc); |
24 | return wsc; | 26 | return wsc; |
25 | } | 27 | } |
@@ -37,6 +39,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
37 | } | 39 | } |
38 | 40 | ||
39 | int output_location = -1; | 41 | int output_location = -1; |
42 | int gaps_location = -1; | ||
40 | 43 | ||
41 | for (int i = 0; i < argc; ++i) { | 44 | for (int i = 0; i < argc; ++i) { |
42 | if (strcasecmp(argv[i], "output") == 0) { | 45 | if (strcasecmp(argv[i], "output") == 0) { |
@@ -44,6 +47,12 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
44 | break; | 47 | break; |
45 | } | 48 | } |
46 | } | 49 | } |
50 | for (int i = 0; i < argc; ++i) { | ||
51 | if (strcasecmp(argv[i], "gaps") == 0) { | ||
52 | gaps_location = i; | ||
53 | break; | ||
54 | } | ||
55 | } | ||
47 | if (output_location >= 0) { | 56 | if (output_location >= 0) { |
48 | if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) { | 57 | if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, output_location + 2))) { |
49 | return error; | 58 | return error; |
@@ -57,6 +66,35 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
57 | } | 66 | } |
58 | free(wsc->output); | 67 | free(wsc->output); |
59 | wsc->output = strdup(argv[output_location + 1]); | 68 | wsc->output = strdup(argv[output_location + 1]); |
69 | } else if (gaps_location >= 0) { | ||
70 | if ((error = checkarg(argc, "workspace", EXPECTED_EQUAL_TO, gaps_location + 3))) { | ||
71 | return error; | ||
72 | } | ||
73 | char *ws_name = join_args(argv, argc - 3); | ||
74 | struct workspace_config *wsc = workspace_config_find_or_create(ws_name); | ||
75 | free(ws_name); | ||
76 | if (!wsc) { | ||
77 | return cmd_results_new(CMD_FAILURE, "workspace gaps", | ||
78 | "Unable to allocate workspace output"); | ||
79 | } | ||
80 | int *prop = NULL; | ||
81 | if (strcasecmp(argv[gaps_location + 1], "inner") == 0) { | ||
82 | prop = &wsc->gaps_inner; | ||
83 | } else if (strcasecmp(argv[gaps_location + 1], "outer") == 0) { | ||
84 | prop = &wsc->gaps_outer; | ||
85 | } else { | ||
86 | return cmd_results_new(CMD_FAILURE, "workspace gaps", | ||
87 | "Expected 'workspace <ws> gaps inner|outer <px>'"); | ||
88 | } | ||
89 | char *end; | ||
90 | int val = strtol(argv[gaps_location + 2], &end, 10); | ||
91 | |||
92 | if (strlen(end)) { | ||
93 | free(end); | ||
94 | return cmd_results_new(CMD_FAILURE, "workspace gaps", | ||
95 | "Expected 'workspace <ws> gaps inner|outer <px>'"); | ||
96 | } | ||
97 | *prop = val >= 0 ? val : 0; | ||
60 | } else { | 98 | } else { |
61 | if (config->reading || !config->active) { | 99 | if (config->reading || !config->active) { |
62 | return cmd_results_new(CMD_DEFER, "workspace", NULL); | 100 | return cmd_results_new(CMD_DEFER, "workspace", NULL); |
diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 1526eee3..aa5b38ab 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd | |||
@@ -419,19 +419,17 @@ The default colors are: | |||
419 | inner gap is nonzero. When _off_, gaps will only be added between views. | 419 | inner gap is nonzero. When _off_, gaps will only be added between views. |
420 | _toggle_ cannot be used in the configuration file. | 420 | _toggle_ cannot be used in the configuration file. |
421 | 421 | ||
422 | *gaps* <amount> | ||
423 | Sets _amount_ pixels of gap between windows and around each workspace. | ||
424 | |||
425 | *gaps* inner|outer <amount> | 422 | *gaps* inner|outer <amount> |
426 | Sets default _amount_ pixels of _inner_ or _outer_ gap, where the former | 423 | Sets default _amount_ pixels of _inner_ or _outer_ gap, where the inner |
427 | affects spacing between views and the latter affects the space around each | 424 | affects spacing around each view and outer affects the spacing around each |
428 | workspace. | 425 | workspace. Outer gaps are in addition to inner gaps. |
426 | |||
427 | This affects new workspaces only, and is used when the workspace doesn't | ||
428 | have its own gaps settings (see: workspace <ws> gaps inner|outer <amount>). | ||
429 | 429 | ||
430 | *gaps* inner|outer all|workspace|current set|plus|minus <amount> | 430 | *gaps* inner|outer all|current set|plus|minus <amount> |
431 | Changes the gaps for the _inner_ or _outer_ gap. _all_ changes the gaps for | 431 | Changes the _inner_ or _outer_ gaps for either _all_ workspaces or the |
432 | all views or workspace, _workspace_ changes gaps for all views in current | 432 | _current_ workspace. |
433 | workspace (or current workspace), and _current_ changes gaps for the current | ||
434 | view or workspace. | ||
435 | 433 | ||
436 | *hide\_edge\_borders* none|vertical|horizontal|both|smart | 434 | *hide\_edge\_borders* none|vertical|horizontal|both|smart |
437 | Hides window borders adjacent to the screen edges. Default is _none_. | 435 | Hides window borders adjacent to the screen edges. Default is _none_. |
@@ -580,6 +578,10 @@ match any output by using the output name "\*". | |||
580 | *workspace* back_and_forth | 578 | *workspace* back_and_forth |
581 | Switches to the previously focused workspace. | 579 | Switches to the previously focused workspace. |
582 | 580 | ||
581 | *workspace* <name> gaps inner|outer <amount> | ||
582 | Specifies that workspace _name_ should have the given gaps settings when it | ||
583 | is created. | ||
584 | |||
583 | *workspace* <name> output <output> | 585 | *workspace* <name> output <output> |
584 | Specifies that workspace _name_ should be shown on the specified _output_. | 586 | Specifies that workspace _name_ should be shown on the specified _output_. |
585 | 587 | ||
diff --git a/sway/tree/container.c b/sway/tree/container.c index c30e7784..788300cc 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -1029,7 +1029,7 @@ void container_add_gaps(struct sway_container *c) { | |||
1029 | 1029 | ||
1030 | struct sway_workspace *ws = c->workspace; | 1030 | struct sway_workspace *ws = c->workspace; |
1031 | 1031 | ||
1032 | c->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner; | 1032 | c->current_gaps = ws->gaps_inner; |
1033 | c->x += c->current_gaps; | 1033 | c->x += c->current_gaps; |
1034 | c->y += c->current_gaps; | 1034 | c->y += c->current_gaps; |
1035 | c->width -= 2 * c->current_gaps; | 1035 | c->width -= 2 * c->current_gaps; |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index d65a3e4c..9dd5c815 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -68,6 +68,20 @@ struct sway_workspace *workspace_create(struct sway_output *output, | |||
68 | ws->output_priority = create_list(); | 68 | ws->output_priority = create_list(); |
69 | workspace_output_add_priority(ws, output); | 69 | workspace_output_add_priority(ws, output); |
70 | 70 | ||
71 | ws->gaps_outer = config->gaps_outer; | ||
72 | ws->gaps_inner = config->gaps_inner; | ||
73 | if (name) { | ||
74 | struct workspace_config *wsc = workspace_find_config(name); | ||
75 | if (wsc) { | ||
76 | if (wsc->gaps_outer != -1) { | ||
77 | ws->gaps_outer = wsc->gaps_outer; | ||
78 | } | ||
79 | if (wsc->gaps_inner != -1) { | ||
80 | ws->gaps_inner = wsc->gaps_inner; | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | |||
71 | output_add_workspace(output, ws); | 85 | output_add_workspace(output, ws); |
72 | output_sort_workspaces(output); | 86 | output_sort_workspaces(output); |
73 | 87 | ||
@@ -632,13 +646,13 @@ void workspace_add_gaps(struct sway_workspace *ws) { | |||
632 | return; | 646 | return; |
633 | } | 647 | } |
634 | 648 | ||
635 | ws->current_gaps = ws->has_gaps ? ws->gaps_outer : config->gaps_outer; | 649 | ws->current_gaps = ws->gaps_outer; |
636 | 650 | ||
637 | if (ws->layout == L_TABBED || ws->layout == L_STACKED) { | 651 | if (ws->layout == L_TABBED || ws->layout == L_STACKED) { |
638 | // We have to add inner gaps for this, because children of tabbed and | 652 | // We have to add inner gaps for this, because children of tabbed and |
639 | // stacked containers don't apply their own gaps - they assume the | 653 | // stacked containers don't apply their own gaps - they assume the |
640 | // tabbed/stacked container is using gaps. | 654 | // tabbed/stacked container is using gaps. |
641 | ws->current_gaps += ws->has_gaps ? ws->gaps_inner : config->gaps_inner; | 655 | ws->current_gaps += ws->gaps_inner; |
642 | } | 656 | } |
643 | 657 | ||
644 | ws->x += ws->current_gaps; | 658 | ws->x += ws->current_gaps; |