diff options
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/transaction.c | 40 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 9 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 9 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 9 |
4 files changed, 56 insertions, 11 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); +} diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index fda1bdef..064e2707 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -9,6 +9,7 @@ #include "sway/decoration.h" #include "sway/desktop.h" #include "sway/desktop/transaction.h" +#include "sway/input/cursor.h" #include "sway/input/input-manager.h" #include "sway/input/seat.h" #include "sway/output.h" @@ -396,6 +397,11 @@ static void handle_unmap(struct wl_listener *listener, void *data) { wl_list_remove(&xdg_shell_view->set_app_id.link); } +static void do_rebase(void *data) { + struct sway_cursor *cursor = data; + cursor_rebase(cursor); +} + static void handle_map(struct wl_listener *listener, void *data) { struct sway_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, map); @@ -422,7 +428,8 @@ static void handle_map(struct wl_listener *listener, void *data) { view_map(view, view->wlr_xdg_surface->surface, xdg_surface->toplevel->client_pending.fullscreen, csd); - transaction_commit_dirty(); + struct sway_seat *seat = input_manager_current_seat(); + transaction_commit_dirty_with_callback(do_rebase, seat->cursor); xdg_shell_view->commit.notify = handle_commit; wl_signal_add(&xdg_surface->surface->events.commit, diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 7159f1ed..90bf55b2 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -8,6 +8,7 @@ #include "sway/decoration.h" #include "sway/desktop.h" #include "sway/desktop/transaction.h" +#include "sway/input/cursor.h" #include "sway/input/input-manager.h" #include "sway/input/seat.h" #include "sway/output.h" @@ -393,6 +394,11 @@ static void handle_unmap(struct wl_listener *listener, void *data) { wl_list_remove(&xdg_shell_v6_view->set_app_id.link); } +static void do_rebase(void *data) { + struct sway_cursor *cursor = data; + cursor_rebase(cursor); +} + static void handle_map(struct wl_listener *listener, void *data) { struct sway_xdg_shell_v6_view *xdg_shell_v6_view = wl_container_of(listener, xdg_shell_v6_view, map); @@ -413,7 +419,8 @@ static void handle_map(struct wl_listener *listener, void *data) { view_map(view, view->wlr_xdg_surface_v6->surface, xdg_surface->toplevel->client_pending.fullscreen, csd); - transaction_commit_dirty(); + struct sway_seat *seat = input_manager_current_seat(); + transaction_commit_dirty_with_callback(do_rebase, seat->cursor); xdg_shell_v6_view->commit.notify = handle_commit; wl_signal_add(&xdg_surface->surface->events.commit, diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index d1aec084..95275937 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -8,6 +8,7 @@ #include "log.h" #include "sway/desktop.h" #include "sway/desktop/transaction.h" +#include "sway/input/cursor.h" #include "sway/input/input-manager.h" #include "sway/input/seat.h" #include "sway/output.h" @@ -390,6 +391,11 @@ static void handle_unmap(struct wl_listener *listener, void *data) { wl_list_remove(&xwayland_view->commit.link); } +static void do_rebase(void *data) { + struct sway_cursor *cursor = data; + cursor_rebase(cursor); +} + static void handle_map(struct wl_listener *listener, void *data) { struct sway_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, map); @@ -416,7 +422,8 @@ static void handle_map(struct wl_listener *listener, void *data) { // Put it back into the tree view_map(view, xsurface->surface, xsurface->fullscreen, false); - transaction_commit_dirty(); + struct sway_seat *seat = input_manager_current_seat(); + transaction_commit_dirty_with_callback(do_rebase, seat->cursor); } static void handle_request_configure(struct wl_listener *listener, void *data) { |