aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/transaction.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-19 15:37:09 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-22 23:10:19 +1000
commit31f91bd483797feb411077da0e351ccfae9ecc10 (patch)
tree7206427d2197de30d67ec5240eb4bcb08d92a751 /sway/desktop/transaction.c
parentFix clicking xwayland menus (diff)
downloadsway-31f91bd483797feb411077da0e351ccfae9ecc10.tar.gz
sway-31f91bd483797feb411077da0e351ccfae9ecc10.tar.zst
sway-31f91bd483797feb411077da0e351ccfae9ecc10.zip
Improve resize performance by partially flushing the transaction queue
When interactively resizing some views (eg. Nautilus), new transactions are added to the queue faster than the client can process them. Previously, we would wait for the entire queue to be ready before applying any of them, but in this case the transactions would time out, giving the client choppy performance. This changes the queue handling so it applies the transactions up to the first waiting transaction, without waiting for the entire queue to be ready.
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r--sway/desktop/transaction.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 19f41efc..2a89880a 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -222,24 +222,16 @@ static void transaction_apply(struct sway_transaction *transaction) {
222 } 222 }
223} 223}
224 224
225/**
226 * For simplicity, we only progress the queue if it can be completely flushed.
227 */
228static void transaction_progress_queue() { 225static void transaction_progress_queue() {
229 // We iterate this list in reverse because we're more likely to find a 226 while (server.transactions->length) {
230 // waiting transactions at the end of the list. 227 struct sway_transaction *transaction = server.transactions->items[0];
231 for (int i = server.transactions->length - 1; i >= 0; --i) {
232 struct sway_transaction *transaction = server.transactions->items[i];
233 if (transaction->num_waiting) { 228 if (transaction->num_waiting) {
234 return; 229 return;
235 } 230 }
236 }
237 for (int i = 0; i < server.transactions->length; ++i) {
238 struct sway_transaction *transaction = server.transactions->items[i];
239 transaction_apply(transaction); 231 transaction_apply(transaction);
240 transaction_destroy(transaction); 232 transaction_destroy(transaction);
233 list_del(server.transactions, 0);
241 } 234 }
242 server.transactions->length = 0;
243 idle_inhibit_v1_check_active(server.idle_inhibit_manager_v1); 235 idle_inhibit_v1_check_active(server.idle_inhibit_manager_v1);
244} 236}
245 237