~azzar1/unity/fix-1036231

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/CompoundGestureRecognizer.h

  • Committer: Tarmac
  • Author(s): Daniel d'Andrada
  • Date: 2012-08-20 14:59:10 UTC
  • mfrom: (2534.1.12 alt_tab_v2)
  • Revision ID: tarmac-20120820145910-y17ko481ufxhmmga
Multi-touch gestures for switching between windows (a.k.a. "alt-tab with gestures").

Approved by Tim Penhey.

The following gestural interactions with the window switcher have been implemented:

1. 3-fingers double tap -> switches to previous window

2. 3-fingers tap followed by 3-fingers hold -> shows window switcher
- drag those 3-fingers -> change selected window icon
- release fingers -> selects window and closes switcher

3. 3-fingers tap followed by 3-fingers hold -> shows window switcher
- release fingers -> switcher will kept being shown for some seconds still
- drag with one or three fingers -> change selected window
- release finger(s) -> selects window and closes switcher

4. 3-fingers tap followed by 3-fingers hold -> shows window switcher
- release fingers -> switcher will kept being shown for some seconds still
- tap on some window icon -> selects that icon and closes the switcher

Unit tests included.. Fixes: . Approved by Tim Penhey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * CompoundGestureRecognizer.h
 
3
 * This file is part of Unity
 
4
 *
 
5
 * Copyright (C) 2012 - Canonical Ltd.
 
6
 *
 
7
 * Unity is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * Unity is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
 
21
 */
 
22
 
 
23
#ifndef COMPOUND_GESTURE_RECOGNIZER_H
 
24
#define COMPOUND_GESTURE_RECOGNIZER_H
 
25
 
 
26
#include <sigc++/sigc++.h>
 
27
 
 
28
namespace nux
 
29
{
 
30
  class GestureEvent;
 
31
}
 
32
 
 
33
namespace unity
 
34
{
 
35
 
 
36
enum class RecognitionResult
 
37
{
 
38
  NONE,
 
39
  DOUBLE_TAP_RECOGNIZED, /*! Returned when a double-tap is recognized */
 
40
  TAP_AND_HOLD_RECOGNIZED, /*!< Returned when a "tap and hold" is recognized
 
41
                             At this point the user is still "holding". I.e.,
 
42
                             his fingers are still on the touchscreen or
 
43
                             trackpad. */
 
44
};
 
45
 
 
46
class CompoundGestureRecognizerPrivate;
 
47
 
 
48
/*!
 
49
  Recognizes compound gestures. I.e. high level gestures that are maded up by
 
50
  two sequencial regular gestures (like a tap followed by a second tap).
 
51
 */
 
52
class CompoundGestureRecognizer
 
53
{
 
54
  public:
 
55
    // in milliseconds
 
56
    static const int MAX_TIME_BETWEEN_GESTURES = 600;
 
57
    static const int MAX_TAP_TIME = 300;
 
58
    static const int HOLD_TIME = 600;
 
59
 
 
60
    CompoundGestureRecognizer();
 
61
    virtual ~CompoundGestureRecognizer();
 
62
 
 
63
    virtual RecognitionResult GestureEvent(nux::GestureEvent const& event);
 
64
 
 
65
  private:
 
66
    CompoundGestureRecognizerPrivate* p;
 
67
};
 
68
 
 
69
} // namespace unity
 
70
 
 
71
#endif // COMPOUND_GESTURE_RECOGNIZER_H