InputConfig: Implement disable while trackpointing

This commit is contained in:
Hugo Machet 2023-01-06 10:30:04 +01:00 committed by Isaac Freund
parent bf7b9d15dd
commit 1d40e5a9ab
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
5 changed files with 26 additions and 1 deletions

View File

@ -88,6 +88,7 @@ function __riverctl_completion ()
drag \
drag-lock \
disable-while-typing \
disable-while-trackpointing \
middle-emulation \
natural-scroll \
left-handed \

View File

@ -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'

View File

@ -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)' ;;

View File

@ -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.

View File

@ -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,