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.
This commit is contained in:
Tudor Brindus 2020-05-04 17:34:28 -04:00 committed by Simon Ser
parent c632d47bf8
commit 5d13f647f9
5 changed files with 73 additions and 1 deletions

View file

@ -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,