diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-05-07 18:57:06 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-10 16:49:35 +0200 |
commit | 726d187d3ce83431a2565cc1b423af99da5f7b6b (patch) | |
tree | 0e24b86e18f4e5abd20aff47eb14dfbf81f897b7 | |
parent | input/keyboard: use wlr_keyboard_keymaps_match from wlroots (diff) | |
download | sway-726d187d3ce83431a2565cc1b423af99da5f7b6b.tar.gz sway-726d187d3ce83431a2565cc1b423af99da5f7b6b.tar.zst sway-726d187d3ce83431a2565cc1b423af99da5f7b6b.zip |
input/tablet: simplify parameter plumbing for tablet references
This is a small cleanup commit for removing `sway_tablet` parameters
from functions that already accept `sway_tablet_tool`, since the tablet
reference can be accessed through `tool->tablet`.
-rw-r--r-- | include/sway/input/seat.h | 5 | ||||
-rw-r--r-- | sway/input/cursor.c | 17 | ||||
-rw-r--r-- | sway/input/seat.c | 5 | ||||
-rw-r--r-- | sway/input/seatop_default.c | 5 |
4 files changed, 14 insertions, 18 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 2e98a244..fa232aa2 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -21,7 +21,7 @@ struct sway_seatop_impl { | |||
21 | void (*pointer_axis)(struct sway_seat *seat, | 21 | void (*pointer_axis)(struct sway_seat *seat, |
22 | struct wlr_event_pointer_axis *event); | 22 | struct wlr_event_pointer_axis *event); |
23 | void (*rebase)(struct sway_seat *seat, uint32_t time_msec); | 23 | void (*rebase)(struct sway_seat *seat, uint32_t time_msec); |
24 | void (*tablet_tool_motion)(struct sway_seat *seat, struct sway_tablet *tablet, | 24 | void (*tablet_tool_motion)(struct sway_seat *seat, |
25 | struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy); | 25 | struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy); |
26 | void (*end)(struct sway_seat *seat); | 26 | void (*end)(struct sway_seat *seat); |
27 | void (*unref)(struct sway_seat *seat, struct sway_container *con); | 27 | void (*unref)(struct sway_seat *seat, struct sway_container *con); |
@@ -269,8 +269,7 @@ void seatop_pointer_axis(struct sway_seat *seat, | |||
269 | struct wlr_event_pointer_axis *event); | 269 | struct wlr_event_pointer_axis *event); |
270 | 270 | ||
271 | void seatop_tablet_tool_motion(struct sway_seat *seat, | 271 | void seatop_tablet_tool_motion(struct sway_seat *seat, |
272 | struct sway_tablet *tablet, struct sway_tablet_tool *tool, | 272 | struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy); |
273 | uint32_t time_msec, double dx, double dy); | ||
274 | 273 | ||
275 | void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); | 274 | void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); |
276 | 275 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 271c95f9..bb846e38 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -511,8 +511,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device, | |||
511 | } | 511 | } |
512 | 512 | ||
513 | static void handle_tablet_tool_position(struct sway_cursor *cursor, | 513 | static void handle_tablet_tool_position(struct sway_cursor *cursor, |
514 | struct sway_tablet *tablet, | 514 | struct sway_tablet_tool *tool, |
515 | struct wlr_tablet_tool *tool, | ||
516 | bool change_x, bool change_y, | 515 | bool change_x, bool change_y, |
517 | double x, double y, double dx, double dy, | 516 | double x, double y, double dx, double dy, |
518 | int32_t time_msec) { | 517 | int32_t time_msec) { |
@@ -522,6 +521,7 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, | |||
522 | return; | 521 | return; |
523 | } | 522 | } |
524 | 523 | ||
524 | struct sway_tablet *tablet = tool->tablet; | ||
525 | struct sway_input_device *input_device = tablet->seat_device->input_device; | 525 | struct sway_input_device *input_device = tablet->seat_device->input_device; |
526 | struct input_config *ic = input_device_get_config(input_device); | 526 | struct input_config *ic = input_device_get_config(input_device); |
527 | if (ic != NULL && ic->mapped_from_region != NULL) { | 527 | if (ic != NULL && ic->mapped_from_region != NULL) { |
@@ -529,7 +529,7 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, | |||
529 | ic->mapped_from_region, &x, &y); | 529 | ic->mapped_from_region, &x, &y); |
530 | } | 530 | } |
531 | 531 | ||
532 | switch (tool->type) { | 532 | switch (tool->tablet_v2_tool->wlr_tool->type) { |
533 | case WLR_TABLET_TOOL_TYPE_MOUSE: | 533 | case WLR_TABLET_TOOL_TYPE_MOUSE: |
534 | wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy); | 534 | wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy); |
535 | break; | 535 | break; |
@@ -542,12 +542,11 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, | |||
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 | node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | 544 | node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
545 | struct sway_tablet_tool *sway_tool = tool->data; | ||
546 | 545 | ||
547 | if (surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) { | 546 | if (surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) { |
548 | seatop_tablet_tool_motion(seat, tablet, sway_tool, time_msec, dx, dy); | 547 | seatop_tablet_tool_motion(seat, tool, time_msec, dx, dy); |
549 | } else { | 548 | } else { |
550 | wlr_tablet_v2_tablet_tool_notify_proximity_out(sway_tool->tablet_v2_tool); | 549 | wlr_tablet_v2_tablet_tool_notify_proximity_out(tool->tablet_v2_tool); |
551 | pointer_motion(cursor, time_msec, input_device->wlr_device, dx, dy, dx, dy); | 550 | pointer_motion(cursor, time_msec, input_device->wlr_device, dx, dy, dx, dy); |
552 | } | 551 | } |
553 | 552 | ||
@@ -565,7 +564,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) { | |||
565 | return; | 564 | return; |
566 | } | 565 | } |
567 | 566 | ||
568 | handle_tablet_tool_position(cursor, sway_tool->tablet, event->tool, | 567 | handle_tablet_tool_position(cursor, sway_tool, |
569 | event->updated_axes & WLR_TABLET_TOOL_AXIS_X, | 568 | event->updated_axes & WLR_TABLET_TOOL_AXIS_X, |
570 | event->updated_axes & WLR_TABLET_TOOL_AXIS_Y, | 569 | event->updated_axes & WLR_TABLET_TOOL_AXIS_Y, |
571 | event->x, event->y, event->dx, event->dy, event->time_msec); | 570 | event->x, event->y, event->dx, event->dy, event->time_msec); |
@@ -691,8 +690,8 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) { | |||
691 | return; | 690 | return; |
692 | } | 691 | } |
693 | 692 | ||
694 | handle_tablet_tool_position(cursor, sway_tool->tablet, event->tool, | 693 | handle_tablet_tool_position(cursor, sway_tool, true, true, event->x, event->y, |
695 | true, true, event->x, event->y, 0, 0, event->time_msec); | 694 | 0, 0, event->time_msec); |
696 | } | 695 | } |
697 | 696 | ||
698 | static void handle_tool_button(struct wl_listener *listener, void *data) { | 697 | static void handle_tool_button(struct wl_listener *listener, void *data) { |
diff --git a/sway/input/seat.c b/sway/input/seat.c index 4abffb25..aa46940d 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -1464,10 +1464,9 @@ void seatop_pointer_axis(struct sway_seat *seat, | |||
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | void seatop_tablet_tool_motion(struct sway_seat *seat, | 1466 | void seatop_tablet_tool_motion(struct sway_seat *seat, |
1467 | struct sway_tablet *tablet, struct sway_tablet_tool *tool, | 1467 | struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy) { |
1468 | uint32_t time_msec, double dx, double dy) { | ||
1469 | if (seat->seatop_impl->tablet_tool_motion) { | 1468 | if (seat->seatop_impl->tablet_tool_motion) { |
1470 | seat->seatop_impl->tablet_tool_motion(seat, tablet, tool, time_msec, dx, dy); | 1469 | seat->seatop_impl->tablet_tool_motion(seat, tool, time_msec, dx, dy); |
1471 | } else { | 1470 | } else { |
1472 | seatop_pointer_motion(seat, time_msec, dx, dy); | 1471 | seatop_pointer_motion(seat, time_msec, dx, dy); |
1473 | } | 1472 | } |
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index e0838c04..64a17157 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -475,8 +475,7 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec, | |||
475 | } | 475 | } |
476 | 476 | ||
477 | static void handle_tablet_tool_motion(struct sway_seat *seat, | 477 | static void handle_tablet_tool_motion(struct sway_seat *seat, |
478 | struct sway_tablet *tablet, struct sway_tablet_tool *tool, | 478 | struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy) { |
479 | uint32_t time_msec, double dx, double dy) { | ||
480 | struct seatop_default_event *e = seat->seatop_data; | 479 | struct seatop_default_event *e = seat->seatop_data; |
481 | struct sway_cursor *cursor = seat->cursor; | 480 | struct sway_cursor *cursor = seat->cursor; |
482 | 481 | ||
@@ -492,7 +491,7 @@ static void handle_tablet_tool_motion(struct sway_seat *seat, | |||
492 | if (surface) { | 491 | if (surface) { |
493 | if (seat_is_input_allowed(seat, surface)) { | 492 | if (seat_is_input_allowed(seat, surface)) { |
494 | wlr_tablet_v2_tablet_tool_notify_proximity_in(tool->tablet_v2_tool, | 493 | wlr_tablet_v2_tablet_tool_notify_proximity_in(tool->tablet_v2_tool, |
495 | tablet->tablet_v2, surface); | 494 | tool->tablet->tablet_v2, surface); |
496 | wlr_tablet_v2_tablet_tool_notify_motion(tool->tablet_v2_tool, sx, sy); | 495 | wlr_tablet_v2_tablet_tool_notify_motion(tool->tablet_v2_tool, sx, sy); |
497 | } | 496 | } |
498 | } else { | 497 | } else { |