input: Extend swipe gesture support to finger count

Swipe pointer gesture bindings added in an earlier commit would catch
swipes indiscriminately, ignoring the number of fingers used.

Add the necessary logic to distinguish three- from four-finger swipes.
Other finger counts cannot be bound to and are passed through to clients.
Continue to trivially map each dimension of a gesture to discrete pseudo
button codes considering that we're unlikely to take this much further
and would otherwise need to extend struct sway_binding to carry some
kind of button-specific internal data.

Test plan:
- add workspace switching to config like so:

bindsym --whole-window SWIPE_3_LEFT workspace prev_on_output
bindsym --whole-window SWIPE_4_RIGHT workspace next_on_output

- start sway and open two workspaces
- switch back and forth using horizontal three- and four-finger swipes,
  observing that different finger counts are necessary per direction

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
This commit is contained in:
Michael Weiser 2020-01-25 20:59:18 +01:00
parent 44a2a60dcd
commit abb82c153e
3 changed files with 74 additions and 21 deletions

View file

@ -14,10 +14,15 @@
#define SWAY_SCROLL_DOWN KEY_MAX + 2
#define SWAY_SCROLL_LEFT KEY_MAX + 3
#define SWAY_SCROLL_RIGHT KEY_MAX + 4
#define SWAY_SWIPE_UP KEY_MAX + 5
#define SWAY_SWIPE_DOWN KEY_MAX + 6
#define SWAY_SWIPE_LEFT KEY_MAX + 7
#define SWAY_SWIPE_RIGHT KEY_MAX + 8
#define SWAY_SWIPE_DIR_UP 0
#define SWAY_SWIPE_DIR_DOWN 1
#define SWAY_SWIPE_DIR_LEFT 2
#define SWAY_SWIPE_DIR_RIGHT 3
#define SWAY_SWIPE_DIR_COUNT 4
#define SWAY_SWIPE_3 SWAY_SCROLL_RIGHT + 1
#define SWAY_SWIPE_4 SWAY_SWIPE_3 + SWAY_SWIPE_DIR_COUNT
struct sway_cursor {
struct sway_seat *seat;