diff options
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r-- | sway/desktop/transaction.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 5dec279d..b2f7f922 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -25,6 +25,8 @@ struct sway_transaction { size_t num_waiting; size_t num_configures; struct timespec commit_time; + void (*callback)(void *data); + void *callback_data; }; struct sway_transaction_instruction { @@ -295,6 +297,10 @@ static void transaction_apply(struct sway_transaction *transaction) { node->instruction = NULL; } + + if (transaction->callback) { + transaction->callback(transaction->callback_data); + } } static void transaction_commit(struct sway_transaction *transaction); @@ -499,14 +505,7 @@ void transaction_notify_view_ready_by_size(struct sway_view *view, } } -void transaction_commit_dirty(void) { - if (!server.dirty_nodes->length) { - return; - } - struct sway_transaction *transaction = transaction_create(); - if (!transaction) { - return; - } +static void do_commit_dirty(struct sway_transaction *transaction) { for (int i = 0; i < server.dirty_nodes->length; ++i) { struct sway_node *node = server.dirty_nodes->items[i]; transaction_add_node(transaction, node); @@ -525,3 +524,28 @@ void transaction_commit_dirty(void) { transaction_progress_queue(); } } + +void transaction_commit_dirty(void) { + if (!server.dirty_nodes->length) { + return; + } + struct sway_transaction *transaction = transaction_create(); + if (!transaction) { + return; + } + do_commit_dirty(transaction); +} + +void transaction_commit_dirty_with_callback( + void (*callback)(void *data), void *data) { + if (!server.dirty_nodes->length) { + return; + } + struct sway_transaction *transaction = transaction_create(); + if (!transaction) { + return; + } + transaction->callback = callback; + transaction->callback_data = data; + do_commit_dirty(transaction); +} |