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

Edge swipe extra #2522

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
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_section_length" type="double">
<_short>Touchscreen edge swipe section length</_short>
<_long>Split the edge swipe in to 3 sections. If 0.0, the full length of the edge will be recognized as edge-swipe. With 0.1, 10% -> edge-s1-swipe, 80% -> edge-swipe, 10% edge-s2-swipe</_long>
<default>0.0</default>
<min>0.0</min>
<max>0.4</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
36 changes: 33 additions & 3 deletions src/core/seat/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,44 @@ void wf::touch_interface_t::add_default_gestures()

auto ack_edge_swipe = [esw_ptr, this] ()
{
uint32_t possible_edges = find_swipe_edges(finger_state.get_center().origin);
wf::option_wrapper_t<double> edge_swipe_section_length{"input/edge_swipe_section_length"};
double main_edge_section = 1.0 - edge_swipe_section_length;
wf::touch::point_t point = finger_state.get_center().origin;
uint32_t possible_edges = find_swipe_edges(point);
uint32_t direction = wf_touch_to_wf_dir(esw_ptr->target_direction);

auto output = wf::get_core().seat->get_active_output();
auto geometry = output->get_layout_geometry();
touch_gesture_type_t edgeType = GESTURE_TYPE_NONE;

possible_edges &= direction;

if (possible_edges)
{
if (main_edge_section == 1.0)
{
edgeType = GESTURE_TYPE_EDGE_SWIPE;
} else if ((direction == GESTURE_DIRECTION_LEFT || direction == GESTURE_DIRECTION_RIGHT))
{
if (point.y <= (geometry.height * edge_swipe_section_length))
edgeType = GESTURE_TYPE_EDGE_S1_SWIPE;
else if (edgeType == GESTURE_TYPE_NONE && (point.y > (geometry.height * edge_swipe_section_length))
&& (point.y < (geometry.height * main_edge_section)))
edgeType = GESTURE_TYPE_EDGE_SWIPE;
else if (edgeType == GESTURE_TYPE_NONE && point.y >= (geometry.height * main_edge_section))
edgeType = GESTURE_TYPE_EDGE_S2_SWIPE;
} else if ((direction == GESTURE_DIRECTION_UP || direction == GESTURE_DIRECTION_DOWN))
{
if (point.x <= (geometry.width * edge_swipe_section_length))
edgeType = GESTURE_TYPE_EDGE_S1_SWIPE;
else if (edgeType == GESTURE_TYPE_NONE && (point.x > (geometry.width * edge_swipe_section_length))
&& (point.x < (geometry.width * main_edge_section)))
edgeType = GESTURE_TYPE_EDGE_SWIPE;
else if (edgeType == GESTURE_TYPE_NONE && point.x >= (geometry.width * main_edge_section))
edgeType = GESTURE_TYPE_EDGE_S2_SWIPE;
}

wf::touchgesture_t gesture{
GESTURE_TYPE_EDGE_SWIPE,
edgeType,
direction,
esw_ptr->cnt_fingers
};
Expand Down