summaryrefslogtreecommitdiff
path: root/sway/desktop/transaction.c
diff options
context:
space:
mode:
authorRyan Dwyer <[email protected]>2018-10-25 23:30:09 +1000
committerRyan Dwyer <[email protected]>2018-10-25 23:37:40 +1000
commit60a1d79de71660949f7a6fc83e242d9d95c75187 (patch)
tree821502ef188985ee023df3f24b9e4e468eb96aef /sway/desktop/transaction.c
parentea2497d35cc1a7357d69b8e09ce0104c82a7be39 (diff)
Rebase the cursor after applying transactions
This approaches cursor rebasing from a different angle. Rather than littering the codebase with cursor_rebase calls and using transaction callbacks, this just runs cursor_rebase after applying every transaction - but only if there's outputs connected, because otherwise it causes a crash during shutdown. There is one known case where we still need to call cursor_rebase directly, and that's when running `seat seat0 cursor move ...`. This command doesn't set anything as dirty so no transaction occurs.
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r--sway/desktop/transaction.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index b2f7f922..955b05d6 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -11,6 +11,8 @@
#include "sway/desktop.h"
#include "sway/desktop/idle_inhibit_v1.h"
#include "sway/desktop/transaction.h"
+#include "sway/input/cursor.h"
+#include "sway/input/input-manager.h"
#include "sway/output.h"
#include "sway/tree/container.h"
#include "sway/tree/node.h"
@@ -25,8 +27,6 @@ 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 {
@@ -298,8 +298,11 @@ static void transaction_apply(struct sway_transaction *transaction) {
node->instruction = NULL;
}
- if (transaction->callback) {
- transaction->callback(transaction->callback_data);
+ if (root->outputs->length) {
+ struct sway_seat *seat;
+ wl_list_for_each(seat, &server.input->seats, link) {
+ cursor_rebase(seat->cursor);
+ }
}
}
@@ -505,7 +508,14 @@ void transaction_notify_view_ready_by_size(struct sway_view *view,
}
}
-static void do_commit_dirty(struct sway_transaction *transaction) {
+void transaction_commit_dirty(void) {
+ if (!server.dirty_nodes->length) {
+ return;
+ }
+ struct sway_transaction *transaction = transaction_create();
+ if (!transaction) {
+ return;
+ }
for (int i = 0; i < server.dirty_nodes->length; ++i) {
struct sway_node *node = server.dirty_nodes->items[i];
transaction_add_node(transaction, node);
@@ -524,28 +534,3 @@ static void do_commit_dirty(struct sway_transaction *transaction) {
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);
-}