| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_OVERVIEW_WINDOW_SELECTOR_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
| 17 #include "ui/wm/public/activation_change_observer.h" | 17 #include "ui/wm/public/activation_change_observer.h" |
| 18 | 18 |
| 19 namespace aura { | 19 namespace aura { |
| 20 class RootWindow; | 20 class RootWindow; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace ui { | |
| 24 class EventHandler; | |
| 25 } | |
| 26 | |
| 27 namespace ash { | 23 namespace ash { |
| 28 class ScopedShowWindow; | |
| 29 class WindowOverview; | 24 class WindowOverview; |
| 30 class WindowSelectorDelegate; | 25 class WindowSelectorDelegate; |
| 31 class WindowSelectorItem; | 26 class WindowSelectorItem; |
| 32 class WindowSelectorTest; | 27 class WindowSelectorTest; |
| 33 | 28 |
| 34 // The WindowSelector allows selecting a window by alt-tabbing (CYCLE mode) or | 29 // The WindowSelector allows selecting a window by clicking or tapping on it |
| 35 // by clicking or tapping on it (OVERVIEW mode). A WindowOverview will be shown | 30 // (entering Overview Mode). |
| 36 // in OVERVIEW mode or if the user lingers on a window while alt tabbing. | |
| 37 class ASH_EXPORT WindowSelector | 31 class ASH_EXPORT WindowSelector |
| 38 : public aura::WindowObserver, | 32 : public aura::WindowObserver, |
| 39 public aura::client::ActivationChangeObserver { | 33 public aura::client::ActivationChangeObserver { |
| 40 public: | 34 public: |
| 41 enum Direction { | |
| 42 FORWARD, | |
| 43 BACKWARD | |
| 44 }; | |
| 45 enum Mode { | |
| 46 CYCLE, | |
| 47 OVERVIEW | |
| 48 }; | |
| 49 | |
| 50 typedef std::vector<aura::Window*> WindowList; | 35 typedef std::vector<aura::Window*> WindowList; |
| 51 | 36 |
| 52 WindowSelector(const WindowList& windows, | 37 WindowSelector(const WindowList& windows, |
| 53 Mode mode, | |
| 54 WindowSelectorDelegate* delegate); | 38 WindowSelectorDelegate* delegate); |
| 55 virtual ~WindowSelector(); | 39 virtual ~WindowSelector(); |
| 56 | 40 |
| 57 // Step to the next window in |direction|. | |
| 58 void Step(Direction direction); | |
| 59 | |
| 60 // Choose the currently selected window. | |
| 61 void SelectWindow(); | |
| 62 | |
| 63 // Choose |window| from the available windows to select. | 41 // Choose |window| from the available windows to select. |
| 64 void SelectWindow(aura::Window* window); | 42 void SelectWindow(aura::Window* window); |
| 65 | 43 |
| 66 // Cancels window selection. | 44 // Cancels window selection. |
| 67 void CancelSelection(); | 45 void CancelSelection(); |
| 68 | 46 |
| 69 Mode mode() { return mode_; } | |
| 70 | |
| 71 // aura::WindowObserver: | 47 // aura::WindowObserver: |
| 72 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; | 48 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; |
| 73 virtual void OnWindowBoundsChanged(aura::Window* window, | 49 virtual void OnWindowBoundsChanged(aura::Window* window, |
| 74 const gfx::Rect& old_bounds, | 50 const gfx::Rect& old_bounds, |
| 75 const gfx::Rect& new_bounds) OVERRIDE; | 51 const gfx::Rect& new_bounds) OVERRIDE; |
| 76 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 52 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 77 | 53 |
| 78 // Overridden from aura::client::ActivationChangeObserver: | 54 // Overridden from aura::client::ActivationChangeObserver: |
| 79 virtual void OnWindowActivated(aura::Window* gained_active, | 55 virtual void OnWindowActivated(aura::Window* gained_active, |
| 80 aura::Window* lost_active) OVERRIDE; | 56 aura::Window* lost_active) OVERRIDE; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 // |focus|, restores focus to the stored window. | 68 // |focus|, restores focus to the stored window. |
| 93 void ResetFocusRestoreWindow(bool focus); | 69 void ResetFocusRestoreWindow(bool focus); |
| 94 | 70 |
| 95 // The collection of items in the overview wrapped by a helper class which | 71 // The collection of items in the overview wrapped by a helper class which |
| 96 // restores their state and helps transform them to other root windows. | 72 // restores their state and helps transform them to other root windows. |
| 97 ScopedVector<WindowSelectorItem> windows_; | 73 ScopedVector<WindowSelectorItem> windows_; |
| 98 | 74 |
| 99 // Tracks observed windows. | 75 // Tracks observed windows. |
| 100 std::set<aura::Window*> observed_windows_; | 76 std::set<aura::Window*> observed_windows_; |
| 101 | 77 |
| 102 // The window selection mode. | |
| 103 Mode mode_; | |
| 104 | |
| 105 // An event handler listening for the release of the alt key during alt-tab | |
| 106 // cycling. | |
| 107 scoped_ptr<ui::EventHandler> event_handler_; | |
| 108 | |
| 109 // The currently selected window being shown (temporarily brought to the front | |
| 110 // of the stacking order and made visible). | |
| 111 scoped_ptr<ScopedShowWindow> showing_window_; | |
| 112 | |
| 113 scoped_ptr<WindowOverview> window_overview_; | 78 scoped_ptr<WindowOverview> window_overview_; |
| 114 | 79 |
| 115 // The time when window cycling was started. | |
| 116 base::Time cycle_start_time_; | |
| 117 | |
| 118 // Weak pointer to the selector delegate which will be called when a | 80 // Weak pointer to the selector delegate which will be called when a |
| 119 // selection is made. | 81 // selection is made. |
| 120 WindowSelectorDelegate* delegate_; | 82 WindowSelectorDelegate* delegate_; |
| 121 | 83 |
| 122 // Index of the currently selected window if the mode is CYCLE. | |
| 123 size_t selected_window_; | |
| 124 | |
| 125 // A weak pointer to the window which was focused on beginning window | 84 // A weak pointer to the window which was focused on beginning window |
| 126 // selection. If window selection is canceled the focus should be restored to | 85 // selection. If window selection is canceled the focus should be restored to |
| 127 // this window. | 86 // this window. |
| 128 aura::Window* restore_focus_window_; | 87 aura::Window* restore_focus_window_; |
| 129 | 88 |
| 130 // True when performing operations that may cause window activations. This is | 89 // True when performing operations that may cause window activations. This is |
| 131 // used to prevent handling the resulting expected activation. | 90 // used to prevent handling the resulting expected activation. |
| 132 bool ignore_activations_; | 91 bool ignore_activations_; |
| 133 | 92 |
| 134 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 93 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
| 135 }; | 94 }; |
| 136 | 95 |
| 137 } // namespace ash | 96 } // namespace ash |
| 138 | 97 |
| 139 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 98 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| OLD | NEW |