diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-04-25 17:57:47 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-02 13:32:28 +0200 |
commit | ae3ec745f84c1efb643d61c0fc9a345745c07da5 (patch) | |
tree | a5474c0678329d1a8ae826fd484754c65f561254 /sway | |
parent | input/cursor: disambiguate cursor functions from pointer functions (diff) | |
download | sway-ae3ec745f84c1efb643d61c0fc9a345745c07da5.tar.gz sway-ae3ec745f84c1efb643d61c0fc9a345745c07da5.tar.zst sway-ae3ec745f84c1efb643d61c0fc9a345745c07da5.zip |
input: refactor tablet motion into seatop handler
This commit moves tablet motion logic into a seatop handler.
As a side-effect of seatop implementations being able to receive
tablet motion events, fixes #5232.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/cursor.c | 18 | ||||
-rw-r--r-- | sway/input/seat.c | 10 | ||||
-rw-r--r-- | sway/input/seatop_default.c | 39 |
3 files changed, 54 insertions, 13 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 1827c744..b38b62c8 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -541,25 +541,17 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, | |||
541 | double sx, sy; | 541 | double sx, sy; |
542 | struct wlr_surface *surface = NULL; | 542 | struct wlr_surface *surface = NULL; |
543 | struct sway_seat *seat = cursor->seat; | 543 | struct sway_seat *seat = cursor->seat; |
544 | struct sway_node *focused_node = node_at_coords(seat, cursor->cursor->x, | 544 | node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
545 | cursor->cursor->y, &surface, &sx, &sy); | ||
546 | struct sway_tablet_tool *sway_tool = tool->data; | 545 | struct sway_tablet_tool *sway_tool = tool->data; |
547 | 546 | ||
548 | if (!surface || !wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) { | 547 | if (surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) { |
548 | seatop_tablet_tool_motion(seat, tablet, sway_tool, time_msec, dx, dy); | ||
549 | } else { | ||
549 | wlr_tablet_v2_tablet_tool_notify_proximity_out(sway_tool->tablet_v2_tool); | 550 | wlr_tablet_v2_tablet_tool_notify_proximity_out(sway_tool->tablet_v2_tool); |
550 | pointer_motion(cursor, time_msec, input_device->wlr_device, dx, dy, dx, dy); | 551 | pointer_motion(cursor, time_msec, input_device->wlr_device, dx, dy, dx, dy); |
551 | transaction_commit_dirty(); | ||
552 | return; | ||
553 | } | ||
554 | |||
555 | wlr_tablet_v2_tablet_tool_notify_proximity_in(sway_tool->tablet_v2_tool, | ||
556 | tablet->tablet_v2, surface); | ||
557 | |||
558 | if (focused_node && config->focus_follows_mouse != FOLLOWS_NO) { | ||
559 | seat_set_focus(seat, focused_node); | ||
560 | } | 552 | } |
561 | 553 | ||
562 | wlr_tablet_v2_tablet_tool_notify_motion(sway_tool->tablet_v2_tool, sx, sy); | 554 | transaction_commit_dirty(); |
563 | } | 555 | } |
564 | 556 | ||
565 | static void handle_tool_axis(struct wl_listener *listener, void *data) { | 557 | static void handle_tool_axis(struct wl_listener *listener, void *data) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index df54261d..27751c27 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1462,6 +1462,16 @@ void seatop_axis(struct sway_seat *seat, struct wlr_event_pointer_axis *event) { | |||
1462 | } | 1462 | } |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | void seatop_tablet_tool_motion(struct sway_seat *seat, | ||
1466 | struct sway_tablet *tablet, struct sway_tablet_tool *tool, | ||
1467 | uint32_t time_msec, double dx, double dy) { | ||
1468 | if (seat->seatop_impl->tablet_tool_motion) { | ||
1469 | seat->seatop_impl->tablet_tool_motion(seat, tablet, tool, time_msec, dx, dy); | ||
1470 | } else { | ||
1471 | seatop_motion(seat, time_msec, dx, dy); | ||
1472 | } | ||
1473 | } | ||
1474 | |||
1465 | void seatop_rebase(struct sway_seat *seat, uint32_t time_msec) { | 1475 | void seatop_rebase(struct sway_seat *seat, uint32_t time_msec) { |
1466 | if (seat->seatop_impl->rebase) { | 1476 | if (seat->seatop_impl->rebase) { |
1467 | seat->seatop_impl->rebase(seat, time_msec); | 1477 | seat->seatop_impl->rebase(seat, time_msec); |
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index d9f9e371..b7e3ff3f 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -2,9 +2,11 @@ | |||
2 | #include <float.h> | 2 | #include <float.h> |
3 | #include <libevdev/libevdev.h> | 3 | #include <libevdev/libevdev.h> |
4 | #include <wlr/types/wlr_cursor.h> | 4 | #include <wlr/types/wlr_cursor.h> |
5 | #include <wlr/types/wlr_tablet_v2.h> | ||
5 | #include <wlr/types/wlr_xcursor_manager.h> | 6 | #include <wlr/types/wlr_xcursor_manager.h> |
6 | #include "sway/input/cursor.h" | 7 | #include "sway/input/cursor.h" |
7 | #include "sway/input/seat.h" | 8 | #include "sway/input/seat.h" |
9 | #include "sway/input/tablet.h" | ||
8 | #include "sway/tree/view.h" | 10 | #include "sway/tree/view.h" |
9 | #include "log.h" | 11 | #include "log.h" |
10 | #if HAVE_XWAYLAND | 12 | #if HAVE_XWAYLAND |
@@ -472,6 +474,42 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec, | |||
472 | e->previous_node = node; | 474 | e->previous_node = node; |
473 | } | 475 | } |
474 | 476 | ||
477 | static void handle_tablet_tool_motion(struct sway_seat *seat, | ||
478 | struct sway_tablet *tablet, struct sway_tablet_tool *tool, | ||
479 | uint32_t time_msec, double dx, double dy) { | ||
480 | struct seatop_default_event *e = seat->seatop_data; | ||
481 | struct sway_cursor *cursor = seat->cursor; | ||
482 | |||
483 | struct wlr_surface *surface = NULL; | ||
484 | double sx, sy; | ||
485 | struct sway_node *node = node_at_coords(seat, | ||
486 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | ||
487 | |||
488 | if (node && config->focus_follows_mouse != FOLLOWS_NO) { | ||
489 | check_focus_follows_mouse(seat, e, node); | ||
490 | } | ||
491 | |||
492 | if (surface) { | ||
493 | if (seat_is_input_allowed(seat, surface)) { | ||
494 | wlr_tablet_v2_tablet_tool_notify_proximity_in(tool->tablet_v2_tool, | ||
495 | tablet->tablet_v2, surface); | ||
496 | wlr_tablet_v2_tablet_tool_notify_motion(tool->tablet_v2_tool, sx, sy); | ||
497 | } | ||
498 | } else { | ||
499 | cursor_update_image(cursor, node); | ||
500 | wlr_tablet_v2_tablet_tool_notify_proximity_out(tool->tablet_v2_tool); | ||
501 | } | ||
502 | |||
503 | struct sway_drag_icon *drag_icon; | ||
504 | wl_list_for_each(drag_icon, &root->drag_icons, link) { | ||
505 | if (drag_icon->seat == seat) { | ||
506 | drag_icon_update_position(drag_icon); | ||
507 | } | ||
508 | } | ||
509 | |||
510 | e->previous_node = node; | ||
511 | } | ||
512 | |||
475 | /*--------------------------------\ | 513 | /*--------------------------------\ |
476 | * Functions used by handle_axis / | 514 | * Functions used by handle_axis / |
477 | *------------------------------*/ | 515 | *------------------------------*/ |
@@ -612,6 +650,7 @@ static const struct sway_seatop_impl seatop_impl = { | |||
612 | .button = handle_button, | 650 | .button = handle_button, |
613 | .motion = handle_motion, | 651 | .motion = handle_motion, |
614 | .axis = handle_axis, | 652 | .axis = handle_axis, |
653 | .tablet_tool_motion = handle_tablet_tool_motion, | ||
615 | .rebase = handle_rebase, | 654 | .rebase = handle_rebase, |
616 | .allow_set_cursor = true, | 655 | .allow_set_cursor = true, |
617 | }; | 656 | }; |