Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to enable 3fg/4fg drag gesture #2594

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ if cpp.has_argument('-fno-gnu-unique')
endif
add_project_arguments(project_args, language: ['cpp', 'c'])

# Compile new libinput features only if they are supported with the libinput installed version
if cpp.has_function('libinput_device_config_3fg_drag_set_enabled', dependencies: libinput)
add_project_arguments('-DHAVE_LIBINPUT_3FG_DRAG=1', language : ['cpp', 'c'])
endif

# Needed on some older compilers
if cpp.has_link_argument('-lc++fs')
add_project_link_arguments(['-lc++fs'], language: 'cpp')
Expand Down
21 changes: 21 additions & 0 deletions metadata/input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@
<_long>Enables or disables drag lock.</_long>
<default>false</default>
</option>
<option name="3fg_drag" type="string">
<_short>Multi-finger drag</_short>
<_long>Enables or disables 3-finger or 4-finger drag. Requires libinput ≥ 1.28.</_long>
<default>default</default>
<desc>
<value>default</value>
<_name>Default</_name>
</desc>
<desc>
<value>none</value>
<_name>None</_name>
</desc>
<desc>
<value>3fg-drag</value>
<_name>Drag using 3 fingers</_name>
</desc>
<desc>
<value>4fg-drag</value>
<_name>Drag using 4 fingers</_name>
</desc>
</option>
<option name="touchpad_cursor_speed" type="double">
<_short>Touchpad cursor speed</_short>
<_long>Changes the touchpad acceleration.</_long>
Expand Down
23 changes: 23 additions & 0 deletions src/core/seat/pointing-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void wf::pointing_device_t::load_options()
touchpad_natural_scroll_enabled.load_option(section_name + "/natural_scroll");
touchpad_tap_and_drag_enabled.load_option(section_name + "/tap_and_drag");
touchpad_drag_lock_enabled.load_option(section_name + "/drag_lock");
touchpad_3fg_drag.load_option(section_name + "/3fg_drag");

mouse_accel_profile.load_option(section_name + "/mouse_accel_profile");
touchpad_accel_profile.load_option(section_name + "/touchpad_accel_profile");
Expand Down Expand Up @@ -147,6 +148,28 @@ void wf::pointing_device_t::update_options()
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED :
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);

#if HAVE_LIBINPUT_3FG_DRAG

if ((std::string)touchpad_3fg_drag == "default")
{
libinput_device_config_3fg_drag_set_enabled(dev,
libinput_device_config_3fg_drag_get_default_enabled(dev));
} else if ((std::string)touchpad_3fg_drag == "none")
{
libinput_device_config_3fg_drag_set_enabled(dev,
LIBINPUT_CONFIG_3FG_DRAG_DISABLED);
} else if ((std::string)touchpad_3fg_drag == "3fg-drag")
{
libinput_device_config_3fg_drag_set_enabled(dev,
LIBINPUT_CONFIG_3FG_DRAG_ENABLED_3FG);
} else if ((std::string)touchpad_3fg_drag == "4fg-drag")
{
libinput_device_config_3fg_drag_set_enabled(dev,
LIBINPUT_CONFIG_3FG_DRAG_ENABLED_4FG);
}

#endif

if (libinput_device_config_scroll_has_natural_scroll(dev) > 0)
{
libinput_device_config_scroll_set_natural_scroll_enabled(dev,
Expand Down
1 change: 1 addition & 0 deletions src/core/seat/pointing-device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct pointing_device_t : public input_device_impl_t
wf::option_wrapper_t<bool> mouse_natural_scroll_enabled;
wf::option_wrapper_t<bool> touchpad_tap_and_drag_enabled;
wf::option_wrapper_t<bool> touchpad_drag_lock_enabled;
wf::option_wrapper_t<std::string> touchpad_3fg_drag;
};
}

Expand Down