aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seatop_default.c
diff options
context:
space:
mode:
authorLibravatar Stacy Harper <contact@stacyharper.net>2021-08-21 16:04:08 +0200
committerLibravatar Simon Zeni <simon@bl4ckb0ne.ca>2023-02-20 10:35:10 -0500
commit4666d1785bfb6635e6e8604de383c91714bceebc (patch)
treee940606bd8e735c26b4239342afe88116bf9f457 /sway/input/seatop_default.c
parentlayer-shell: enter output before surface is mapped (diff)
downloadsway-4666d1785bfb6635e6e8604de383c91714bceebc.tar.gz
sway-4666d1785bfb6635e6e8604de383c91714bceebc.tar.zst
sway-4666d1785bfb6635e6e8604de383c91714bceebc.zip
Implement seatop_touch
Atm we got issue with the touch position sent to the clients. While holding contact, leaving the initial container will continue to send motion event to the client but with the new local position from the new container. This seatop goal is to send the position of the touch event, relatively to the initial container layout position.
Diffstat (limited to 'sway/input/seatop_default.c')
-rw-r--r--sway/input/seatop_default.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index 0dcb87ab..5a55c186 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -261,7 +261,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
261 261
262 // Handle tapping on a container surface 262 // Handle tapping on a container surface
263 seat_set_focus_container(seat, cont); 263 seat_set_focus_container(seat, cont);
264 seatop_begin_down(seat, node->sway_container, time_msec, sx, sy); 264 seatop_begin_down(seat, node->sway_container, sx, sy);
265 } 265 }
266#if HAVE_XWAYLAND 266#if HAVE_XWAYLAND
267 // Handle tapping on an xwayland unmanaged view 267 // Handle tapping on an xwayland unmanaged view
@@ -374,7 +374,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
374 transaction_commit_dirty(); 374 transaction_commit_dirty();
375 } 375 }
376 if (state == WLR_BUTTON_PRESSED) { 376 if (state == WLR_BUTTON_PRESSED) {
377 seatop_begin_down_on_surface(seat, surface, time_msec, sx, sy); 377 seatop_begin_down_on_surface(seat, surface, sx, sy);
378 } 378 }
379 seat_pointer_notify_button(seat, time_msec, button, state); 379 seat_pointer_notify_button(seat, time_msec, button, state);
380 return; 380 return;
@@ -499,7 +499,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
499 499
500 // Handle mousedown on a container surface 500 // Handle mousedown on a container surface
501 if (surface && cont && state == WLR_BUTTON_PRESSED) { 501 if (surface && cont && state == WLR_BUTTON_PRESSED) {
502 seatop_begin_down(seat, cont, time_msec, sx, sy); 502 seatop_begin_down(seat, cont, sx, sy);
503 seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED); 503 seat_pointer_notify_button(seat, time_msec, button, WLR_BUTTON_PRESSED);
504 return; 504 return;
505 } 505 }
@@ -649,6 +649,36 @@ static void handle_tablet_tool_motion(struct sway_seat *seat,
649 e->previous_node = node; 649 e->previous_node = node;
650} 650}
651 651
652static void handle_touch_down(struct sway_seat *seat,
653 struct wlr_touch_down_event *event, double lx, double ly) {
654 struct wlr_surface *surface = NULL;
655 struct wlr_seat *wlr_seat = seat->wlr_seat;
656 struct sway_cursor *cursor = seat->cursor;
657 double sx, sy;
658 node_at_coords(seat, seat->touch_x, seat->touch_y, &surface, &sx, &sy);
659
660 if (surface && wlr_surface_accepts_touch(wlr_seat, surface)) {
661 if (seat_is_input_allowed(seat, surface)) {
662 cursor->simulating_pointer_from_touch = false;
663 seatop_begin_touch_down(seat, surface, event, sx, sy, lx, ly);
664 }
665 } else if (!cursor->simulating_pointer_from_touch &&
666 (!surface || seat_is_input_allowed(seat, surface))) {
667 // Fallback to cursor simulation.
668 // The pointer_touch_id state is needed, so drags are not aborted when over
669 // a surface supporting touch and multi touch events don't interfere.
670 cursor->simulating_pointer_from_touch = true;
671 cursor->pointer_touch_id = seat->touch_id;
672 double dx, dy;
673 dx = seat->touch_x - cursor->cursor->x;
674 dy = seat->touch_y - cursor->cursor->y;
675 pointer_motion(cursor, event->time_msec, &event->touch->base, dx, dy,
676 dx, dy);
677 dispatch_cursor_button(cursor, &event->touch->base, event->time_msec,
678 BTN_LEFT, WLR_BUTTON_PRESSED);
679 }
680}
681
652/*----------------------------------------\ 682/*----------------------------------------\
653 * Functions used by handle_pointer_axis / 683 * Functions used by handle_pointer_axis /
654 *--------------------------------------*/ 684 *--------------------------------------*/
@@ -1096,6 +1126,7 @@ static const struct sway_seatop_impl seatop_impl = {
1096 .swipe_begin = handle_swipe_begin, 1126 .swipe_begin = handle_swipe_begin,
1097 .swipe_update = handle_swipe_update, 1127 .swipe_update = handle_swipe_update,
1098 .swipe_end = handle_swipe_end, 1128 .swipe_end = handle_swipe_end,
1129 .touch_down = handle_touch_down,
1099 .rebase = handle_rebase, 1130 .rebase = handle_rebase,
1100 .allow_set_cursor = true, 1131 .allow_set_cursor = true,
1101}; 1132};