diff options
-rw-r--r-- | include/sway/desktop/transaction.h | 7 | ||||
-rw-r--r-- | include/sway/output.h | 1 | ||||
-rw-r--r-- | include/sway/server.h | 6 | ||||
-rw-r--r-- | sway/commands/border.c | 5 | ||||
-rw-r--r-- | sway/commands/floating.c | 4 | ||||
-rw-r--r-- | sway/commands/focus.c | 6 | ||||
-rw-r--r-- | sway/commands/fullscreen.c | 4 | ||||
-rw-r--r-- | sway/commands/gaps.c | 4 | ||||
-rw-r--r-- | sway/commands/kill.c | 4 | ||||
-rw-r--r-- | sway/commands/layout.c | 4 | ||||
-rw-r--r-- | sway/commands/move.c | 4 | ||||
-rw-r--r-- | sway/commands/rename.c | 4 | ||||
-rw-r--r-- | sway/commands/resize.c | 4 | ||||
-rw-r--r-- | sway/commands/scratchpad.c | 4 | ||||
-rw-r--r-- | sway/commands/split.c | 4 | ||||
-rw-r--r-- | sway/commands/swap.c | 4 | ||||
-rw-r--r-- | sway/commands/workspace.c | 4 | ||||
-rw-r--r-- | sway/desktop/output.c | 185 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 45 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 8 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 8 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 8 | ||||
-rw-r--r-- | sway/input/seat.c | 1 | ||||
-rw-r--r-- | sway/server.c | 3 | ||||
-rw-r--r-- | sway/tree/output.c | 2 | ||||
-rw-r--r-- | sway/tree/view.c | 1 | ||||
-rw-r--r-- | sway/tree/workspace.c | 1 |
27 files changed, 178 insertions, 157 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h index f38f033c..66e8c9a2 100644 --- a/include/sway/desktop/transaction.h +++ b/include/sway/desktop/transaction.h @@ -29,13 +29,6 @@ struct sway_view; void transaction_commit_dirty(void); /** - * Same as above, but runs the specific callback when the transaction is - * applied. - */ -void transaction_commit_dirty_with_callback( - void (*callback)(void *data), void *data); - -/** * Notify the transaction system that a view is ready for the new layout. * * When all views in the transaction are ready, the layout will be applied. diff --git a/include/sway/output.h b/include/sway/output.h index 19a61175..369e62ce 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -40,6 +40,7 @@ struct sway_output { struct wl_listener mode; struct wl_listener transform; struct wl_listener scale; + struct wl_listener present; struct wl_listener damage_destroy; struct wl_listener damage_frame; diff --git a/include/sway/server.h b/include/sway/server.h index 3e1cbb33..5fced224 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -8,12 +8,12 @@ #include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_layer_shell_v1.h> +#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_server_decoration.h> #include <wlr/types/wlr_xdg_shell_v6.h> #include <wlr/types/wlr_xdg_shell.h> -// TODO WLR: make Xwayland optional -#include "list.h" #include "config.h" +#include "list.h" #ifdef HAVE_XWAYLAND #include "sway/xwayland.h" #endif @@ -58,6 +58,8 @@ struct sway_server { struct wl_listener xdg_decoration; struct wl_list xdg_decorations; // sway_xdg_decoration::link + struct wlr_presentation *presentation; + size_t txn_timeout_ms; list_t *transactions; list_t *dirty_nodes; diff --git a/sway/commands/border.c b/sway/commands/border.c index 5b65148d..37047812 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c @@ -94,10 +94,5 @@ struct cmd_results *cmd_border(int argc, char **argv) { arrange_container(view->container); - struct sway_seat *seat = input_manager_current_seat(); - if (seat->cursor) { - cursor_rebase(seat->cursor); - } - return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/floating.c b/sway/commands/floating.c index 97662a18..81bb86f8 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c @@ -15,6 +15,10 @@ struct cmd_results *cmd_floating(int argc, char **argv) { if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "floating", + "Can't run this command while there's no outputs connected."); + } struct sway_container *container = config->handler_context.container; struct sway_workspace *workspace = config->handler_context.workspace; if (!container && workspace->tiling->length == 0) { diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 81af8e0f..2204f722 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -224,6 +224,10 @@ struct cmd_results *cmd_focus(int argc, char **argv) { if (config->reading || !config->active) { return cmd_results_new(CMD_DEFER, NULL, NULL); } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "focus", + "Can't run this command while there's no outputs connected."); + } struct sway_node *node = config->handler_context.node; struct sway_container *container = config->handler_context.container; struct sway_workspace *workspace = config->handler_context.workspace; @@ -236,7 +240,6 @@ struct cmd_results *cmd_focus(int argc, char **argv) { if (argc == 0 && container) { seat_set_focus_container(seat, container); seat_consider_warp_to_focus(seat); - cursor_rebase(seat->cursor); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } @@ -294,7 +297,6 @@ struct cmd_results *cmd_focus(int argc, char **argv) { if (next_focus) { seat_set_focus(seat, next_focus); seat_consider_warp_to_focus(seat); - cursor_rebase(seat->cursor); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index 0204a73c..ff7cbba7 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c @@ -12,6 +12,10 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_MOST, 1))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "fullscreen", + "Can't run this command while there's no outputs connected."); + } struct sway_node *node = config->handler_context.node; struct sway_container *container = config->handler_context.container; struct sway_workspace *workspace = config->handler_context.workspace; diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c index 042b415f..ca8cb27a 100644 --- a/sway/commands/gaps.c +++ b/sway/commands/gaps.c @@ -88,6 +88,10 @@ static struct cmd_results *gaps_set_runtime(int argc, char **argv) { if (error) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "gaps", + "Can't run this command while there's no outputs connected."); + } struct gaps_data data; diff --git a/sway/commands/kill.c b/sway/commands/kill.c index 85ca0f33..f1d75b9a 100644 --- a/sway/commands/kill.c +++ b/sway/commands/kill.c @@ -14,6 +14,10 @@ static void close_container_iterator(struct sway_container *con, void *data) { } struct cmd_results *cmd_kill(int argc, char **argv) { + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "kill", + "Can't run this command while there's no outputs connected."); + } struct sway_container *con = config->handler_context.container; struct sway_workspace *ws = config->handler_context.workspace; diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 65f67af8..8fde1776 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -99,6 +99,10 @@ struct cmd_results *cmd_layout(int argc, char **argv) { if ((error = checkarg(argc, "layout", EXPECTED_AT_LEAST, 1))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "layout", + "Can't run this command while there's no outputs connected."); + } struct sway_container *container = config->handler_context.container; struct sway_workspace *workspace = config->handler_context.workspace; diff --git a/sway/commands/move.c b/sway/commands/move.c index e0a958bf..ffe12d41 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -844,6 +844,10 @@ struct cmd_results *cmd_move(int argc, char **argv) { if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "move", + "Can't run this command while there's no outputs connected."); + } if (strcasecmp(argv[0], "left") == 0) { return cmd_move_in_direction(MOVE_LEFT, argc, argv); diff --git a/sway/commands/rename.c b/sway/commands/rename.c index d982f941..0cee9293 100644 --- a/sway/commands/rename.c +++ b/sway/commands/rename.c @@ -20,6 +20,10 @@ struct cmd_results *cmd_rename(int argc, char **argv) { if ((error = checkarg(argc, "rename", EXPECTED_AT_LEAST, 3))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "rename", + "Can't run this command while there's no outputs connected."); + } if (strcasecmp(argv[0], "workspace") != 0) { return cmd_results_new(CMD_INVALID, "rename", expected_syntax); } diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 8666f40b..8635b309 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c @@ -671,6 +671,10 @@ static struct cmd_results *cmd_resize_adjust(int argc, char **argv, } struct cmd_results *cmd_resize(int argc, char **argv) { + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "resize", + "Can't run this command while there's no outputs connected."); + } struct sway_container *current = config->handler_context.container; if (!current) { return cmd_results_new(CMD_INVALID, "resize", "Cannot resize nothing"); diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index 26f0e490..6eab456d 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c @@ -87,6 +87,10 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "scratchpad", "Expected 'scratchpad show'"); } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "scratchpad", + "Can't run this command while there's no outputs connected."); + } if (!root->scratchpad->length) { return cmd_results_new(CMD_INVALID, "scratchpad", "Scratchpad is empty"); diff --git a/sway/commands/split.c b/sway/commands/split.c index 9a53f3d3..ed106a86 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c @@ -28,6 +28,10 @@ struct cmd_results *cmd_split(int argc, char **argv) { if ((error = checkarg(argc, "split", EXPECTED_EQUAL_TO, 1))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "split", + "Can't run this command while there's no outputs connected."); + } if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { return do_split(L_VERT); } else if (strcasecmp(argv[0], "h") == 0 || diff --git a/sway/commands/swap.c b/sway/commands/swap.c index afe11a47..a70a6cdd 100644 --- a/sway/commands/swap.c +++ b/sway/commands/swap.c @@ -171,6 +171,10 @@ struct cmd_results *cmd_swap(int argc, char **argv) { if ((error = checkarg(argc, "swap", EXPECTED_AT_LEAST, 4))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "swap", + "Can't run this command while there's no outputs connected."); + } if (strcasecmp(argv[0], "container") || strcasecmp(argv[1], "with")) { return cmd_results_new(CMD_INVALID, "swap", EXPECTED_SYNTAX); diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 745b40c7..8364e607 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c @@ -38,6 +38,10 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { if ((error = checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1))) { return error; } + if (!root->outputs->length) { + return cmd_results_new(CMD_INVALID, "workspace", + "Can't run this command while there's no outputs connected."); + } int output_location = -1; int gaps_location = -1; diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 018a7285..ed9300bb 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -11,10 +11,11 @@ #include <wlr/types/wlr_output_damage.h> #include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output.h> +#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_surface.h> #include <wlr/util/region.h> -#include "log.h" #include "config.h" +#include "log.h" #include "sway/config.h" #include "sway/desktop/transaction.h" #include "sway/input/input-manager.h" @@ -223,6 +224,75 @@ void output_drag_icons_for_each_surface(struct sway_output *output, } } +static void for_each_surface_container_iterator(struct sway_container *con, + void *_data) { + if (!con->view || !view_is_visible(con->view)) { + return; + } + + struct surface_iterator_data *data = _data; + output_view_for_each_surface(data->output, con->view, + data->user_iterator, data->user_data); +} + +static void output_for_each_surface(struct sway_output *output, + sway_surface_iterator_func_t iterator, void *user_data) { + if (output_has_opaque_overlay_layer_surface(output)) { + goto overlay; + } + + struct surface_iterator_data data = { + .user_iterator = iterator, + .user_data = user_data, + .output = output, + }; + + struct sway_workspace *workspace = output_get_active_workspace(output); + if (workspace->current.fullscreen) { + for_each_surface_container_iterator( + workspace->current.fullscreen, &data); + container_for_each_child(workspace->current.fullscreen, + for_each_surface_container_iterator, &data); + for (int i = 0; i < workspace->current.floating->length; ++i) { + struct sway_container *floater = + workspace->current.floating->items[i]; + if (container_is_transient_for(floater, + workspace->current.fullscreen)) { + for_each_surface_container_iterator(floater, &data); + } + } +#ifdef HAVE_XWAYLAND + output_unmanaged_for_each_surface(output, &root->xwayland_unmanaged, + iterator, user_data); +#endif + } else { + output_layer_for_each_surface(output, + &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], + iterator, user_data); + output_layer_for_each_surface(output, + &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], + iterator, user_data); + + workspace_for_each_container(workspace, + for_each_surface_container_iterator, &data); + +#ifdef HAVE_XWAYLAND + output_unmanaged_for_each_surface(output, &root->xwayland_unmanaged, + iterator, user_data); +#endif + output_layer_for_each_surface(output, + &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], + iterator, user_data); + } + +overlay: + output_layer_for_each_surface(output, + &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], + iterator, user_data); + output_drag_icons_for_each_surface(output, &root->drag_icons, + iterator, user_data); +} + static int scale_length(int length, int offset, float scale) { return round((offset + length) * scale) - round(offset * scale); } @@ -274,96 +344,13 @@ bool output_has_opaque_overlay_layer_surface(struct sway_output *output) { static void send_frame_done_iterator(struct sway_output *output, struct wlr_surface *surface, struct wlr_box *box, float rotation, - void *_data) { - struct timespec *when = _data; + void *data) { + struct timespec *when = data; wlr_surface_send_frame_done(surface, when); } -static void send_frame_done_layer(struct sway_output *output, - struct wl_list *layer_surfaces, struct timespec *when) { - output_layer_for_each_surface(output, layer_surfaces, - send_frame_done_iterator, when); -} - -#ifdef HAVE_XWAYLAND -static void send_frame_done_unmanaged(struct sway_output *output, - struct wl_list *unmanaged, struct timespec *when) { - output_unmanaged_for_each_surface(output, unmanaged, - send_frame_done_iterator, when); -} -#endif - -static void send_frame_done_drag_icons(struct sway_output *output, - struct wl_list *drag_icons, struct timespec *when) { - output_drag_icons_for_each_surface(output, drag_icons, - send_frame_done_iterator, when); -} - -struct send_frame_done_data { - struct sway_output *output; - struct timespec *when; -}; - -static void send_frame_done_container_iterator(struct sway_container *con, - void *_data) { - if (!con->view) { - return; - } - if (!view_is_visible(con->view)) { - return; - } - - struct send_frame_done_data *data = _data; - output_view_for_each_surface(data->output, con->view, - send_frame_done_iterator, data->when); -} - static void send_frame_done(struct sway_output *output, struct timespec *when) { - if (output_has_opaque_overlay_layer_surface(output)) { - goto send_frame_overlay; - } - - struct send_frame_done_data data = { - .output = output, - .when = when, - }; - struct sway_workspace *workspace = output_get_active_workspace(output); - if (workspace->current.fullscreen) { - send_frame_done_container_iterator( - workspace->current.fullscreen, &data); - container_for_each_child(workspace->current.fullscreen, - send_frame_done_container_iterator, &data); - for (int i = 0; i < workspace->current.floating->length; ++i) { - struct sway_container *floater = - workspace->current.floating->items[i]; - if (container_is_transient_for(floater, - workspace->current.fullscreen)) { - send_frame_done_container_iterator(floater, &data); - } - } -#ifdef HAVE_XWAYLAND - send_frame_done_unmanaged(output, &root->xwayland_unmanaged, when); -#endif - } else { - send_frame_done_layer(output, - &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], when); - send_frame_done_layer(output, - &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM], when); - - workspace_for_each_container(workspace, - send_frame_done_container_iterator, &data); - -#ifdef HAVE_XWAYLAND - send_frame_done_unmanaged(output, &root->xwayland_unmanaged, when); -#endif - send_frame_done_layer(output, - &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], when); - } - -send_frame_overlay: - send_frame_done_layer(output, - &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], when); - send_frame_done_drag_icons(output, &root->drag_icons, when); + output_for_each_surface(output, send_frame_done_iterator, when); } static void damage_handle_frame(struct wl_listener *listener, void *data) { @@ -545,6 +532,29 @@ static void handle_scale(struct wl_listener *listener, void *data) { transaction_commit_dirty(); } +static void send_presented_iterator(struct sway_output *output, + struct wlr_surface *surface, struct wlr_box *box, float rotation, + void *data) { + struct wlr_presentation_event *event = data; + wlr_presentation_send_surface_presented(server.presentation, + surface, event); +} + +static void handle_present(struct wl_listener *listener, void *data) { + struct sway_output *output = wl_container_of(listener, output, present); + struct wlr_output_event_present *output_event = data; + + struct wlr_presentation_event event = { + .output = output->wlr_output, + .tv_sec = (uint64_t)output_event->when->tv_sec, + .tv_nsec = (uint32_t)output_event->when->tv_nsec, + .refresh = (uint32_t)output_event->refresh, + .seq = (uint64_t)output_event->seq, + .flags = output_event->flags, + }; + output_for_each_surface(output, send_presented_iterator, &event); +} + void handle_new_output(struct wl_listener *listener, void *data) { struct sway_server *server = wl_container_of(listener, server, new_output); struct wlr_output *wlr_output = data; @@ -571,6 +581,7 @@ void output_add_listeners(struct sway_output *output) { output->mode.notify = handle_mode; output->transform.notify = handle_transform; output->scale.notify = handle_scale; + output->present.notify = handle_present; output->damage_frame.notify = damage_handle_frame; output->damage_destroy.notify = damage_handle_destroy; } 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); -} diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 064e2707..0b2ebc96 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -397,11 +397,6 @@ 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); @@ -428,8 +423,7 @@ 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); - struct sway_seat *seat = input_manager_current_seat(); - transaction_commit_dirty_with_callback(do_rebase, seat->cursor); + transaction_commit_dirty(); 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 90bf55b2..692cfbf5 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -394,11 +394,6 @@ 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); @@ -419,8 +414,7 @@ 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); - struct sway_seat *seat = input_manager_current_seat(); - transaction_commit_dirty_with_callback(do_rebase, seat->cursor); + transaction_commit_dirty(); 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 95275937..0c41d960 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -391,11 +391,6 @@ 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); @@ -422,8 +417,7 @@ static void handle_map(struct wl_listener *listener, void *data) { // Put it back into the tree view_map(view, xsurface->surface, xsurface->fullscreen, false); - struct sway_seat *seat = input_manager_current_seat(); - transaction_commit_dirty_with_callback(do_rebase, seat->cursor); + transaction_commit_dirty(); } static void handle_request_configure(struct wl_listener *listener, void *data) { diff --git a/sway/input/seat.c b/sway/input/seat.c index 89d841bb..577619a7 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -1196,5 +1196,4 @@ void seat_consider_warp_to_focus(struct sway_seat *seat) { } else { cursor_warp_to_workspace(seat->cursor, focus->sway_workspace); } - cursor_rebase(seat->cursor); } diff --git a/sway/server.c b/sway/server.c index 23d42028..f06173d1 100644 --- a/sway/server.c +++ b/sway/server.c @@ -135,6 +135,9 @@ bool server_init(struct sway_server *server) { server->xdg_decoration.notify = handle_xdg_decoration; wl_list_init(&server->xdg_decorations); + server->presentation = + wlr_presentation_create(server->wl_display, server->backend); + wlr_export_dmabuf_manager_v1_create(server->wl_display); wlr_screencopy_manager_v1_create(server->wl_display); diff --git a/sway/tree/output.c b/sway/tree/output.c index 04219b5f..e5794b8a 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -103,6 +103,7 @@ void output_enable(struct sway_output *output, struct output_config *oc) { wl_signal_add(&wlr_output->events.mode, &output->mode); wl_signal_add(&wlr_output->events.transform, &output->transform); wl_signal_add(&wlr_output->events.scale, &output->scale); + wl_signal_add(&wlr_output->events.present, &output->present); wl_signal_add(&output->damage->events.frame, &output->damage_frame); wl_signal_add(&output->damage->events.destroy, &output->damage_destroy); @@ -214,6 +215,7 @@ void output_disable(struct sway_output *output) { wl_list_remove(&output->mode.link); wl_list_remove(&output->transform.link); wl_list_remove(&output->scale.link); + wl_list_remove(&output->present.link); wl_list_remove(&output->damage_destroy.link); wl_list_remove(&output->damage_frame.link); diff --git a/sway/tree/view.c b/sway/tree/view.c index 20babf7b..4bc9e0f3 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -661,7 +661,6 @@ void view_unmap(struct sway_view *view) { cursor_warp_to_workspace(seat->cursor, node->sway_workspace); } } - cursor_rebase(seat->cursor); } transaction_commit_dirty(); diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 65284679..27e9ac7a 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -404,7 +404,6 @@ bool workspace_switch(struct sway_workspace *workspace, } seat_set_focus(seat, next); arrange_workspace(workspace); - cursor_rebase(seat->cursor); return true; } |