aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-06-19 14:11:57 -0400
committerSimon Ser <contact@emersion.fr>2020-10-12 15:01:37 +0200
commited247c031cb9783deb5c04631b53c5ac6c432eb7 (patch)
tree3b8aa74d49d6e6cb1518cd749854cba13728f259 /sway/input
parent136add4e1208fe631dd8f8590a69ef9b959cfe34 (diff)
downloadsway-ed247c031cb9783deb5c04631b53c5ac6c432eb7.tar.xz
input/tablet: add tool_mode option to set tablet tools as relative input
Closes #4139.
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c12
-rw-r--r--sway/input/tablet.c23
2 files changed, 29 insertions, 6 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 61d75b8a..e47410a5 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -567,14 +567,14 @@ static void handle_tablet_tool_position(struct sway_cursor *cursor,
ic->mapped_from_region, &x, &y);
}
- switch (tool->tablet_v2_tool->wlr_tool->type) {
- case WLR_TABLET_TOOL_TYPE_LENS:
- case WLR_TABLET_TOOL_TYPE_MOUSE:
- wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy);
- break;
- default:
+ switch (tool->mode) {
+ case SWAY_TABLET_TOOL_MODE_ABSOLUTE:
wlr_cursor_warp_absolute(cursor->cursor, input_device->wlr_device,
change_x ? x : NAN, change_y ? y : NAN);
+ break;
+ case SWAY_TABLET_TOOL_MODE_RELATIVE:
+ wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy);
+ break;
}
double sx, sy;
diff --git a/sway/input/tablet.c b/sway/input/tablet.c
index b74347aa..5f81f772 100644
--- a/sway/input/tablet.c
+++ b/sway/input/tablet.c
@@ -140,6 +140,29 @@ void sway_tablet_tool_configure(struct sway_tablet *tablet,
return;
}
+ switch (wlr_tool->type) {
+ case WLR_TABLET_TOOL_TYPE_LENS:
+ case WLR_TABLET_TOOL_TYPE_MOUSE:
+ tool->mode = SWAY_TABLET_TOOL_MODE_RELATIVE;
+ break;
+ default:
+ tool->mode = SWAY_TABLET_TOOL_MODE_ABSOLUTE;
+
+ struct input_config *ic = input_device_get_config(
+ tablet->seat_device->input_device);
+ if (!ic) {
+ break;
+ }
+
+ for (int i = 0; i < ic->tools->length; i++) {
+ struct input_config_tool *tool_config = ic->tools->items[i];
+ if (tool_config->type == wlr_tool->type) {
+ tool->mode = tool_config->mode;
+ break;
+ }
+ }
+ }
+
tool->seat = tablet->seat_device->sway_seat;
tool->tablet = tablet;
tool->tablet_v2_tool =