diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-05-04 17:34:28 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-25 10:01:00 +0200 |
commit | 5d13f647f9384e59012c0f829651911564bb5365 (patch) | |
tree | b768fac3dac8328d1efc7c9b4e96aa461ab7c9a5 /sway/input/cursor.c | |
parent | c632d47bf811d246ea2f4874e6dda6b85a3b95ff (diff) |
input/tablet: add seatop_down entry for tablet input
Currently, when tablet input exits a window during an implicit grab, it
passes focus to another window.
For instance, this is problematic when trying to drag a scrollbar, and
exiting the window — the scrollbar motion stops. Additionally,
without `focus_follows_mouse no`, the tablet passes focus to whatever
surface it goes over regardless of if there is an active implicit.
If the tablet is over a surface that does not bind tablet handlers, sway
will fall back to pointer emulation, and all of this works fine. It
probably should have consistent behavior between emulated and
not-emulated input, though.
This commit adds a condition for entering seatop_down when a tablet's
tool tip goes down, and exiting when it goes up. Since events won't be
routed through seatop_default, this prevents windows losing focus during
implicit grabs.
Closes #5302.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 8121cc84..8de7d950 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -572,7 +572,19 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor, struct sway_seat *seat = cursor->seat; node_at_coords(seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); - if (surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) { + // The logic for whether we should send a tablet event or an emulated pointer + // event is tricky. It comes down to: + // * If we began a drag on a non-tablet surface (simulated_tool_tip_down), + // then we should continue sending emulated pointer events regardless of + // whether the surface currently under us accepts tablet or not. + // * Otherwise, if we are over a surface that accepts tablet, then we should + // send tablet events. + // * If we began a drag over a tablet surface, we should continue sending + // tablet events until the drag is released, even if we are now over a + // non-tablet surface. + if (!cursor->simulated_tool_tip_down && + ((surface && wlr_surface_accepts_tablet_v2(tablet->tablet_v2, surface)) || + wlr_tablet_tool_v2_has_implicit_grab(tool->tablet_v2_tool))) { seatop_tablet_tool_motion(seat, tool, time_msec, dx, dy); } else { wlr_tablet_v2_tablet_tool_notify_proximity_out(tool->tablet_v2_tool); @@ -680,6 +692,8 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) { wlr_tablet_v2_tablet_tool_notify_up(sway_tool->tablet_v2_tool); } + + seatop_tablet_tool_tip(seat, sway_tool, event->time_msec, event->state); } static struct sway_tablet *get_tablet_for_device(struct sway_cursor *cursor, |