summaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-07-15 05:01:25 -0700
committerLibravatar GitHub <noreply@github.com>2018-07-15 05:01:25 -0700
commit53e3f35ba348d6285478ceb4a93b020e138c95c7 (patch)
tree091c6133f3bd33b64b1853c7984eaa3921b9facf /sway/commands
parentMerge pull request #2266 from emersion/remove-orbital-screenshooter (diff)
parentSet signature to void (diff)
downloadsway-53e3f35ba348d6285478ceb4a93b020e138c95c7.tar.gz
sway-53e3f35ba348d6285478ceb4a93b020e138c95c7.tar.zst
sway-53e3f35ba348d6285478ceb4a93b020e138c95c7.zip
Merge pull request #2272 from RyanDwyer/simplify-transactions
Simplify transactions by using a dirty flag on containers
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/border.c2
-rw-r--r--sway/commands/floating.c2
-rw-r--r--sway/commands/fullscreen.c2
-rw-r--r--sway/commands/gaps.c8
-rw-r--r--sway/commands/layout.c2
-rw-r--r--sway/commands/move.c25
-rw-r--r--sway/commands/reload.c2
-rw-r--r--sway/commands/resize.c6
-rw-r--r--sway/commands/smart_gaps.c2
-rw-r--r--sway/commands/split.c2
-rw-r--r--sway/commands/swap.c9
11 files changed, 24 insertions, 38 deletions
diff --git a/sway/commands/border.c b/sway/commands/border.c
index 6db85395..9c19e20a 100644
--- a/sway/commands/border.c
+++ b/sway/commands/border.c
@@ -42,7 +42,7 @@ struct cmd_results *cmd_border(int argc, char **argv) {
42 container_set_geometry_from_floating_view(view->swayc); 42 container_set_geometry_from_floating_view(view->swayc);
43 } 43 }
44 44
45 arrange_and_commit(view->swayc); 45 arrange_windows(view->swayc);
46 46
47 struct sway_seat *seat = input_manager_current_seat(input_manager); 47 struct sway_seat *seat = input_manager_current_seat(input_manager);
48 if (seat->cursor) { 48 if (seat->cursor) {
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index e6003521..6ab56c3b 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -37,7 +37,7 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
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); 39 struct sway_container *workspace = container_parent(container, C_WORKSPACE);
40 arrange_and_commit(workspace); 40 arrange_windows(workspace);
41 41
42 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 42 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
43} 43}
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c
index 1a4d8b41..0b5beaa2 100644
--- a/sway/commands/fullscreen.c
+++ b/sway/commands/fullscreen.c
@@ -34,7 +34,7 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
34 view_set_fullscreen(view, wants_fullscreen); 34 view_set_fullscreen(view, wants_fullscreen);
35 35
36 struct sway_container *workspace = container_parent(container, C_WORKSPACE); 36 struct sway_container *workspace = container_parent(container, C_WORKSPACE);
37 arrange_and_commit(workspace->parent); 37 arrange_windows(workspace->parent);
38 38
39 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 39 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
40} 40}
diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c
index 801fb179..3906eb70 100644
--- a/sway/commands/gaps.c
+++ b/sway/commands/gaps.c
@@ -43,7 +43,7 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
43 return cmd_results_new(CMD_INVALID, "gaps", 43 return cmd_results_new(CMD_INVALID, "gaps",
44 "gaps edge_gaps on|off|toggle"); 44 "gaps edge_gaps on|off|toggle");
45 } 45 }
46 arrange_and_commit(&root_container); 46 arrange_windows(&root_container);
47 } else { 47 } else {
48 int amount_idx = 0; // the current index in argv 48 int amount_idx = 0; // the current index in argv
49 enum gaps_op op = GAPS_OP_SET; 49 enum gaps_op op = GAPS_OP_SET;
@@ -124,7 +124,7 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
124 if (amount_idx == 0) { // gaps <amount> 124 if (amount_idx == 0) { // gaps <amount>
125 config->gaps_inner = val; 125 config->gaps_inner = val;
126 config->gaps_outer = val; 126 config->gaps_outer = val;
127 arrange_and_commit(&root_container); 127 arrange_windows(&root_container);
128 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 128 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
129 } 129 }
130 // Other variants. The middle-length variant (gaps inner|outer <amount>) 130 // Other variants. The middle-length variant (gaps inner|outer <amount>)
@@ -155,7 +155,7 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
155 } else { 155 } else {
156 config->gaps_outer = total; 156 config->gaps_outer = total;
157 } 157 }
158 arrange_and_commit(&root_container); 158 arrange_windows(&root_container);
159 } else { 159 } else {
160 struct sway_container *c = 160 struct sway_container *c =
161 config->handler_context.current_container; 161 config->handler_context.current_container;
@@ -169,7 +169,7 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
169 c->gaps_outer = total; 169 c->gaps_outer = total;
170 } 170 }
171 171
172 arrange_and_commit(c->parent ? c->parent : &root_container); 172 arrange_windows(c->parent ? c->parent : &root_container);
173 } 173 }
174 } 174 }
175 175
diff --git a/sway/commands/layout.c b/sway/commands/layout.c
index 9945fa5c..c446f1f9 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_and_commit(parent); 52 arrange_windows(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 a1c1e018..6ec050a8 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -6,7 +6,6 @@
6#include <wlr/types/wlr_output_layout.h> 6#include <wlr/types/wlr_output_layout.h>
7#include <wlr/util/log.h> 7#include <wlr/util/log.h>
8#include "sway/commands.h" 8#include "sway/commands.h"
9#include "sway/desktop/transaction.h"
10#include "sway/input/cursor.h" 9#include "sway/input/cursor.h"
11#include "sway/input/seat.h" 10#include "sway/input/seat.h"
12#include "sway/output.h" 11#include "sway/output.h"
@@ -105,10 +104,8 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
105 // TODO: Ideally we would arrange the surviving parent after reaping, 104 // TODO: Ideally we would arrange the surviving parent after reaping,
106 // but container_reap_empty does not return it, so we arrange the 105 // but container_reap_empty does not return it, so we arrange the
107 // workspace instead. 106 // workspace instead.
108 struct sway_transaction *txn = transaction_create(); 107 arrange_windows(old_ws);
109 arrange_windows(old_ws, txn); 108 arrange_windows(destination->parent);
110 arrange_windows(destination->parent, txn);
111 transaction_commit(txn);
112 109
113 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 110 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
114 } else if (strcasecmp(argv[1], "to") == 0 111 } else if (strcasecmp(argv[1], "to") == 0
@@ -144,10 +141,8 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
144 // TODO: Ideally we would arrange the surviving parent after reaping, 141 // TODO: Ideally we would arrange the surviving parent after reaping,
145 // but container_reap_empty does not return it, so we arrange the 142 // but container_reap_empty does not return it, so we arrange the
146 // workspace instead. 143 // workspace instead.
147 struct sway_transaction *txn = transaction_create(); 144 arrange_windows(old_ws);
148 arrange_windows(old_ws, txn); 145 arrange_windows(focus->parent);
149 arrange_windows(focus->parent, txn);
150 transaction_commit(txn);
151 146
152 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 147 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
153 } 148 }
@@ -177,10 +172,8 @@ static struct cmd_results *cmd_move_workspace(struct sway_container *current,
177 } 172 }
178 container_move_to(current, destination); 173 container_move_to(current, destination);
179 174
180 struct sway_transaction *txn = transaction_create(); 175 arrange_windows(source);
181 arrange_windows(source, txn); 176 arrange_windows(destination);
182 arrange_windows(destination, txn);
183 transaction_commit(txn);
184 177
185 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 178 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
186} 179}
@@ -238,12 +231,10 @@ static struct cmd_results *move_in_direction(struct sway_container *container,
238 container_move(container, direction, move_amt); 231 container_move(container, direction, move_amt);
239 struct sway_container *new_ws = container_parent(container, C_WORKSPACE); 232 struct sway_container *new_ws = container_parent(container, C_WORKSPACE);
240 233
241 struct sway_transaction *txn = transaction_create(); 234 arrange_windows(old_ws);
242 arrange_windows(old_ws, txn);
243 if (new_ws != old_ws) { 235 if (new_ws != old_ws) {
244 arrange_windows(new_ws, txn); 236 arrange_windows(new_ws);
245 } 237 }
246 transaction_commit(txn);
247 238
248 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 239 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
249} 240}
diff --git a/sway/commands/reload.c b/sway/commands/reload.c
index c6715f9c..cea6a94b 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_and_commit(&root_container); 15 arrange_windows(&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 2cf811d8..e657864c 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -268,7 +268,7 @@ static void resize_tiled(int amount, enum resize_axis axis) {
268 } 268 }
269 } 269 }
270 270
271 arrange_and_commit(parent->parent); 271 arrange_windows(parent->parent);
272} 272}
273 273
274/** 274/**
@@ -338,7 +338,7 @@ static struct cmd_results *resize_adjust_floating(enum resize_axis axis,
338 view->height += grow_height; 338 view->height += grow_height;
339 } 339 }
340 340
341 arrange_and_commit(con); 341 arrange_windows(con);
342 342
343 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 343 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
344} 344}
@@ -410,7 +410,7 @@ static struct cmd_results *resize_set_floating(struct sway_container *con,
410 view->height += grow_height; 410 view->height += grow_height;
411 } 411 }
412 412
413 arrange_and_commit(con); 413 arrange_windows(con);
414 414
415 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 415 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
416} 416}
diff --git a/sway/commands/smart_gaps.c b/sway/commands/smart_gaps.c
index f687e78e..7d27e571 100644
--- a/sway/commands/smart_gaps.c
+++ b/sway/commands/smart_gaps.c
@@ -23,7 +23,7 @@ struct cmd_results *cmd_smart_gaps(int argc, char **argv) {
23 "Expected 'smart_gaps <on|off>' "); 23 "Expected 'smart_gaps <on|off>' ");
24 } 24 }
25 25
26 arrange_and_commit(&root_container); 26 arrange_windows(&root_container);
27 27
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 28 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
29} 29}
diff --git a/sway/commands/split.c b/sway/commands/split.c
index c40f4d9f..313799da 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_and_commit(parent->parent); 19 arrange_windows(parent->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 e052058f..2fc88308 100644
--- a/sway/commands/swap.c
+++ b/sway/commands/swap.c
@@ -1,7 +1,6 @@
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/arrange.h"
6#include "sway/tree/layout.h" 5#include "sway/tree/layout.h"
7#include "sway/tree/view.h" 6#include "sway/tree/view.h"
@@ -79,14 +78,10 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
79 78
80 container_swap(current, other); 79 container_swap(current, other);
81 80
82 struct sway_transaction *txn = transaction_create(); 81 arrange_windows(current->parent);
83 arrange_windows(current->parent, txn);
84
85 if (other->parent != current->parent) { 82 if (other->parent != current->parent) {
86 arrange_windows(other->parent, txn); 83 arrange_windows(other->parent);
87 } 84 }
88 85
89 transaction_commit(txn);
90
91 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 86 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
92} 87}