git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitee2b99ad0e66d5e8a29f162f58f12785bce3a77f
parent84b1bc7203
authorHugo Machet <[email protected]>
date2023-01-06 10:30
InputConfig: Implement disable while trackpointing

 completions/bash/riverctl      |  1 +
 completions/fish/riverctl.fish |  3 ++-
 completions/zsh/_riverctl      |  2 ++
 doc/riverctl.1.scd             |  3 +++
 river/InputConfig.zig          | 18 ++++++++++++++++++
 5 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/completions/bash/riverctl b/completions/bash/riverctl
index ccee6a0..fce2d56 100644
--- a/completions/bash/riverctl
+++ b/completions/bash/riverctl
@@ -88,6 +88,7 @@ function __riverctl_completion ()
 				drag \
 				drag-lock \
 				disable-while-typing \
+				disable-while-trackpointing \
 				middle-emulation \
 				natural-scroll \
 				left-handed \
diff --git a/completions/fish/riverctl.fish b/completions/fish/riverctl.fish
index 7accc4d..115946f 100644
--- a/completions/fish/riverctl.fish
+++ b/completions/fish/riverctl.fish
@@ -108,6 +108,7 @@ complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'drag'                 -d 'Enable or disable the tap-and-drag functionality'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'drag-lock'            -d 'Enable or disable the drag lock functionality'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'disable-while-typing' -d 'Enable or disable the disable-while-typing functionality'
+complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'disable-while-trackpointing' -d 'Enable or disable the disable-while-trackpointing functionality'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'middle-emulation'     -d 'Enable or disable the middle-emulation functionality'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'natural-scroll'       -d 'Enable or disable the natural-scroll functionality'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'left-handed'          -d 'Enable or disable the left handed mode'
@@ -117,7 +118,7 @@ complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 3' -a 'scroll-button'        -d 'Set the scroll button'
 
 # Subcommands for the subcommands of 'input'
-complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 4; and __fish_seen_subcommand_from drag drag-lock disable-while-typing middle-emulation natural-scroll left-handed tap' -a 'enabled disabled'
+complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 4; and __fish_seen_subcommand_from drag drag-lock disable-while-typing disable-while-trackpointing middle-emulation natural-scroll left-handed tap' -a 'enabled disabled'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 4; and __fish_seen_subcommand_from events'         -a 'enabled disabled disabled-on-external-mouse'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 4; and __fish_seen_subcommand_from accel-profile'  -a 'none flat adaptive'
 complete -c riverctl -n '__fish_seen_subcommand_from input; and __fish_riverctl_complete_arg 4; and __fish_seen_subcommand_from click-method'   -a 'none button-areas clickfinger'
diff --git a/completions/zsh/_riverctl b/completions/zsh/_riverctl
index 0c90bf9..3c7f7e1 100644
--- a/completions/zsh/_riverctl
+++ b/completions/zsh/_riverctl
@@ -115,6 +115,7 @@ _riverctl()
                                 'drag:Enable or disable the tap-and-drag functionality'
                                 'drag-lock:Enable or disable the drag lock functionality'
                                 'disable-while-typing:Enable or disable the disable-while-typing functionality'
+                                'disable-while-trackpointing:Enable or disable the disable-while-trackpointing functionality'
                                 'middle-emulation:Enable or disable the middle click emulation functionality'
                                 'natural-scroll:Enable or disable the natural scroll functionality'
                                 'left-handed:Enable or disable the left handed mode'
@@ -134,6 +135,7 @@ _riverctl()
                                 drag) _alternative 'input-cmds:args:(enabled disabled)' ;;
                                 drag-lock) _alternative 'input-cmds:args:(enabled disabled)' ;;
                                 disable-while-typing) _alternative 'input-cmds:args:(enabled disabled)' ;;
+                                disable-while-trackpointing) _alternative 'input-cmds:args:(enabled disabled)' ;;
                                 middle-emulation) _alternative 'input-cmds:args:(enabled disabled)' ;;
                                 natural-scroll) _alternative 'input-cmds:args:(enabled disabled)' ;;
                                 left-handed) _alternative 'input-cmds:args:(enabled disabled)' ;;
diff --git a/doc/riverctl.1.scd b/doc/riverctl.1.scd
index 9023c33..b3d0c72 100644
--- a/doc/riverctl.1.scd
+++ b/doc/riverctl.1.scd
@@ -491,6 +491,9 @@ However note that not every input device supports every property.
 *input* _name_ *disable-while-typing* *enabled*|*disabled*
 	Enable or disable the disable-while-typing functionality of the input device.
 
+*input* _name_ *disable-while-trackpointing* *enabled*|*disabled*
+	Enable or disable the disable-while-trackpointing functionality of the input device.
+
 *input* _name_ *middle-emulation* *enabled*|*disabled*
 	Enable or disable the middle click emulation functionality of the input device.
 
diff --git a/river/InputConfig.zig b/river/InputConfig.zig
index 7381817..258a25e 100644
--- a/river/InputConfig.zig
+++ b/river/InputConfig.zig
@@ -137,6 +137,23 @@ pub const DwtState = enum {
     }
 };
 
+pub const DwtpState = enum {
+    disabled,
+    enabled,
+
+    pub fn apply(dwtp_state: DwtpState, device: *c.libinput_device) void {
+        const want = @as(c_uint, switch (dwtp_state) {
+            .disabled => c.LIBINPUT_CONFIG_DWTP_DISABLED,
+            .enabled => c.LIBINPUT_CONFIG_DWTP_ENABLED,
+        });
+        if (c.libinput_device_config_dwtp_is_available(device) == 0) return;
+        const current = c.libinput_device_config_dwtp_get_enabled(device);
+        if (want != current) {
+            _ = c.libinput_device_config_dwtp_set_enabled(device, want);
+        }
+    }
+};
+
 pub const MiddleEmulation = enum {
     disabled,
     enabled,
@@ -271,6 +288,7 @@ events: ?EventState = null,
 drag: ?DragState = null,
 @"drag-lock": ?DragLock = null,
 @"disable-while-typing": ?DwtState = null,
+@"disable-while-trackpointing": ?DwtpState = null,
 @"middle-emulation": ?MiddleEmulation = null,
 @"natural-scroll": ?NaturalScroll = null,
 @"left-handed": ?LeftHanded = null,