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

touch: make EDGE_SWIPE_THRESHOLD configurable #2517

Open
wants to merge 1 commit 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
7 changes: 7 additions & 0 deletions metadata/input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@
<min>0.1</min>
<max>5.0</max>
</option>
<option name="edge_swipe_threshold" type="int">
<_short>Touchscreen edge swipe threshold</_short>
<_long>Change the threshold of the built-in edge swipe detection. Higher values mean that a bigger area on the edge is used to trigger the edge swipe.</_long>
<default>10</default>
<min>5</min>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this 1 or so .. let the users have more freedom :)

<max>50</max>
</option>
<option name="touchpad_scroll_speed" type="double">
<_short>Touchpad scroll speed</_short>
<_long>Changes the touchpad scroll factor. Scroll speed will be scaled by the given value, which must be non-negative.</_long>
Expand Down
10 changes: 5 additions & 5 deletions src/core/seat/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ void wf::touch_interface_t::update_cursor_state()
}

// Swipe params
constexpr static int EDGE_SWIPE_THRESHOLD = 10;
constexpr static double MIN_SWIPE_DISTANCE = 30;
constexpr static double MAX_SWIPE_DISTANCE = 450;
constexpr static double SWIPE_INCORRECT_DRAG_TOLERANCE = 150;
Expand Down Expand Up @@ -427,24 +426,25 @@ static uint32_t find_swipe_edges(wf::touch::point_t point)
{
auto output = wf::get_core().seat->get_active_output();
auto geometry = output->get_layout_geometry();
wf::option_wrapper_t<int> edge_swipe_threshold{"input/edge_swipe_threshold"};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a lookup for the option every time the function is called. I would make it a static wf::option_wrapper_t<...> so that it loads only the first time the function is called :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will fix up after new year.


uint32_t edge_directions = 0;
if (point.x <= geometry.x + EDGE_SWIPE_THRESHOLD)
if (point.x <= geometry.x + edge_swipe_threshold)
{
edge_directions |= wf::GESTURE_DIRECTION_RIGHT;
}

if (point.x >= geometry.x + geometry.width - EDGE_SWIPE_THRESHOLD)
if (point.x >= geometry.x + geometry.width - edge_swipe_threshold)
{
edge_directions |= wf::GESTURE_DIRECTION_LEFT;
}

if (point.y <= geometry.y + EDGE_SWIPE_THRESHOLD)
if (point.y <= geometry.y + edge_swipe_threshold)
{
edge_directions |= wf::GESTURE_DIRECTION_DOWN;
}

if (point.y >= geometry.y + geometry.height - EDGE_SWIPE_THRESHOLD)
if (point.y >= geometry.y + geometry.height - edge_swipe_threshold)
{
edge_directions |= wf::GESTURE_DIRECTION_UP;
}
Expand Down
Loading