1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_WM_SYSTEM_GESTURE_EVENT_FILTER_H_
6 #define ASH_WM_SYSTEM_GESTURE_EVENT_FILTER_H_
9 #include "ash/touch/touch_uma.h"
10 #include "base/timer/timer.h"
11 #include "ui/aura/window_observer.h"
12 #include "ui/events/event_handler.h"
13 #include "ui/gfx/point.h"
28 class SystemGestureEventFilterTest;
32 class LongPressAffordanceHandler;
33 class OverviewGestureHandler;
34 class SystemPinchHandler;
36 class TwoFingerDragHandler;
38 // An event filter which handles system level gesture events.
39 class SystemGestureEventFilter : public ui::EventHandler,
40 public aura::WindowObserver {
42 SystemGestureEventFilter();
43 virtual ~SystemGestureEventFilter();
45 // Overridden from ui::EventHandler:
46 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
47 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
48 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
49 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
51 // Overridden from aura::WindowObserver.
52 virtual void OnWindowVisibilityChanged(aura::Window* window,
53 bool visible) OVERRIDE;
54 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
57 friend class ash::test::SystemGestureEventFilterTest;
59 // Removes system-gesture handlers for a window.
60 void ClearGestureHandlerForWindow(aura::Window* window);
62 typedef std::map<aura::Window*, SystemPinchHandler*> WindowPinchHandlerMap;
63 // Created on demand when a system-level pinch gesture is initiated. Destroyed
64 // when the system-level pinch gesture ends for the window.
65 WindowPinchHandlerMap pinch_handlers_;
67 bool system_gestures_enabled_;
69 scoped_ptr<LongPressAffordanceHandler> long_press_affordance_;
70 scoped_ptr<OverviewGestureHandler> overview_gesture_handler_;
71 scoped_ptr<TwoFingerDragHandler> two_finger_drag_;
73 DISALLOW_COPY_AND_ASSIGN(SystemGestureEventFilter);
76 } // namespace internal
79 #endif // ASH_WM_SYSTEM_GESTURE_EVENT_FILTER_H_