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 #include "ash/wm/window_cycle_controller.h" | 5 #include "ash/wm/window_cycle_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/wm/activation_controller.h" | 11 #include "ash/wm/activation_controller.h" |
12 #include "ash/wm/window_cycle_list.h" | 12 #include "ash/wm/window_cycle_list.h" |
13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
14 #include "ui/aura/event.h" | |
15 #include "ui/aura/event_filter.h" | 14 #include "ui/aura/event_filter.h" |
16 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
| 16 #include "ui/base/event.h" |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // List of containers whose children we will cycle through. | 22 // List of containers whose children we will cycle through. |
23 const int kContainerIds[] = { | 23 const int kContainerIds[] = { |
24 internal::kShellWindowId_DefaultContainer, | 24 internal::kShellWindowId_DefaultContainer, |
25 internal::kShellWindowId_AlwaysOnTopContainer | 25 internal::kShellWindowId_AlwaysOnTopContainer |
26 }; | 26 }; |
27 | 27 |
28 // Filter to watch for the termination of a keyboard gesture to cycle through | 28 // Filter to watch for the termination of a keyboard gesture to cycle through |
29 // multiple windows. | 29 // multiple windows. |
30 class WindowCycleEventFilter : public aura::EventFilter { | 30 class WindowCycleEventFilter : public aura::EventFilter { |
31 public: | 31 public: |
32 WindowCycleEventFilter(); | 32 WindowCycleEventFilter(); |
33 virtual ~WindowCycleEventFilter(); | 33 virtual ~WindowCycleEventFilter(); |
34 | 34 |
35 // Overridden from aura::EventFilter: | 35 // Overridden from aura::EventFilter: |
36 virtual bool PreHandleKeyEvent(aura::Window* target, | 36 virtual bool PreHandleKeyEvent(aura::Window* target, |
37 aura::KeyEvent* event) OVERRIDE; | 37 ui::KeyEvent* event) OVERRIDE; |
38 virtual bool PreHandleMouseEvent(aura::Window* target, | 38 virtual bool PreHandleMouseEvent(aura::Window* target, |
39 aura::MouseEvent* event) OVERRIDE; | 39 ui::MouseEvent* event) OVERRIDE; |
40 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | 40 virtual ui::TouchStatus PreHandleTouchEvent( |
41 aura::TouchEvent* event) OVERRIDE; | 41 aura::Window* target, |
| 42 ui::TouchEventImpl* event) OVERRIDE; |
42 virtual ui::GestureStatus PreHandleGestureEvent( | 43 virtual ui::GestureStatus PreHandleGestureEvent( |
43 aura::Window* target, | 44 aura::Window* target, |
44 aura::GestureEvent* event) OVERRIDE; | 45 ui::GestureEventImpl* event) OVERRIDE; |
45 private: | 46 private: |
46 DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilter); | 47 DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilter); |
47 }; | 48 }; |
48 | 49 |
49 // Watch for all keyboard events by filtering the root window. | 50 // Watch for all keyboard events by filtering the root window. |
50 WindowCycleEventFilter::WindowCycleEventFilter() { | 51 WindowCycleEventFilter::WindowCycleEventFilter() { |
51 } | 52 } |
52 | 53 |
53 WindowCycleEventFilter::~WindowCycleEventFilter() { | 54 WindowCycleEventFilter::~WindowCycleEventFilter() { |
54 } | 55 } |
55 | 56 |
56 bool WindowCycleEventFilter::PreHandleKeyEvent( | 57 bool WindowCycleEventFilter::PreHandleKeyEvent( |
57 aura::Window* target, | 58 aura::Window* target, |
58 aura::KeyEvent* event) { | 59 ui::KeyEvent* event) { |
59 // Views uses VKEY_MENU for both left and right Alt keys. | 60 // Views uses VKEY_MENU for both left and right Alt keys. |
60 if (event->key_code() == ui::VKEY_MENU && | 61 if (event->key_code() == ui::VKEY_MENU && |
61 event->type() == ui::ET_KEY_RELEASED) { | 62 event->type() == ui::ET_KEY_RELEASED) { |
62 Shell::GetInstance()->window_cycle_controller()->AltKeyReleased(); | 63 Shell::GetInstance()->window_cycle_controller()->AltKeyReleased(); |
63 // Warning: |this| will be deleted from here on. | 64 // Warning: |this| will be deleted from here on. |
64 } | 65 } |
65 return false; // Always let the event propagate. | 66 return false; // Always let the event propagate. |
66 } | 67 } |
67 | 68 |
68 bool WindowCycleEventFilter::PreHandleMouseEvent( | 69 bool WindowCycleEventFilter::PreHandleMouseEvent( |
69 aura::Window* target, | 70 aura::Window* target, |
70 aura::MouseEvent* event) { | 71 ui::MouseEvent* event) { |
71 return false; // Not handled. | 72 return false; // Not handled. |
72 } | 73 } |
73 | 74 |
74 ui::TouchStatus WindowCycleEventFilter::PreHandleTouchEvent( | 75 ui::TouchStatus WindowCycleEventFilter::PreHandleTouchEvent( |
75 aura::Window* target, | 76 aura::Window* target, |
76 aura::TouchEvent* event) { | 77 ui::TouchEventImpl* event) { |
77 return ui::TOUCH_STATUS_UNKNOWN; // Not handled. | 78 return ui::TOUCH_STATUS_UNKNOWN; // Not handled. |
78 } | 79 } |
79 | 80 |
80 ui::GestureStatus WindowCycleEventFilter::PreHandleGestureEvent( | 81 ui::GestureStatus WindowCycleEventFilter::PreHandleGestureEvent( |
81 aura::Window* target, | 82 aura::Window* target, |
82 aura::GestureEvent* event) { | 83 ui::GestureEventImpl* event) { |
83 return ui::GESTURE_STATUS_UNKNOWN; // Not handled. | 84 return ui::GESTURE_STATUS_UNKNOWN; // Not handled. |
84 } | 85 } |
85 | 86 |
86 } // namespace | 87 } // namespace |
87 | 88 |
88 ////////////////////////////////////////////////////////////////////////////// | 89 ////////////////////////////////////////////////////////////////////////////// |
89 // WindowCycleController, public: | 90 // WindowCycleController, public: |
90 | 91 |
91 WindowCycleController::WindowCycleController( | 92 WindowCycleController::WindowCycleController( |
92 internal::ActivationController* activation_controller) | 93 internal::ActivationController* activation_controller) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 265 |
265 void WindowCycleController::OnWillRemoveWindow(aura::Window* window) { | 266 void WindowCycleController::OnWillRemoveWindow(aura::Window* window) { |
266 mru_windows_.remove(window); | 267 mru_windows_.remove(window); |
267 } | 268 } |
268 | 269 |
269 void WindowCycleController::OnWindowDestroying(aura::Window* window) { | 270 void WindowCycleController::OnWindowDestroying(aura::Window* window) { |
270 window->RemoveObserver(this); | 271 window->RemoveObserver(this); |
271 } | 272 } |
272 | 273 |
273 } // namespace ash | 274 } // namespace ash |
OLD | NEW |