aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar pudiva chip lĂ­quida <pudiva@skylittlesystem.org>2022-08-24 00:13:12 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2022-10-30 10:56:34 +0100
commit7cc8ab6d6c4e7ebbfee832b3d8d8fd86623d89fc (patch)
treefaacab010de2a3ffdd76dcf3bab015bb708f42dc
parentcontainer_floating_set_default_size: Store workspace size box on the stack (diff)
downloadsway-7cc8ab6d6c4e7ebbfee832b3d8d8fd86623d89fc.tar.gz
sway-7cc8ab6d6c4e7ebbfee832b3d8d8fd86623d89fc.tar.zst
sway-7cc8ab6d6c4e7ebbfee832b3d8d8fd86623d89fc.zip
Support libinput's 1.21 new dwtp option
Support the new dwtp (disable while trackpointing) option introduced in libinput 1.21, allowing users to control whether the trackpoint (like those in Thinkpads, but not only) should be disabled while using the keyboard/touchpad. See: https://gitlab.freedesktop.org/libinput/libinput/-/issues/731
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h1
-rw-r--r--meson.build2
-rw-r--r--sway/commands/input.c1
-rw-r--r--sway/commands/input/dwtp.c25
-rw-r--r--sway/config/input.c4
-rw-r--r--sway/input/libinput.c15
-rw-r--r--sway/ipc-json.c13
-rw-r--r--sway/meson.build1
-rw-r--r--sway/sway-input.5.scd4
-rw-r--r--sway/sway-ipc.7.scd10
11 files changed, 74 insertions, 3 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 07941bb4..7fad26a1 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -252,6 +252,7 @@ sway_cmd input_cmd_click_method;
252sway_cmd input_cmd_drag; 252sway_cmd input_cmd_drag;
253sway_cmd input_cmd_drag_lock; 253sway_cmd input_cmd_drag_lock;
254sway_cmd input_cmd_dwt; 254sway_cmd input_cmd_dwt;
255sway_cmd input_cmd_dwtp;
255sway_cmd input_cmd_events; 256sway_cmd input_cmd_events;
256sway_cmd input_cmd_left_handed; 257sway_cmd input_cmd_left_handed;
257sway_cmd input_cmd_map_from_region; 258sway_cmd input_cmd_map_from_region;
diff --git a/include/sway/config.h b/include/sway/config.h
index 68c06846..190ab13b 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -150,6 +150,7 @@ struct input_config {
150 int drag; 150 int drag;
151 int drag_lock; 151 int drag_lock;
152 int dwt; 152 int dwt;
153 int dwtp;
153 int left_handed; 154 int left_handed;
154 int middle_emulation; 155 int middle_emulation;
155 int natural_scroll; 156 int natural_scroll;
diff --git a/meson.build b/meson.build
index d23300be..fccf6429 100644
--- a/meson.build
+++ b/meson.build
@@ -60,7 +60,7 @@ gdk_pixbuf = dependency('gdk-pixbuf-2.0', required: get_option('gdk-pixbuf'))
60pixman = dependency('pixman-1') 60pixman = dependency('pixman-1')
61glesv2 = dependency('glesv2') 61glesv2 = dependency('glesv2')
62libevdev = dependency('libevdev') 62libevdev = dependency('libevdev')
63libinput = dependency('libinput', version: '>=1.6.0') 63libinput = dependency('libinput', version: '>=1.21.0')
64xcb = dependency('xcb', required: get_option('xwayland')) 64xcb = dependency('xcb', required: get_option('xwayland'))
65drm_full = dependency('libdrm') # only needed for drm_fourcc.h 65drm_full = dependency('libdrm') # only needed for drm_fourcc.h
66drm = drm_full.partial_dependency(compile_args: true, includes: true) 66drm = drm_full.partial_dependency(compile_args: true, includes: true)
diff --git a/sway/commands/input.c b/sway/commands/input.c
index 77acb671..ea531659 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -14,6 +14,7 @@ static const struct cmd_handler input_handlers[] = {
14 { "drag", input_cmd_drag }, 14 { "drag", input_cmd_drag },
15 { "drag_lock", input_cmd_drag_lock }, 15 { "drag_lock", input_cmd_drag_lock },
16 { "dwt", input_cmd_dwt }, 16 { "dwt", input_cmd_dwt },
17 { "dwtp", input_cmd_dwtp },
17 { "events", input_cmd_events }, 18 { "events", input_cmd_events },
18 { "left_handed", input_cmd_left_handed }, 19 { "left_handed", input_cmd_left_handed },
19 { "map_from_region", input_cmd_map_from_region }, 20 { "map_from_region", input_cmd_map_from_region },
diff --git a/sway/commands/input/dwtp.c b/sway/commands/input/dwtp.c
new file mode 100644
index 00000000..232e2b26
--- /dev/null
+++ b/sway/commands/input/dwtp.c
@@ -0,0 +1,25 @@
1#include <string.h>
2#include <strings.h>
3#include "sway/config.h"
4#include "sway/commands.h"
5#include "sway/input/input-manager.h"
6#include "util.h"
7
8struct cmd_results *input_cmd_dwtp(int argc, char **argv) {
9 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "dwtp", EXPECTED_AT_LEAST, 1))) {
11 return error;
12 }
13 struct input_config *ic = config->handler_context.input_config;
14 if (!ic) {
15 return cmd_results_new(CMD_FAILURE, "No input device defined.");
16 }
17
18 if (parse_boolean(argv[0], true)) {
19 ic->dwtp = LIBINPUT_CONFIG_DWTP_ENABLED;
20 } else {
21 ic->dwtp = LIBINPUT_CONFIG_DWTP_DISABLED;
22 }
23
24 return cmd_results_new(CMD_SUCCESS, NULL);
25}
diff --git a/sway/config/input.c b/sway/config/input.c
index a998e170..a98204df 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -25,6 +25,7 @@ struct input_config *new_input_config(const char* identifier) {
25 input->drag = INT_MIN; 25 input->drag = INT_MIN;
26 input->drag_lock = INT_MIN; 26 input->drag_lock = INT_MIN;
27 input->dwt = INT_MIN; 27 input->dwt = INT_MIN;
28 input->dwtp = INT_MIN;
28 input->send_events = INT_MIN; 29 input->send_events = INT_MIN;
29 input->click_method = INT_MIN; 30 input->click_method = INT_MIN;
30 input->middle_emulation = INT_MIN; 31 input->middle_emulation = INT_MIN;
@@ -61,6 +62,9 @@ void merge_input_config(struct input_config *dst, struct input_config *src) {
61 if (src->dwt != INT_MIN) { 62 if (src->dwt != INT_MIN) {
62 dst->dwt = src->dwt; 63 dst->dwt = src->dwt;
63 } 64 }
65 if (src->dwtp != INT_MIN) {
66 dst->dwtp = src->dwtp;
67 }
64 if (src->left_handed != INT_MIN) { 68 if (src->left_handed != INT_MIN) {
65 dst->left_handed = src->left_handed; 69 dst->left_handed = src->left_handed;
66 } 70 }
diff --git a/sway/input/libinput.c b/sway/input/libinput.c
index 1bac72c9..53019301 100644
--- a/sway/input/libinput.c
+++ b/sway/input/libinput.c
@@ -166,6 +166,16 @@ static bool set_dwt(struct libinput_device *device, bool dwt) {
166 return true; 166 return true;
167} 167}
168 168
169static bool set_dwtp(struct libinput_device *device, bool dwtp) {
170 if (!libinput_device_config_dwtp_is_available(device) ||
171 libinput_device_config_dwtp_get_enabled(device) == dwtp) {
172 return false;
173 }
174 sway_log(SWAY_DEBUG, "dwtp_set_enabled(%d)", dwtp);
175 log_status(libinput_device_config_dwtp_set_enabled(device, dwtp));
176 return true;
177}
178
169static bool set_calibration_matrix(struct libinput_device *dev, float mat[6]) { 179static bool set_calibration_matrix(struct libinput_device *dev, float mat[6]) {
170 if (!libinput_device_config_calibration_has_matrix(dev)) { 180 if (!libinput_device_config_calibration_has_matrix(dev)) {
171 return false; 181 return false;
@@ -255,6 +265,9 @@ bool sway_input_configure_libinput_device(struct sway_input_device *input_device
255 if (ic->dwt != INT_MIN) { 265 if (ic->dwt != INT_MIN) {
256 changed |= set_dwt(device, ic->dwt); 266 changed |= set_dwt(device, ic->dwt);
257 } 267 }
268 if (ic->dwtp != INT_MIN) {
269 changed |= set_dwtp(device, ic->dwtp);
270 }
258 if (ic->calibration_matrix.configured) { 271 if (ic->calibration_matrix.configured) {
259 changed |= set_calibration_matrix(device, ic->calibration_matrix.matrix); 272 changed |= set_calibration_matrix(device, ic->calibration_matrix.matrix);
260 } 273 }
@@ -302,6 +315,8 @@ void sway_input_reset_libinput_device(struct sway_input_device *input_device) {
302 libinput_device_config_scroll_get_default_button(device)); 315 libinput_device_config_scroll_get_default_button(device));
303 changed |= set_dwt(device, 316 changed |= set_dwt(device,
304 libinput_device_config_dwt_get_default_enabled(device)); 317 libinput_device_config_dwt_get_default_enabled(device));
318 changed |= set_dwtp(device,
319 libinput_device_config_dwtp_get_default_enabled(device));
305 320
306 float matrix[6]; 321 float matrix[6];
307 libinput_device_config_calibration_get_default_matrix(device, matrix); 322 libinput_device_config_calibration_get_default_matrix(device, matrix);
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 61613f53..d757f21f 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -1000,6 +1000,19 @@ static json_object *describe_libinput_device(struct libinput_device *device) {
1000 json_object_object_add(object, "dwt", json_object_new_string(dwt)); 1000 json_object_object_add(object, "dwt", json_object_new_string(dwt));
1001 } 1001 }
1002 1002
1003 if (libinput_device_config_dwtp_is_available(device)) {
1004 const char *dwtp = "unknown";
1005 switch (libinput_device_config_dwtp_get_enabled(device)) {
1006 case LIBINPUT_CONFIG_DWTP_ENABLED:
1007 dwtp = "enabled";
1008 break;
1009 case LIBINPUT_CONFIG_DWTP_DISABLED:
1010 dwtp = "disabled";
1011 break;
1012 }
1013 json_object_object_add(object, "dwtp", json_object_new_string(dwtp));
1014 }
1015
1003 if (libinput_device_config_calibration_has_matrix(device)) { 1016 if (libinput_device_config_calibration_has_matrix(device)) {
1004 float matrix[6]; 1017 float matrix[6];
1005 libinput_device_config_calibration_get_matrix(device, matrix); 1018 libinput_device_config_calibration_get_matrix(device, matrix);
diff --git a/sway/meson.build b/sway/meson.build
index c7b9d6e6..4d7dccfa 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -157,6 +157,7 @@ sway_sources = files(
157 'commands/input/drag.c', 157 'commands/input/drag.c',
158 'commands/input/drag_lock.c', 158 'commands/input/drag_lock.c',
159 'commands/input/dwt.c', 159 'commands/input/dwt.c',
160 'commands/input/dwtp.c',
160 'commands/input/events.c', 161 'commands/input/events.c',
161 'commands/input/left_handed.c', 162 'commands/input/left_handed.c',
162 'commands/input/map_from_region.c', 163 'commands/input/map_from_region.c',
diff --git a/sway/sway-input.5.scd b/sway/sway-input.5.scd
index 8b702b77..e073c45d 100644
--- a/sway/sway-input.5.scd
+++ b/sway/sway-input.5.scd
@@ -147,6 +147,10 @@ The following commands may only be used in the configuration file.
147*input* <identifier> dwt enabled|disabled 147*input* <identifier> dwt enabled|disabled
148 Enables or disables disable-while-typing for the specified input device. 148 Enables or disables disable-while-typing for the specified input device.
149 149
150*input* <identifier> dwtp enabled|disabled
151 Enables or disables disable-while-trackpointing for the specified input
152 device.
153
150*input* <identifier> events enabled|disabled|disabled_on_external_mouse|toggle [<toggle-modes>] 154*input* <identifier> events enabled|disabled|disabled_on_external_mouse|toggle [<toggle-modes>]
151 Enables or disables send_events for specified input device. Disabling 155 Enables or disables send_events for specified input device. Disabling
152 send_events disables the input device. 156 send_events disables the input device.
diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd
index c7a2c473..9121f679 100644
--- a/sway/sway-ipc.7.scd
+++ b/sway/sway-ipc.7.scd
@@ -1197,6 +1197,10 @@ following properties will be included for devices that support them:
1197|- dwt 1197|- dwt
1198: string 1198: string
1199: Whether disable-while-typing is enabled. It can be _enabled_ or _disabled_ 1199: Whether disable-while-typing is enabled. It can be _enabled_ or _disabled_
1200|- dwtp
1201: string
1202: Whether disable-while-trackpointing is enabled. It can be _enabled_ or
1203 _disabled_
1200|- calibration_matrix 1204|- calibration_matrix
1201: array 1205: array
1202: An array of 6 floats representing the calibration matrix for absolute 1206: An array of 6 floats representing the calibration matrix for absolute
@@ -1236,7 +1240,8 @@ following properties will be included for devices that support them:
1236 "click_method": "button_areas", 1240 "click_method": "button_areas",
1237 "middle_emulation": "disabled", 1241 "middle_emulation": "disabled",
1238 "scroll_method": "edge", 1242 "scroll_method": "edge",
1239 "dwt": "enabled" 1243 "dwt": "enabled",
1244 "dwtp": "enabled"
1240 } 1245 }
1241 }, 1246 },
1242 { 1247 {
@@ -1363,7 +1368,8 @@ one seat. Each object has the following properties:
1363 "click_method": "button_areas", 1368 "click_method": "button_areas",
1364 "middle_emulation": "disabled", 1369 "middle_emulation": "disabled",
1365 "scroll_method": "edge", 1370 "scroll_method": "edge",
1366 "dwt": "enabled" 1371 "dwt": "enabled",
1372 "dwtp": "enabled"
1367 } 1373 }
1368 }, 1374 },
1369 { 1375 {