mirror of
https://github.com/swaywm/sway.git
synced 2025-11-23 06:59:48 -05:00
Rebase the cursor after mapping a view
I originally put the rebase at the end of view_map, but at this point the view is still at its native size and will ignore the motion event if it falls outside of its native size. The only way to do this properly is to rebase the cursor later - either after sending the configure, after the view commits with the new size, or after applying the transaction. I chose to do it after applying the transaction for simplicity. I then attempted to just call cursor_rebase after applying every transaction, but this causes crashes when exiting sway (and possibly other places) because cursor_rebase assumes the tree is in a valid state. So my chosen solution introduces transaction_commit_dirty_with_callback which allows handle_map to register a callback which will run when the transaction is applied.
This commit is contained in:
parent
bdb176863c
commit
bdae625cb3
5 changed files with 63 additions and 11 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue