| 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 "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "ui/aura/event.h" | 10 #include "ui/aura/event.h" |
| 11 #include "ui/aura/event_filter.h" | 11 #include "ui/aura/event_filter.h" |
| 12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 | 15 |
| 16 // Filter to watch for the termination of a keyboard gesture to cycle through | 16 // Filter to watch for the termination of a keyboard gesture to cycle through |
| 17 // multiple windows. | 17 // multiple windows. |
| 18 class WindowCycleEventFilter : public aura::EventFilter { | 18 class WindowCycleEventFilter : public aura::EventFilter { |
| 19 public: | 19 public: |
| 20 WindowCycleEventFilter(); | 20 WindowCycleEventFilter(); |
| 21 virtual ~WindowCycleEventFilter(); | 21 virtual ~WindowCycleEventFilter(); |
| 22 | 22 |
| 23 // Overridden from aura::EventFilter: | 23 // Overridden from aura::EventFilter: |
| 24 virtual bool PreHandleKeyEvent(aura::Window* target, | 24 virtual bool PreHandleKeyEvent(aura::Window* target, |
| 25 aura::KeyEvent* event) OVERRIDE; | 25 aura::KeyEvent* event) OVERRIDE; |
| 26 virtual bool PreHandleMouseEvent(aura::Window* target, | 26 virtual bool PreHandleMouseEvent(aura::Window* target, |
| 27 aura::MouseEvent* event) OVERRIDE; | 27 aura::MouseEvent* event) OVERRIDE; |
| 28 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | 28 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, |
| 29 aura::TouchEvent* event) OVERRIDE; | 29 aura::TouchEvent* event) OVERRIDE; |
| 30 virtual ui::GestureStatus PreHandleGestureEvent( |
| 31 aura::Window* target, |
| 32 aura::GestureEvent* event) OVERRIDE; |
| 30 private: | 33 private: |
| 31 DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilter); | 34 DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilter); |
| 32 }; | 35 }; |
| 33 | 36 |
| 34 // Watch for all keyboard events by filtering the root window. | 37 // Watch for all keyboard events by filtering the root window. |
| 35 WindowCycleEventFilter::WindowCycleEventFilter() | 38 WindowCycleEventFilter::WindowCycleEventFilter() |
| 36 : aura::EventFilter(aura::RootWindow::GetInstance()) { | 39 : aura::EventFilter(aura::RootWindow::GetInstance()) { |
| 37 } | 40 } |
| 38 | 41 |
| 39 WindowCycleEventFilter::~WindowCycleEventFilter() { | 42 WindowCycleEventFilter::~WindowCycleEventFilter() { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 aura::MouseEvent* event) { | 59 aura::MouseEvent* event) { |
| 57 return false; // Not handled. | 60 return false; // Not handled. |
| 58 } | 61 } |
| 59 | 62 |
| 60 ui::TouchStatus WindowCycleEventFilter::PreHandleTouchEvent( | 63 ui::TouchStatus WindowCycleEventFilter::PreHandleTouchEvent( |
| 61 aura::Window* target, | 64 aura::Window* target, |
| 62 aura::TouchEvent* event) { | 65 aura::TouchEvent* event) { |
| 63 return ui::TOUCH_STATUS_UNKNOWN; // Not handled. | 66 return ui::TOUCH_STATUS_UNKNOWN; // Not handled. |
| 64 } | 67 } |
| 65 | 68 |
| 69 ui::GestureStatus WindowCycleEventFilter::PreHandleGestureEvent( |
| 70 aura::Window* target, |
| 71 aura::GestureEvent* event) { |
| 72 return ui::GESTURE_STATUS_UNKNOWN; // Not handled. |
| 73 } |
| 74 |
| 66 ////////////////////////////////////////////////////////////////////////////// | 75 ////////////////////////////////////////////////////////////////////////////// |
| 67 // WindowCycleController, public: | 76 // WindowCycleController, public: |
| 68 | 77 |
| 69 WindowCycleController::WindowCycleController() : current_index_(-1) { | 78 WindowCycleController::WindowCycleController() : current_index_(-1) { |
| 70 } | 79 } |
| 71 | 80 |
| 72 WindowCycleController::~WindowCycleController() { | 81 WindowCycleController::~WindowCycleController() { |
| 73 StopCycling(); | 82 StopCycling(); |
| 74 } | 83 } |
| 75 | 84 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 171 |
| 163 int WindowCycleController::GetWindowIndex(aura::Window* window) { | 172 int WindowCycleController::GetWindowIndex(aura::Window* window) { |
| 164 WindowList::const_iterator it = | 173 WindowList::const_iterator it = |
| 165 std::find(windows_.begin(), windows_.end(), window); | 174 std::find(windows_.begin(), windows_.end(), window); |
| 166 if (it == windows_.end()) | 175 if (it == windows_.end()) |
| 167 return -1; // Not found. | 176 return -1; // Not found. |
| 168 return it - windows_.begin(); | 177 return it - windows_.begin(); |
| 169 } | 178 } |
| 170 | 179 |
| 171 } // namespace ash | 180 } // namespace ash |
| OLD | NEW |