Merge pull request #2957 from RyanDwyer/rebase-cursor-after-map
Rebase the cursor after mapping a view
This commit is contained in:
commit
46fc4ba4e3
|
@ -28,6 +28,13 @@ 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.
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue