OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_WM_OVERLAY_EVENT_FILTER_H_ | 5 #ifndef ASH_WM_OVERLAY_EVENT_FILTER_H_ |
6 #define ASH_WM_OVERLAY_EVENT_FILTER_H_ | 6 #define ASH_WM_OVERLAY_EVENT_FILTER_H_ |
7 | 7 |
8 #include "ash/shell_observer.h" | 8 #include "ash/shell_observer.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/aura/event.h" | |
11 #include "ui/aura/event_filter.h" | 10 #include "ui/aura/event_filter.h" |
12 | 11 |
13 namespace ash { | 12 namespace ash { |
14 namespace internal { | 13 namespace internal { |
15 | 14 |
16 // EventFilter for the "overlay window", which intercepts events before they are | 15 // EventFilter for the "overlay window", which intercepts events before they are |
17 // processed by the usual path (e.g. the partial screenshot UI, the keyboard | 16 // processed by the usual path (e.g. the partial screenshot UI, the keyboard |
18 // overlay). It does nothing the first time, but works when |Activate()| is | 17 // overlay). It does nothing the first time, but works when |Activate()| is |
19 // called. The main task of this event filter is just to stop propagation | 18 // called. The main task of this event filter is just to stop propagation |
20 // of any key events during activation, and also signal cancellation when keys | 19 // of any key events during activation, and also signal cancellation when keys |
21 // for canceling are pressed. | 20 // for canceling are pressed. |
22 class OverlayEventFilter : public aura::EventFilter, | 21 class OverlayEventFilter : public aura::EventFilter, |
23 public ShellObserver { | 22 public ShellObserver { |
24 public: | 23 public: |
25 // Windows that need to receive events from OverlayEventFilter implement this. | 24 // Windows that need to receive events from OverlayEventFilter implement this. |
26 class Delegate { | 25 class Delegate { |
27 public: | 26 public: |
28 // Invoked when OverlayEventFilter needs to stop handling events. | 27 // Invoked when OverlayEventFilter needs to stop handling events. |
29 virtual void Cancel() = 0; | 28 virtual void Cancel() = 0; |
30 | 29 |
31 // Returns true if the overlay should be canceled in response to |event|. | 30 // Returns true if the overlay should be canceled in response to |event|. |
32 virtual bool IsCancelingKeyEvent(aura::KeyEvent* event) = 0; | 31 virtual bool IsCancelingKeyEvent(ui::KeyEvent* event) = 0; |
33 | 32 |
34 // Returns the window that needs to receive events. | 33 // Returns the window that needs to receive events. |
35 virtual aura::Window* GetWindow() = 0; | 34 virtual aura::Window* GetWindow() = 0; |
36 }; | 35 }; |
37 | 36 |
38 OverlayEventFilter(); | 37 OverlayEventFilter(); |
39 virtual ~OverlayEventFilter(); | 38 virtual ~OverlayEventFilter(); |
40 | 39 |
41 // Starts the filtering of events. It also notifies the specified | 40 // Starts the filtering of events. It also notifies the specified |
42 // |delegate| when a key event means cancel (like Esc). It holds the | 41 // |delegate| when a key event means cancel (like Esc). It holds the |
43 // pointer to the specified |delegate| until Deactivate() is called, but | 42 // pointer to the specified |delegate| until Deactivate() is called, but |
44 // does not take ownership. | 43 // does not take ownership. |
45 void Activate(Delegate* delegate); | 44 void Activate(Delegate* delegate); |
46 | 45 |
47 // Ends the filtering of events. | 46 // Ends the filtering of events. |
48 void Deactivate(); | 47 void Deactivate(); |
49 | 48 |
50 // Cancels the partial screenshot UI. Do nothing if it's not activated. | 49 // Cancels the partial screenshot UI. Do nothing if it's not activated. |
51 void Cancel(); | 50 void Cancel(); |
52 | 51 |
53 // aura::EventFilter overrides: | 52 // aura::EventFilter overrides: |
54 virtual bool PreHandleKeyEvent( | 53 virtual bool PreHandleKeyEvent( |
55 aura::Window* target, aura::KeyEvent* event) OVERRIDE; | 54 aura::Window* target, ui::KeyEvent* event) OVERRIDE; |
56 virtual bool PreHandleMouseEvent( | 55 virtual bool PreHandleMouseEvent( |
57 aura::Window* target, aura::MouseEvent* event) OVERRIDE; | 56 aura::Window* target, ui::MouseEvent* event) OVERRIDE; |
58 virtual ui::TouchStatus PreHandleTouchEvent( | 57 virtual ui::TouchStatus PreHandleTouchEvent( |
59 aura::Window* target, aura::TouchEvent* event) OVERRIDE; | 58 aura::Window* target, ui::TouchEventImpl* event) OVERRIDE; |
60 virtual ui::GestureStatus PreHandleGestureEvent( | 59 virtual ui::GestureStatus PreHandleGestureEvent( |
61 aura::Window* target, aura::GestureEvent* event) OVERRIDE; | 60 aura::Window* target, ui::GestureEventImpl* event) OVERRIDE; |
62 | 61 |
63 // ShellObserver overrides: | 62 // ShellObserver overrides: |
64 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; | 63 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; |
65 virtual void OnAppTerminating() OVERRIDE; | 64 virtual void OnAppTerminating() OVERRIDE; |
66 virtual void OnLockStateChanged(bool locked) OVERRIDE; | 65 virtual void OnLockStateChanged(bool locked) OVERRIDE; |
67 | 66 |
68 private: | 67 private: |
69 Delegate* delegate_; | 68 Delegate* delegate_; |
70 | 69 |
71 DISALLOW_COPY_AND_ASSIGN(OverlayEventFilter); | 70 DISALLOW_COPY_AND_ASSIGN(OverlayEventFilter); |
72 }; | 71 }; |
73 | 72 |
74 } // namespace internal | 73 } // namespace internal |
75 } // namespace ash | 74 } // namespace ash |
76 | 75 |
77 #endif // ASH_WM_OVERLAY_EVENT_FILTER_H_ | 76 #endif // ASH_WM_OVERLAY_EVENT_FILTER_H_ |
OLD | NEW |