aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input
diff options
context:
space:
mode:
authorLibravatar Tudor Brindus <me@tbrindus.ca>2020-06-19 14:11:57 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2020-10-12 15:01:37 +0200
commited247c031cb9783deb5c04631b53c5ac6c432eb7 (patch)
tree3b8aa74d49d6e6cb1518cd749854cba13728f259 /sway/input
parentinput/cursor: default tablet lens tool to relative motion (diff)
downloadsway-ed247c031cb9783deb5c04631b53c5ac6c432eb7.tar.gz
sway-ed247c031cb9783deb5c04631b53c5ac6c432eb7.tar.zst
sway-ed247c031cb9783deb5c04631b53c5ac6c432eb7.zip
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,
567 ic->mapped_from_region, &x, &y); 567 ic->mapped_from_region, &x, &y);
568 } 568 }
569 569
570 switch (tool->tablet_v2_tool->wlr_tool->type) { 570 switch (tool->mode) {
571 case WLR_TABLET_TOOL_TYPE_LENS: 571 case SWAY_TABLET_TOOL_MODE_ABSOLUTE:
572 case WLR_TABLET_TOOL_TYPE_MOUSE:
573 wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy);
574 break;
575 default:
576 wlr_cursor_warp_absolute(cursor->cursor, input_device->wlr_device, 572 wlr_cursor_warp_absolute(cursor->cursor, input_device->wlr_device,
577 change_x ? x : NAN, change_y ? y : NAN); 573 change_x ? x : NAN, change_y ? y : NAN);
574 break;
575 case SWAY_TABLET_TOOL_MODE_RELATIVE:
576 wlr_cursor_move(cursor->cursor, input_device->wlr_device, dx, dy);
577 break;
578 } 578 }
579 579
580 double sx, sy; 580 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,
140 return; 140 return;
141 } 141 }
142 142
143 switch (wlr_tool->type) {
144 case WLR_TABLET_TOOL_TYPE_LENS:
145 case WLR_TABLET_TOOL_TYPE_MOUSE:
146 tool->mode = SWAY_TABLET_TOOL_MODE_RELATIVE;
147 break;
148 default:
149 tool->mode = SWAY_TABLET_TOOL_MODE_ABSOLUTE;
150
151 struct input_config *ic = input_device_get_config(
152 tablet->seat_device->input_device);
153 if (!ic) {
154 break;
155 }
156
157 for (int i = 0; i < ic->tools->length; i++) {
158 struct input_config_tool *tool_config = ic->tools->items[i];
159 if (tool_config->type == wlr_tool->type) {
160 tool->mode = tool_config->mode;
161 break;
162 }
163 }
164 }
165
143 tool->seat = tablet->seat_device->sway_seat; 166 tool->seat = tablet->seat_device->sway_seat;
144 tool->tablet = tablet; 167 tool->tablet = tablet;
145 tool->tablet_v2_tool = 168 tool->tablet_v2_tool =