aboutsummaryrefslogtreecommitdiff
path: root/sway/input/seatop_down.c
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-05-04 17:34:28 -0400
committerSimon Ser <contact@emersion.fr>2020-05-25 10:01:00 +0200
commit5d13f647f9384e59012c0f829651911564bb5365 (patch)
treeb768fac3dac8328d1efc7c9b4e96aa461ab7c9a5 /sway/input/seatop_down.c
parentc632d47bf811d246ea2f4874e6dda6b85a3b95ff (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 &mdash; 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/seatop_down.c')
-rw-r--r--sway/input/seatop_down.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c
index 358d5c59..dd8be6bf 100644
--- a/sway/input/seatop_down.c
+++ b/sway/input/seatop_down.c
@@ -1,6 +1,7 @@
#define _POSIX_C_SOURCE 200809L
#include <float.h>
#include <wlr/types/wlr_cursor.h>
+#include <wlr/types/wlr_tablet_v2.h>
#include "sway/input/cursor.h"
#include "sway/input/seat.h"
#include "sway/tree/view.h"
@@ -49,6 +50,27 @@ static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec,
}
}
+static void handle_tablet_tool_tip(struct sway_seat *seat,
+ struct sway_tablet_tool *tool, uint32_t time_msec,
+ enum wlr_tablet_tool_tip_state state) {
+ if (state == WLR_TABLET_TOOL_TIP_UP) {
+ seatop_begin_default(seat);
+ }
+}
+
+static void handle_tablet_tool_motion(struct sway_seat *seat,
+ struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy) {
+ struct seatop_down_event *e = seat->seatop_data;
+ struct sway_container *con = e->con;
+ if (seat_is_input_allowed(seat, con->view->surface)) {
+ double moved_x = seat->cursor->cursor->x - e->ref_lx;
+ double moved_y = seat->cursor->cursor->y - e->ref_ly;
+ double sx = e->ref_con_lx + moved_x;
+ double sy = e->ref_con_ly + moved_y;
+ wlr_tablet_v2_tablet_tool_notify_motion(tool->tablet_v2_tool, sx, sy);
+ }
+}
+
static void handle_unref(struct sway_seat *seat, struct sway_container *con) {
struct seatop_down_event *e = seat->seatop_data;
if (e->con == con) {
@@ -60,6 +82,8 @@ static const struct sway_seatop_impl seatop_impl = {
.button = handle_button,
.pointer_motion = handle_pointer_motion,
.pointer_axis = handle_pointer_axis,
+ .tablet_tool_tip = handle_tablet_tool_tip,
+ .tablet_tool_motion = handle_tablet_tool_motion,
.unref = handle_unref,
.allow_set_cursor = true,
};