aboutsummaryrefslogtreecommitdiff
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-06-04 00:31:19 -0400
committerSimon Ser <contact@emersion.fr>2020-06-04 10:20:32 +0200
commitf7e050c58f61a15bf5987e2e3d280a72666f6381 (patch)
tree1e5f5779746514abdd532eceae6f4a758511a170 /sway/input/cursor.c
parentf8dd7df1f510cdd2e53b25d2bb9a1edc19235e04 (diff)
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.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c45
1 files changed, 19 insertions, 26 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) {
node_at_coords(seat, cursor->cursor->x, cursor->cursor->y,
&surface, &sx, &sy);
- if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) {
- // If we started holding the tool tip down on a surface that accepts tablet
- // v2, we should notify that surface if it gets released over a surface that
- // doesn't support v2.
- if (event->state == WLR_TABLET_TOOL_TIP_UP) {
- wlr_tablet_v2_tablet_tool_notify_up(sway_tool->tablet_v2_tool);
- }
-
- cursor->simulating_pointer_from_tool_tip = event->state == WLR_TABLET_TOOL_TIP_DOWN;
+ if (cursor->simulating_pointer_from_tool_tip &&
+ event->state == WLR_TABLET_TOOL_TIP_UP) {
+ cursor->simulating_pointer_from_tool_tip = false;
dispatch_cursor_button(cursor, event->device, event->time_msec,
- BTN_LEFT, cursor->simulating_pointer_from_tool_tip ?
- WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED);
+ BTN_LEFT, WLR_BUTTON_RELEASED);
wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
transaction_commit_dirty();
- return;
- }
-
- if (event->state == WLR_TABLET_TOOL_TIP_DOWN) {
- wlr_tablet_v2_tablet_tool_notify_down(sway_tool->tablet_v2_tool);
- wlr_tablet_tool_v2_start_implicit_grab(sway_tool->tablet_v2_tool);
- } else {
- if (cursor->simulating_pointer_from_tool_tip) {
- dispatch_cursor_button(cursor, event->device, event->time_msec, BTN_LEFT,
- WLR_BUTTON_RELEASED);
- cursor->simulating_pointer_from_tool_tip = false;
+ } else if (!surface || !wlr_surface_accepts_tablet_v2(tablet_v2, surface)) {
+ // If we started holding the tool tip down on a surface that accepts
+ // tablet v2, we should notify that surface if it gets released over a
+ // surface that doesn't support v2.
+ if (event->state == WLR_TABLET_TOOL_TIP_UP) {
+ seatop_tablet_tool_tip(seat, sway_tool, event->time_msec,
+ WLR_TABLET_TOOL_TIP_UP);
+ } else {
+ cursor->simulating_pointer_from_tool_tip = true;
+ dispatch_cursor_button(cursor, event->device, event->time_msec,
+ BTN_LEFT, WLR_BUTTON_PRESSED);
+ wlr_seat_pointer_notify_frame(cursor->seat->wlr_seat);
+ transaction_commit_dirty();
}
-
- wlr_tablet_v2_tablet_tool_notify_up(sway_tool->tablet_v2_tool);
+ } else {
+ seatop_tablet_tool_tip(seat, sway_tool, event->time_msec, event->state);
}
-
- seatop_tablet_tool_tip(seat, sway_tool, event->time_msec, event->state);
}
static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor,