diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/border.c | 7 | ||||
-rw-r--r-- | sway/commands/floating.c | 3 | ||||
-rw-r--r-- | sway/commands/fullscreen.c | 4 | ||||
-rw-r--r-- | sway/commands/gaps.c | 18 | ||||
-rw-r--r-- | sway/commands/layout.c | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 41 | ||||
-rw-r--r-- | sway/commands/reload.c | 2 | ||||
-rw-r--r-- | sway/commands/resize.c | 2 | ||||
-rw-r--r-- | sway/commands/smart_gaps.c | 5 | ||||
-rw-r--r-- | sway/commands/split.c | 2 | ||||
-rw-r--r-- | sway/commands/swap.c | 12 |
11 files changed, 72 insertions, 26 deletions
diff --git a/sway/commands/border.c b/sway/commands/border.c index 0b059562..6db85395 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/input/cursor.h" | 4 | #include "sway/input/cursor.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "sway/tree/arrange.h" | ||
6 | #include "sway/tree/container.h" | 7 | #include "sway/tree/container.h" |
7 | #include "sway/tree/view.h" | 8 | #include "sway/tree/view.h" |
8 | 9 | ||
@@ -38,13 +39,11 @@ struct cmd_results *cmd_border(int argc, char **argv) { | |||
38 | } | 39 | } |
39 | 40 | ||
40 | if (container_is_floating(view->swayc)) { | 41 | if (container_is_floating(view->swayc)) { |
41 | container_damage_whole(view->swayc); | ||
42 | container_set_geometry_from_floating_view(view->swayc); | 42 | container_set_geometry_from_floating_view(view->swayc); |
43 | container_damage_whole(view->swayc); | ||
44 | } else { | ||
45 | view_autoconfigure(view); | ||
46 | } | 43 | } |
47 | 44 | ||
45 | arrange_and_commit(view->swayc); | ||
46 | |||
48 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 47 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
49 | if (seat->cursor) { | 48 | if (seat->cursor) { |
50 | cursor_send_pointer_motion(seat->cursor, 0, false); | 49 | cursor_send_pointer_motion(seat->cursor, 0, false); |
diff --git a/sway/commands/floating.c b/sway/commands/floating.c index 46b761da..e6003521 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c | |||
@@ -36,5 +36,8 @@ struct cmd_results *cmd_floating(int argc, char **argv) { | |||
36 | 36 | ||
37 | container_set_floating(container, wants_floating); | 37 | container_set_floating(container, wants_floating); |
38 | 38 | ||
39 | struct sway_container *workspace = container_parent(container, C_WORKSPACE); | ||
40 | arrange_and_commit(workspace); | ||
41 | |||
39 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 42 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
40 | } | 43 | } |
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index ec9ec276..1a4d8b41 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "log.h" | 1 | #include "log.h" |
2 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/tree/arrange.h" | ||
4 | #include "sway/tree/container.h" | 5 | #include "sway/tree/container.h" |
5 | #include "sway/tree/view.h" | 6 | #include "sway/tree/view.h" |
6 | #include "sway/tree/layout.h" | 7 | #include "sway/tree/layout.h" |
@@ -32,5 +33,8 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { | |||
32 | 33 | ||
33 | view_set_fullscreen(view, wants_fullscreen); | 34 | view_set_fullscreen(view, wants_fullscreen); |
34 | 35 | ||
36 | struct sway_container *workspace = container_parent(container, C_WORKSPACE); | ||
37 | arrange_and_commit(workspace->parent); | ||
38 | |||
35 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 39 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
36 | } | 40 | } |
diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c index aacb792b..801fb179 100644 --- a/sway/commands/gaps.c +++ b/sway/commands/gaps.c | |||
@@ -31,21 +31,19 @@ struct cmd_results *cmd_gaps(int argc, char **argv) { | |||
31 | 31 | ||
32 | if (strcmp(argv[1], "on") == 0) { | 32 | if (strcmp(argv[1], "on") == 0) { |
33 | config->edge_gaps = true; | 33 | config->edge_gaps = true; |
34 | arrange_root(); | ||
35 | } else if (strcmp(argv[1], "off") == 0) { | 34 | } else if (strcmp(argv[1], "off") == 0) { |
36 | config->edge_gaps = false; | 35 | config->edge_gaps = false; |
37 | arrange_root(); | ||
38 | } else if (strcmp(argv[1], "toggle") == 0) { | 36 | } else if (strcmp(argv[1], "toggle") == 0) { |
39 | if (!config->active) { | 37 | if (!config->active) { |
40 | return cmd_results_new(CMD_INVALID, "gaps", | 38 | return cmd_results_new(CMD_INVALID, "gaps", |
41 | "Cannot toggle gaps while not running."); | 39 | "Cannot toggle gaps while not running."); |
42 | } | 40 | } |
43 | config->edge_gaps = !config->edge_gaps; | 41 | config->edge_gaps = !config->edge_gaps; |
44 | arrange_root(); | ||
45 | } else { | 42 | } else { |
46 | return cmd_results_new(CMD_INVALID, "gaps", | 43 | return cmd_results_new(CMD_INVALID, "gaps", |
47 | "gaps edge_gaps on|off|toggle"); | 44 | "gaps edge_gaps on|off|toggle"); |
48 | } | 45 | } |
46 | arrange_and_commit(&root_container); | ||
49 | } else { | 47 | } else { |
50 | int amount_idx = 0; // the current index in argv | 48 | int amount_idx = 0; // the current index in argv |
51 | enum gaps_op op = GAPS_OP_SET; | 49 | enum gaps_op op = GAPS_OP_SET; |
@@ -120,13 +118,13 @@ struct cmd_results *cmd_gaps(int argc, char **argv) { | |||
120 | "gaps inner|outer <amount>"); | 118 | "gaps inner|outer <amount>"); |
121 | } | 119 | } |
122 | return cmd_results_new(CMD_INVALID, "gaps", | 120 | return cmd_results_new(CMD_INVALID, "gaps", |
123 | "gaps inner|outer all|workspace|current set|plus|minus <amount>"); | 121 | "gaps inner|outer all|workspace|current set|plus|minus <amount>"); |
124 | } | 122 | } |
125 | 123 | ||
126 | if (amount_idx == 0) { // gaps <amount> | 124 | if (amount_idx == 0) { // gaps <amount> |
127 | config->gaps_inner = val; | 125 | config->gaps_inner = val; |
128 | config->gaps_outer = val; | 126 | config->gaps_outer = val; |
129 | arrange_root(); | 127 | arrange_and_commit(&root_container); |
130 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 128 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
131 | } | 129 | } |
132 | // Other variants. The middle-length variant (gaps inner|outer <amount>) | 130 | // Other variants. The middle-length variant (gaps inner|outer <amount>) |
@@ -150,14 +148,14 @@ struct cmd_results *cmd_gaps(int argc, char **argv) { | |||
150 | break; | 148 | break; |
151 | } | 149 | } |
152 | } | 150 | } |
153 | 151 | ||
154 | if (scope == GAPS_SCOPE_ALL) { | 152 | if (scope == GAPS_SCOPE_ALL) { |
155 | if (inner) { | 153 | if (inner) { |
156 | config->gaps_inner = total; | 154 | config->gaps_inner = total; |
157 | } else { | 155 | } else { |
158 | config->gaps_outer = total; | 156 | config->gaps_outer = total; |
159 | } | 157 | } |
160 | arrange_root(); | 158 | arrange_and_commit(&root_container); |
161 | } else { | 159 | } else { |
162 | struct sway_container *c = | 160 | struct sway_container *c = |
163 | config->handler_context.current_container; | 161 | config->handler_context.current_container; |
@@ -171,11 +169,7 @@ struct cmd_results *cmd_gaps(int argc, char **argv) { | |||
171 | c->gaps_outer = total; | 169 | c->gaps_outer = total; |
172 | } | 170 | } |
173 | 171 | ||
174 | if (c->parent) { | 172 | arrange_and_commit(c->parent ? c->parent : &root_container); |
175 | arrange_children_of(c->parent); | ||
176 | } else { | ||
177 | arrange_root(); | ||
178 | } | ||
179 | } | 173 | } |
180 | } | 174 | } |
181 | 175 | ||
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index a009e38f..9945fa5c 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -49,7 +49,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) { | |||
49 | } | 49 | } |
50 | 50 | ||
51 | container_notify_subtree_changed(parent); | 51 | container_notify_subtree_changed(parent); |
52 | arrange_children_of(parent); | 52 | arrange_and_commit(parent); |
53 | 53 | ||
54 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 54 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
55 | } | 55 | } |
diff --git a/sway/commands/move.c b/sway/commands/move.c index dc9a6f6f..2c9fb77a 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -5,8 +5,10 @@ | |||
5 | #include <wlr/types/wlr_output_layout.h> | 5 | #include <wlr/types/wlr_output_layout.h> |
6 | #include <wlr/util/log.h> | 6 | #include <wlr/util/log.h> |
7 | #include "sway/commands.h" | 7 | #include "sway/commands.h" |
8 | #include "sway/desktop/transaction.h" | ||
8 | #include "sway/input/seat.h" | 9 | #include "sway/input/seat.h" |
9 | #include "sway/output.h" | 10 | #include "sway/output.h" |
11 | #include "sway/tree/arrange.h" | ||
10 | #include "sway/tree/container.h" | 12 | #include "sway/tree/container.h" |
11 | #include "sway/tree/layout.h" | 13 | #include "sway/tree/layout.h" |
12 | #include "sway/tree/workspace.h" | 14 | #include "sway/tree/workspace.h" |
@@ -96,6 +98,12 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
96 | seat_set_focus(config->handler_context.seat, focus); | 98 | seat_set_focus(config->handler_context.seat, focus); |
97 | container_reap_empty(old_parent); | 99 | container_reap_empty(old_parent); |
98 | container_reap_empty(destination->parent); | 100 | container_reap_empty(destination->parent); |
101 | |||
102 | struct sway_transaction *txn = transaction_create(); | ||
103 | arrange_windows(old_parent, txn); | ||
104 | arrange_windows(destination->parent, txn); | ||
105 | transaction_commit(txn); | ||
106 | |||
99 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 107 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
100 | } else if (strcasecmp(argv[1], "to") == 0 | 108 | } else if (strcasecmp(argv[1], "to") == 0 |
101 | && strcasecmp(argv[2], "output") == 0) { | 109 | && strcasecmp(argv[2], "output") == 0) { |
@@ -125,6 +133,12 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
125 | seat_set_focus(config->handler_context.seat, old_parent); | 133 | seat_set_focus(config->handler_context.seat, old_parent); |
126 | container_reap_empty(old_parent); | 134 | container_reap_empty(old_parent); |
127 | container_reap_empty(focus->parent); | 135 | container_reap_empty(focus->parent); |
136 | |||
137 | struct sway_transaction *txn = transaction_create(); | ||
138 | arrange_windows(old_parent, txn); | ||
139 | arrange_windows(focus->parent, txn); | ||
140 | transaction_commit(txn); | ||
141 | |||
128 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 142 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
129 | } | 143 | } |
130 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 144 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); |
@@ -152,9 +166,28 @@ static struct cmd_results *cmd_move_workspace(struct sway_container *current, | |||
152 | current = container_parent(current, C_WORKSPACE); | 166 | current = container_parent(current, C_WORKSPACE); |
153 | } | 167 | } |
154 | container_move_to(current, destination); | 168 | container_move_to(current, destination); |
169 | |||
170 | struct sway_transaction *txn = transaction_create(); | ||
171 | arrange_windows(source, txn); | ||
172 | arrange_windows(destination, txn); | ||
173 | transaction_commit(txn); | ||
174 | |||
155 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 175 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
156 | } | 176 | } |
157 | 177 | ||
178 | static void move_in_direction(struct sway_container *container, | ||
179 | enum wlr_direction direction, int move_amt) { | ||
180 | struct sway_container *old_parent = container->parent; | ||
181 | container_move(container, direction, move_amt); | ||
182 | |||
183 | struct sway_transaction *txn = transaction_create(); | ||
184 | arrange_windows(old_parent, txn); | ||
185 | if (container->parent != old_parent) { | ||
186 | arrange_windows(container->parent, txn); | ||
187 | } | ||
188 | transaction_commit(txn); | ||
189 | } | ||
190 | |||
158 | struct cmd_results *cmd_move(int argc, char **argv) { | 191 | struct cmd_results *cmd_move(int argc, char **argv) { |
159 | struct cmd_results *error = NULL; | 192 | struct cmd_results *error = NULL; |
160 | int move_amt = 10; | 193 | int move_amt = 10; |
@@ -173,13 +206,13 @@ struct cmd_results *cmd_move(int argc, char **argv) { | |||
173 | } | 206 | } |
174 | 207 | ||
175 | if (strcasecmp(argv[0], "left") == 0) { | 208 | if (strcasecmp(argv[0], "left") == 0) { |
176 | container_move(current, MOVE_LEFT, move_amt); | 209 | move_in_direction(current, MOVE_LEFT, move_amt); |
177 | } else if (strcasecmp(argv[0], "right") == 0) { | 210 | } else if (strcasecmp(argv[0], "right") == 0) { |
178 | container_move(current, MOVE_RIGHT, move_amt); | 211 | move_in_direction(current, MOVE_RIGHT, move_amt); |
179 | } else if (strcasecmp(argv[0], "up") == 0) { | 212 | } else if (strcasecmp(argv[0], "up") == 0) { |
180 | container_move(current, MOVE_UP, move_amt); | 213 | move_in_direction(current, MOVE_UP, move_amt); |
181 | } else if (strcasecmp(argv[0], "down") == 0) { | 214 | } else if (strcasecmp(argv[0], "down") == 0) { |
182 | container_move(current, MOVE_DOWN, move_amt); | 215 | move_in_direction(current, MOVE_DOWN, move_amt); |
183 | } else if (strcasecmp(argv[0], "container") == 0 | 216 | } else if (strcasecmp(argv[0], "container") == 0 |
184 | || strcasecmp(argv[0], "window") == 0) { | 217 | || strcasecmp(argv[0], "window") == 0) { |
185 | return cmd_move_container(current, argc, argv); | 218 | return cmd_move_container(current, argc, argv); |
diff --git a/sway/commands/reload.c b/sway/commands/reload.c index 092dd46f..9fc213c4 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c | |||
@@ -12,6 +12,6 @@ struct cmd_results *cmd_reload(int argc, char **argv) { | |||
12 | } | 12 | } |
13 | 13 | ||
14 | load_swaybars(); | 14 | load_swaybars(); |
15 | arrange_root(); | 15 | arrange_and_commit(&root_container); |
16 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 16 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
17 | } | 17 | } |
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 29637953..6357343e 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -182,7 +182,7 @@ static void resize_tiled(int amount, enum resize_axis axis) { | |||
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | arrange_children_of(parent->parent); | 185 | arrange_and_commit(parent->parent); |
186 | } | 186 | } |
187 | 187 | ||
188 | static void resize(int amount, enum resize_axis axis, enum resize_unit unit) { | 188 | static void resize(int amount, enum resize_axis axis, enum resize_unit unit) { |
diff --git a/sway/commands/smart_gaps.c b/sway/commands/smart_gaps.c index 38700d65..f687e78e 100644 --- a/sway/commands/smart_gaps.c +++ b/sway/commands/smart_gaps.c | |||
@@ -16,13 +16,14 @@ struct cmd_results *cmd_smart_gaps(int argc, char **argv) { | |||
16 | 16 | ||
17 | if (strcmp(argv[0], "on") == 0) { | 17 | if (strcmp(argv[0], "on") == 0) { |
18 | config->smart_gaps = true; | 18 | config->smart_gaps = true; |
19 | arrange_root(); | ||
20 | } else if (strcmp(argv[0], "off") == 0) { | 19 | } else if (strcmp(argv[0], "off") == 0) { |
21 | config->smart_gaps = false; | 20 | config->smart_gaps = false; |
22 | arrange_root(); | ||
23 | } else { | 21 | } else { |
24 | return cmd_results_new(CMD_INVALID, "smart_gaps", | 22 | return cmd_results_new(CMD_INVALID, "smart_gaps", |
25 | "Expected 'smart_gaps <on|off>' "); | 23 | "Expected 'smart_gaps <on|off>' "); |
26 | } | 24 | } |
25 | |||
26 | arrange_and_commit(&root_container); | ||
27 | |||
27 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
28 | } | 29 | } |
diff --git a/sway/commands/split.c b/sway/commands/split.c index 57e42a5a..7ea14953 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c | |||
@@ -16,7 +16,7 @@ static struct cmd_results *do_split(int layout) { | |||
16 | } | 16 | } |
17 | struct sway_container *parent = container_split(con, layout); | 17 | struct sway_container *parent = container_split(con, layout); |
18 | container_create_notify(parent); | 18 | container_create_notify(parent); |
19 | arrange_children_of(parent); | 19 | arrange_and_commit(parent); |
20 | 20 | ||
21 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 21 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
22 | } | 22 | } |
diff --git a/sway/commands/swap.c b/sway/commands/swap.c index e8dfc57f..e052058f 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c | |||
@@ -1,6 +1,8 @@ | |||
1 | #include <strings.h> | 1 | #include <strings.h> |
2 | #include <wlr/util/log.h> | 2 | #include <wlr/util/log.h> |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "sway/desktop/transaction.h" | ||
5 | #include "sway/tree/arrange.h" | ||
4 | #include "sway/tree/layout.h" | 6 | #include "sway/tree/layout.h" |
5 | #include "sway/tree/view.h" | 7 | #include "sway/tree/view.h" |
6 | #include "stringop.h" | 8 | #include "stringop.h" |
@@ -76,5 +78,15 @@ struct cmd_results *cmd_swap(int argc, char **argv) { | |||
76 | } | 78 | } |
77 | 79 | ||
78 | container_swap(current, other); | 80 | container_swap(current, other); |
81 | |||
82 | struct sway_transaction *txn = transaction_create(); | ||
83 | arrange_windows(current->parent, txn); | ||
84 | |||
85 | if (other->parent != current->parent) { | ||
86 | arrange_windows(other->parent, txn); | ||
87 | } | ||
88 | |||
89 | transaction_commit(txn); | ||
90 | |||
79 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 91 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
80 | } | 92 | } |