aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/input-manager.c
diff options
context:
space:
mode:
authorLibravatar Benjamin Cheng <ben@bcheng.cf>2019-03-12 13:17:47 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-04-14 19:31:36 -0400
commit6737b90cb93d0231bbbc6045adf8a2443bc4e21c (patch)
tree1b9c4f75ec160e85a2ffe9018c3564f105bd6678 /sway/input/input-manager.c
parentSpawn swaynag as a wayland client (diff)
downloadsway-6737b90cb93d0231bbbc6045adf8a2443bc4e21c.tar.gz
sway-6737b90cb93d0231bbbc6045adf8a2443bc4e21c.tar.zst
sway-6737b90cb93d0231bbbc6045adf8a2443bc4e21c.zip
Add heuristics to differentiate touchpads
Use libinput_device_config_tap_get_finger_count to determine whether a pointer is a touchpad. swaymsg is also updated to reflect the new touchpad type.
Diffstat (limited to 'sway/input/input-manager.c')
-rw-r--r--sway/input/input-manager.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index adb36af9..0c5254bd 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -71,6 +71,40 @@ char *input_device_get_identifier(struct wlr_input_device *device) {
71 return identifier; 71 return identifier;
72} 72}
73 73
74static bool device_is_touchpad(struct sway_input_device *device) {
75 if (device->wlr_device->type != WLR_INPUT_DEVICE_POINTER ||
76 !wlr_input_device_is_libinput(device->wlr_device)) {
77 return false;
78 }
79
80 struct libinput_device *libinput_device =
81 wlr_libinput_get_device_handle(device->wlr_device);
82
83 return libinput_device_config_tap_get_finger_count(libinput_device) > 0;
84}
85
86const char *input_device_get_type(struct sway_input_device *device) {
87 switch (device->wlr_device->type) {
88 case WLR_INPUT_DEVICE_POINTER:
89 if (device_is_touchpad(device)) {
90 return "touchpad";
91 } else {
92 return "pointer";
93 }
94 case WLR_INPUT_DEVICE_KEYBOARD:
95 return "keyboard";
96 case WLR_INPUT_DEVICE_TOUCH:
97 return "touch";
98 case WLR_INPUT_DEVICE_TABLET_TOOL:
99 return "tablet_tool";
100 case WLR_INPUT_DEVICE_TABLET_PAD:
101 return "tablet_pad";
102 case WLR_INPUT_DEVICE_SWITCH:
103 return "switch";
104 }
105 return "unknown";
106}
107
74static struct sway_input_device *input_sway_device_from_wlr( 108static struct sway_input_device *input_sway_device_from_wlr(
75 struct wlr_input_device *device) { 109 struct wlr_input_device *device) {
76 struct sway_input_device *input_device = NULL; 110 struct sway_input_device *input_device = NULL;