aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-06-04 00:31:19 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2020-06-04 10:20:32 +0200
commitf7e050c58f61a15bf5987e2e3d280a72666f6381 (patch)
tree1e5f5779746514abdd532eceae6f4a758511a170
parentshells: Resize on commit if geometry x/y changes (diff)
downloadsway-f7e050c58f61a15bf5987e2e3d280a72666f6381.tar.gz
sway-f7e050c58f61a15bf5987e2e3d280a72666f6381.tar.zst
sway-f7e050c58f61a15bf5987e2e3d280a72666f6381.zip
input/cursor: refactor tablet tool tip events into seatops
This commit moves tool tip event generation into seatops. In doing so, some corner cases where we'd erroneously (but likely harmlessly) generate both tablet and pointer events simultaneously are eliminated.
-rw-r--r--sway/input/cursor.c45
-rw-r--r--sway/input/seatop_default.c6
-rw-r--r--sway/input/seatop_down.c1
3 files changed, 25 insertions, 27 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 85d0e825..1a211c3b 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -663,37 +663,30 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
663 node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, 663 node_at_coords(seat, cursor->cursor->x, cursor->cursor->y,
664 &surface, &sx, &sy); 664 &surface, &sx, &sy);
665 665
666 if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) { 666 if (cursor->simulating_pointer_from_tool_tip &&
667 // If we started holding the tool tip down on a surface that accepts tablet 667 event->state == WLR_TABLET_TOOL_TIP_UP) {
668 // v2, we should notify that surface if it gets released over a surface that 668 cursor->simulating_pointer_from_tool_tip = false;
669 // doesn't support v2.
670 if (event->state == WLR_TABLET_TOOL_TIP_UP) {
671 wlr_tablet_v2_tablet_tool_notify_up(sway_tool->tablet_v2_tool);
672 }
673
674 cursor->simulating_pointer_from_tool_tip = event->state == WLR_TABLET_TOOL_TIP_DOWN;
675 dispatch_cursor_button(cursor, event->device, event->time_msec, 669 dispatch_cursor_button(cursor, event->device, event->time_msec,
676 BTN_LEFT, cursor->simulating_pointer_from_tool_tip ? 670 BTN_LEFT, WLR_BUTTON_RELEASED);
677 WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED);
678 wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat); 671 wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
679 transaction_commit_dirty(); 672 transaction_commit_dirty();
680 return; 673 } else if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) {
681 } 674 // If we started holding the tool tip down on a surface that accepts
682 675 // tablet v2, we should notify that surface if it gets released over a
683 if (event->state == WLR_TABLET_TOOL_TIP_DOWN) { 676 // surface that doesn't support v2.
684 wlr_tablet_v2_tablet_tool_notify_down(sway_tool->tablet_v2_tool); 677 if (event->state == WLR_TABLET_TOOL_TIP_UP) {
685 wlr_tablet_tool_v2_start_implicit_grab(sway_tool->tablet_v2_tool); 678 seatop_tablet_tool_tip(seat, sway_tool, event->time_msec,
686 } else { 679 WLR_TABLET_TOOL_TIP_UP);
687 if (cursor->simulating_pointer_from_tool_tip) { 680 } else {
688 dispatch_cursor_button(cursor, event->device, event->time_msec, BTN_LEFT, 681 cursor->simulating_pointer_from_tool_tip = true;
689 WLR_BUTTON_RELEASED); 682 dispatch_cursor_button(cursor, event->device, event->time_msec,
690 cursor->simulating_pointer_from_tool_tip = false; 683 BTN_LEFT, WLR_BUTTON_PRESSED);
684 wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
685 transaction_commit_dirty();
691 } 686 }
692 687 } else {
693 wlr_tablet_v2_tablet_tool_notify_up(sway_tool->tablet_v2_tool); 688 seatop_tablet_tool_tip(seat, sway_tool, event->time_msec, event->state);
694 } 689 }
695
696 seatop_tablet_tool_tip(seat, sway_tool, event->time_msec, event->state);
697} 690}
698 691
699static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor, 692static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor,
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index 048bad75..072f4396 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -201,8 +201,12 @@ static void state_add_button(struct seatop_default_event *e, uint32_t button) {
201static void handle_tablet_tool_tip(struct sway_seat *seat, 201static void handle_tablet_tool_tip(struct sway_seat *seat,
202 struct sway_tablet_tool *tool, uint32_t time_msec, 202 struct sway_tablet_tool *tool, uint32_t time_msec,
203 enum wlr_tablet_tool_tip_state state) { 203 enum wlr_tablet_tool_tip_state state) {
204 if (state != WLR_TABLET_TOOL_TIP_DOWN) { 204 if (state == WLR_TABLET_TOOL_TIP_UP) {
205 wlr_tablet_v2_tablet_tool_notify_up(tool->tablet_v2_tool);
205 return; 206 return;
207 } else if (state == WLR_TABLET_TOOL_TIP_DOWN) {
208 wlr_tablet_v2_tablet_tool_notify_down(tool->tablet_v2_tool);
209 wlr_tablet_tool_v2_start_implicit_grab(tool->tablet_v2_tool);
206 } 210 }
207 211
208 struct sway_cursor *cursor = seat->cursor; 212 struct sway_cursor *cursor = seat->cursor;
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index dd8be6bf..0d24f480 100644
--- a/sway/input/seatop_down.c
+++ b/sway/input/seatop_down.c
@@ -54,6 +54,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
54 struct sway_tablet_tool *tool, uint32_t time_msec, 54 struct sway_tablet_tool *tool, uint32_t time_msec,
55 enum wlr_tablet_tool_tip_state state) { 55 enum wlr_tablet_tool_tip_state state) {
56 if (state == WLR_TABLET_TOOL_TIP_UP) { 56 if (state == WLR_TABLET_TOOL_TIP_UP) {
57 wlr_tablet_v2_tablet_tool_notify_up(tool->tablet_v2_tool);
57 seatop_begin_default(seat); 58 seatop_begin_default(seat);
58 } 59 }
59} 60}