aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xdg_shell.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-24 19:38:52 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-24 19:38:52 +1000
commitbdae625cb344209424841a7c5f0c0967773c8c10 (patch)
tree754adb52ec2e2eb9d336d1c826bab62ea96e6c52 /sway/desktop/xdg_shell.c
parentMerge pull request #2933 from Snaipe/xwayland-window-properties (diff)
downloadsway-bdae625cb344209424841a7c5f0c0967773c8c10.tar.gz
sway-bdae625cb344209424841a7c5f0c0967773c8c10.tar.zst
sway-bdae625cb344209424841a7c5f0c0967773c8c10.zip
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.
Diffstat (limited to 'sway/desktop/xdg_shell.c')
-rw-r--r--sway/desktop/xdg_shell.c9
1 files changed, 8 insertions, 1 deletions
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 @@
9#include "sway/decoration.h" 9#include "sway/decoration.h"
10#include "sway/desktop.h" 10#include "sway/desktop.h"
11#include "sway/desktop/transaction.h" 11#include "sway/desktop/transaction.h"
12#include "sway/input/cursor.h"
12#include "sway/input/input-manager.h" 13#include "sway/input/input-manager.h"
13#include "sway/input/seat.h" 14#include "sway/input/seat.h"
14#include "sway/output.h" 15#include "sway/output.h"
@@ -396,6 +397,11 @@ static void handle_unmap(struct wl_listener *listener, void *data) {
396 wl_list_remove(&xdg_shell_view->set_app_id.link); 397 wl_list_remove(&xdg_shell_view->set_app_id.link);
397} 398}
398 399
400static void do_rebase(void *data) {
401 struct sway_cursor *cursor = data;
402 cursor_rebase(cursor);
403}
404
399static void handle_map(struct wl_listener *listener, void *data) { 405static void handle_map(struct wl_listener *listener, void *data) {
400 struct sway_xdg_shell_view *xdg_shell_view = 406 struct sway_xdg_shell_view *xdg_shell_view =
401 wl_container_of(listener, xdg_shell_view, map); 407 wl_container_of(listener, xdg_shell_view, map);
@@ -422,7 +428,8 @@ static void handle_map(struct wl_listener *listener, void *data) {
422 view_map(view, view->wlr_xdg_surface->surface, 428 view_map(view, view->wlr_xdg_surface->surface,
423 xdg_surface->toplevel->client_pending.fullscreen, csd); 429 xdg_surface->toplevel->client_pending.fullscreen, csd);
424 430
425 transaction_commit_dirty(); 431 struct sway_seat *seat = input_manager_current_seat();
432 transaction_commit_dirty_with_callback(do_rebase, seat->cursor);
426 433
427 xdg_shell_view->commit.notify = handle_commit; 434 xdg_shell_view->commit.notify = handle_commit;
428 wl_signal_add(&xdg_surface->surface->events.commit, 435 wl_signal_add(&xdg_surface->surface->events.commit,