mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
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.
This commit is contained in:
parent
ea2497d35c
commit
60a1d79de7
10 changed files with 18 additions and 68 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue