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.
This commit is contained in:
Ryan Dwyer 2018-07-19 15:37:09 +10:00
parent 350e9ea929
commit 31f91bd483

View file

@ -222,24 +222,16 @@ static void transaction_apply(struct sway_transaction *transaction) {
} }
} }
/**
* For simplicity, we only progress the queue if it can be completely flushed.
*/
static void transaction_progress_queue() { static void transaction_progress_queue() {
// We iterate this list in reverse because we're more likely to find a while (server.transactions->length) {
// waiting transactions at the end of the list. struct sway_transaction *transaction = server.transactions->items[0];
for (int i = server.transactions->length - 1; i >= 0; --i) {
struct sway_transaction *transaction = server.transactions->items[i];
if (transaction->num_waiting) { if (transaction->num_waiting) {
return; return;
} }
}
for (int i = 0; i < server.transactions->length; ++i) {
struct sway_transaction *transaction = server.transactions->items[i];
transaction_apply(transaction); transaction_apply(transaction);
transaction_destroy(transaction); transaction_destroy(transaction);
list_del(server.transactions, 0);
} }
server.transactions->length = 0;
idle_inhibit_v1_check_active(server.idle_inhibit_manager_v1); idle_inhibit_v1_check_active(server.idle_inhibit_manager_v1);
} }