Add support for global touchpad swipe gestures
ClosedPublic

Authored by graesslin on Mar 18 2017, 1:40 PM.

Details

Summary

This change adds global touchpad swipe gestures to the
GlobalShortcutsManager and hooks up the swipe gestures as defined at the
Plasma Affenfels sprint:

  • swipe up: Desktop Grid
  • swipe down: Present Windows
  • swipe left: previous virtual desktop
  • swipe right: next virtual desktop

The main work is handled by two new classes: SwipeGesture and
GestureRecognizer. This is implemented in a way that it can be extended
to also recognize touch screen gestures and pinch gestures.

The SwipeGesture defines what is required for the gesture to trigger.
Currently this includes the minimum and maximum number of fingers
participating in the gesture and the direction. The gesture gets
registered in the GestureRecognizer.

The events for the gesture are fed into the GestureRecognizer. It
evaluates which gestures could trigger and tracks them for every update
of the gesture. In the process of the gesture tracking the
GestureRecognizer emits signals on the Gesture:

  • started: when the Gesture gets considered for a sequence
  • cancelled: the Gesture no longer matches the sequence
  • triggered: the sequence ended and the Gesture still matches

The remaining changes are related to hook up the existing shortcut
framework with the new touchpad gestures. The GlobalShortcutManager
gained support for it, InputRedirection and EffectsHandler offer methods
to register a QAction. VirtualDesktopManager, PresentWindows and
DesktopGrid are adjusted to support the gesture.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin created this revision.Mar 18 2017, 1:40 PM
Restricted Application added a project: Plasma on Wayland. · View Herald TranscriptMar 18 2017, 1:40 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson accepted this revision.Mar 27 2017, 7:36 AM
davidedmundson added a subscriber: davidedmundson.

All good I think, a few questions.

gestures.cpp
96

I think you need to handle delta being zero in both directions and return without cancelling

137

Hypothetical question: Is it possible to have a start and end without an update?

gestures.h
127

I don't get what this is for.

You append to the list and you clear it, but it's used for any branch decisions.

Unless it's a future thing for more advanced swipe analysis later?

globalshortcuts.cpp
36

what's this for?

You don't make a QHash of SwipeDirections anywhere, and even if you did, it should be implicity done for enums.

This revision is now accepted and ready to land.Mar 27 2017, 7:36 AM
graesslin added inline comments.Mar 27 2017, 3:04 PM
gestures.cpp
96

I think a delta of 0/0 just cannot happen. libinput should not send us an update in such a case. We only get updates if the fingers moved. Thus 0/0 is just impossible.

137

Theoretically yes, practically I doubt that any user would be able to rest four fingers on the touchpad, trigger the swipe gesture (which already needs movements) and then raise without further movement. Similar for touch screen events: it would mean the user clicks a point without moving the finger even a little bit.

gestures.h
127

It's a future thing and used in the follow up patch for touch screen swipes where we need to get the minimum swipe distance.

globalshortcuts.cpp
36

I do: QHash<Qt::KeyboardModifiers, QHash<SwipeDirection, GlobalShortcut*> > m_swipeShortcuts;

and no, it's not implicit. I only added because I got a compile error.

This revision was automatically updated to reflect the committed changes.