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

types: add two more edge-swipe types #73

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
14 changes: 12 additions & 2 deletions include/wayfire/config/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,21 @@ enum touch_gesture_type_t
GESTURE_TYPE_NONE = 0,
/* Swipe gesture, i.e moving in one direction */
GESTURE_TYPE_SWIPE = 1,
/* Edge swipe, which is a swipe originating from the edge of the screen */
/* Edge swipe, which is a swipe originating from the edge of the screen
* and is the main section in the center of the edge
*/
GESTURE_TYPE_EDGE_SWIPE = 2,
/* Edge swipe S1, which is a swipe originating from the edge of the screen
* and is the first section of the edge before the main section
*/
GESTURE_TYPE_EDGE_S1_SWIPE = 3,
/* Edge swipe S2, which is a swipe originating from the edge of the screen
* and is the last section of the edge after the main section
*/
GESTURE_TYPE_EDGE_S2_SWIPE = 4,
/* Pinch gesture, multiple touch points coming closer or farther apart
* from the center */
GESTURE_TYPE_PINCH = 3,
GESTURE_TYPE_PINCH = 5,
};

enum touch_gesture_direction_t
Expand Down
23 changes: 21 additions & 2 deletions src/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,14 @@ wf::touchgesture_t parse_gesture(const std::string& value)
{
type = wf::GESTURE_TYPE_EDGE_SWIPE;
direction = parse_direction(tokens[1]);
} else if (tokens[0] == "edge-s1-swipe")
{
type = wf::GESTURE_TYPE_EDGE_S1_SWIPE;
direction = parse_direction(tokens[1]);
} else if (tokens[0] == "edge-s2-swipe")
{
type = wf::GESTURE_TYPE_EDGE_S2_SWIPE;
direction = parse_direction(tokens[1]);
} else
{
throw std::domain_error("Invalid gesture type:" + tokens[0]);
Expand Down Expand Up @@ -697,9 +705,20 @@ std::string wf::option_type::to_string(const touchgesture_t& value)
return "";

case GESTURE_TYPE_EDGE_SWIPE:
result += "edge-";
result += "edge-swipe ";
result += direction_to_string(value.get_direction()) + " ";
break;

case GESTURE_TYPE_EDGE_S1_SWIPE:
result += "edge-s1-swipe ";
result += direction_to_string(value.get_direction()) + " ";
break;

case GESTURE_TYPE_EDGE_S2_SWIPE:
result += "edge-s2-swipe ";
result += direction_to_string(value.get_direction()) + " ";
break;

// fallthrough
case GESTURE_TYPE_SWIPE:
result += "swipe ";
result += direction_to_string(value.get_direction()) + " ";
Expand Down
18 changes: 18 additions & 0 deletions test/types_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ TEST_CASE("wf::touchgesture_t")
CHECK(binding5.get_direction() == wf::GESTURE_DIRECTION_OUT);
CHECK(binding5.get_finger_count() == 2);

auto binding6 =
from_string<touchgesture_t>("edge-s1-swipe down 2").value();
CHECK(binding6.get_type() == wf::GESTURE_TYPE_EDGE_S1_SWIPE);
CHECK(binding6.get_direction() == wf::GESTURE_DIRECTION_DOWN);
CHECK(binding6.get_finger_count() == 2);

auto binding7 =
from_string<touchgesture_t>("edge-s2-swipe down 2").value();
CHECK(binding7.get_type() == wf::GESTURE_TYPE_EDGE_S2_SWIPE);
CHECK(binding7.get_direction() == wf::GESTURE_DIRECTION_DOWN);
CHECK(binding7.get_finger_count() == 2);

auto empty = wf::touchgesture_t{wf::GESTURE_TYPE_NONE, 0, 0};
CHECK(from_string<touchgesture_t>("none").value() == empty);
CHECK(from_string<touchgesture_t>("disabled").value() == empty);
Expand All @@ -263,13 +275,19 @@ TEST_CASE("wf::touchgesture_t")
CHECK(binding5 == wf::touchgesture_t{wf::GESTURE_TYPE_PINCH, 0, 2});
CHECK(!(binding5 == wf::touchgesture_t{
wf::GESTURE_TYPE_PINCH, wf::GESTURE_DIRECTION_IN, 2}));
CHECK(binding6 == wf::touchgesture_t{
wf::GESTURE_TYPE_EDGE_S1_SWIPE, wf::GESTURE_DIRECTION_DOWN, 2});
CHECK(binding7 == wf::touchgesture_t{
wf::GESTURE_TYPE_EDGE_S2_SWIPE, wf::GESTURE_DIRECTION_DOWN, 2});

using wt_t = wf::touchgesture_t;
CHECK(from_string<wt_t>(to_string<wt_t>(binding1)).value() == binding1);
CHECK(from_string<wt_t>(to_string<wt_t>(binding2)).value() == binding2);
CHECK(from_string<wt_t>(to_string<wt_t>(binding3)).value() == binding3);
CHECK(from_string<wt_t>(to_string<wt_t>(binding4)).value() == binding4);
CHECK(from_string<wt_t>(to_string<wt_t>(binding5)).value() == binding5);
CHECK(from_string<wt_t>(to_string<wt_t>(binding6)).value() == binding6);
CHECK(from_string<wt_t>(to_string<wt_t>(binding7)).value() == binding7);
}

TEST_CASE("wf::hotspot_binding_t")
Expand Down
Loading