Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef ASH_WM_OVERLAY_EVENT_FILTER_H_ | |
| 6 #define ASH_WM_OVERLAY_EVENT_FILTER_H_ | |
| 7 | |
| 8 #include "ash/shell_observer.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "ui/aura/event.h" | |
| 11 #include "ui/aura/event_filter.h" | |
| 12 | |
| 13 namespace ash { | |
| 14 namespace internal { | |
| 15 | |
| 16 // EventFilter for "overlay window", which intercepts events before they are | |
|
Daniel Erat
2012/07/26 01:52:51
nit: s/for /for the /
mazda
2012/07/26 02:09:08
Done.
| |
| 17 // processed in usual paths (e.g. the partial screenshot UI, the keyboard | |
|
Daniel Erat
2012/07/26 01:52:51
nit: "processed by the usual path ..."
mazda
2012/07/26 02:09:08
Done.
| |
| 18 // overlay). It does nothing for the first time, but works when |Activate()| | |
|
Daniel Erat
2012/07/26 01:52:51
nit: "It does nothing the first time..."
mazda
2012/07/26 02:09:08
Done.
| |
| 19 // is 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 | |
| 21 // for canceling are pressed. | |
| 22 class OverlayEventFilter : public aura::EventFilter, | |
| 23 public ShellObserver { | |
| 24 public: | |
| 25 // Windows that need to receive events from OverlayEventFilter implement this. | |
| 26 class Delegate { | |
| 27 public: | |
| 28 // Invoked when OverlayEventFilter needs to stop handling events. | |
| 29 virtual void Cancel() = 0; | |
|
Daniel Erat
2012/07/26 01:52:51
nit: mind adding blank lines between methods?
mazda
2012/07/26 02:09:08
Done.
| |
| 30 // Returns true if |event| is a key event to cancel. | |
|
Daniel Erat
2012/07/26 01:52:51
nit: "Returns true if the overlay should be cancel
mazda
2012/07/26 02:09:08
Done.
| |
| 31 virtual bool IsCancelingKeyEvent(aura::KeyEvent* event) = 0; | |
| 32 // Returns the window that needs to receive events. | |
| 33 virtual aura::Window* GetWindow() = 0; | |
| 34 }; | |
| 35 | |
| 36 OverlayEventFilter(); | |
| 37 virtual ~OverlayEventFilter(); | |
| 38 | |
| 39 // Start the filtering of events. It also notifies the specified | |
|
Daniel Erat
2012/07/26 01:52:51
nit: s/Start/Starts/
mazda
2012/07/26 02:09:08
Done.
| |
| 40 // |delegate| when a key event means cancel (like Esc). It holds the | |
| 41 // pointer to the specified |delegate| until Deactivate() is called, but | |
| 42 // does not take ownership. | |
| 43 void Activate(Delegate* delegate); | |
| 44 | |
| 45 // End the filtering of events. | |
|
Daniel Erat
2012/07/26 01:52:51
nit: s/End/Ends/
mazda
2012/07/26 02:09:08
Done.
| |
| 46 void Deactivate(); | |
| 47 | |
| 48 // Cancels the partial screenshot UI. Do nothing if it's not activated. | |
| 49 void Cancel(); | |
| 50 | |
| 51 // aura::EventFilter overrides: | |
| 52 virtual bool PreHandleKeyEvent( | |
| 53 aura::Window* target, aura::KeyEvent* event) OVERRIDE; | |
| 54 virtual bool PreHandleMouseEvent( | |
| 55 aura::Window* target, aura::MouseEvent* event) OVERRIDE; | |
| 56 virtual ui::TouchStatus PreHandleTouchEvent( | |
| 57 aura::Window* target, aura::TouchEvent* event) OVERRIDE; | |
| 58 virtual ui::GestureStatus PreHandleGestureEvent( | |
| 59 aura::Window* target, aura::GestureEvent* event) OVERRIDE; | |
| 60 | |
| 61 // ShellObserver overrides: | |
| 62 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE; | |
| 63 virtual void OnAppTerminating() OVERRIDE; | |
| 64 virtual void OnLockStateChanged(bool locked) OVERRIDE; | |
| 65 | |
| 66 private: | |
| 67 Delegate* delegate_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(OverlayEventFilter); | |
| 70 }; | |
| 71 | |
| 72 } // namespace internal | |
| 73 } // namespace ash | |
| 74 | |
| 75 #endif // ASH_WM_OVERLAY_EVENT_FILTER_H_ | |
| OLD | NEW |