aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/input/seat.h7
-rw-r--r--sway/input/cursor.c18
-rw-r--r--sway/input/seat.c10
-rw-r--r--sway/input/seatop_default.c39
4 files changed, 61 insertions, 13 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h
index ad7cac75..1e255b47 100644
--- a/include/sway/input/seat.h
+++ b/include/sway/input/seat.h
@@ -7,6 +7,7 @@
7#include <wlr/util/edges.h> 7#include <wlr/util/edges.h>
8#include "sway/config.h" 8#include "sway/config.h"
9#include "sway/input/input-manager.h" 9#include "sway/input/input-manager.h"
10#include "sway/input/tablet.h"
10#include "sway/input/text_input.h" 11#include "sway/input/text_input.h"
11 12
12struct sway_seat; 13struct sway_seat;
@@ -19,6 +20,8 @@ struct sway_seatop_impl {
19 double dx, double dy); 20 double dx, double dy);
20 void (*axis)(struct sway_seat *seat, struct wlr_event_pointer_axis *event); 21 void (*axis)(struct sway_seat *seat, struct wlr_event_pointer_axis *event);
21 void (*rebase)(struct sway_seat *seat, uint32_t time_msec); 22 void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
23 void (*tablet_tool_motion)(struct sway_seat *seat, struct sway_tablet *tablet,
24 struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy);
22 void (*end)(struct sway_seat *seat); 25 void (*end)(struct sway_seat *seat);
23 void (*unref)(struct sway_seat *seat, struct sway_container *con); 26 void (*unref)(struct sway_seat *seat, struct sway_container *con);
24 void (*render)(struct sway_seat *seat, struct sway_output *output, 27 void (*render)(struct sway_seat *seat, struct sway_output *output,
@@ -261,6 +264,10 @@ void seatop_button(struct sway_seat *seat, uint32_t time_msec,
261void seatop_motion(struct sway_seat *seat, uint32_t time_msec, 264void seatop_motion(struct sway_seat *seat, uint32_t time_msec,
262 double dx, double dy); 265 double dx, double dy);
263 266
267void seatop_tablet_tool_motion(struct sway_seat *seat,
268 struct sway_tablet *tablet, struct sway_tablet_tool *tool,
269 uint32_t time_msec, double dx, double dy);
270
264void seatop_axis(struct sway_seat *seat, struct wlr_event_pointer_axis *event); 271void seatop_axis(struct sway_seat *seat, struct wlr_event_pointer_axis *event);
265 272
266void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); 273void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);
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
565static void handle_tool_axis(struct wl_listener *listener, void *data) { 557static 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
1465void 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
1465void seatop_rebase(struct sway_seat *seat, uint32_t time_msec) { 1475void 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
477static 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};