Chromium Code Reviews| 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; | 24 class ScopedShowWindow; |
|
flackr
2014/05/06 02:21:37
Remove this.
| |
| 29 class WindowOverview; | 25 class WindowOverview; |
| 30 class WindowSelectorDelegate; | 26 class WindowSelectorDelegate; |
| 31 class WindowSelectorItem; | 27 class WindowSelectorItem; |
| 32 class WindowSelectorTest; | 28 class WindowSelectorTest; |
| 33 | 29 |
| 34 // The WindowSelector allows selecting a window by alt-tabbing (CYCLE mode) or | 30 // The WindowSelector allows selecting a window by alt-tabbing (CYCLE mode) or |
| 35 // by clicking or tapping on it (OVERVIEW mode). A WindowOverview will be shown | 31 // by clicking or tapping on it (OVERVIEW mode). A WindowOverview will be shown |
| 36 // in OVERVIEW mode or if the user lingers on a window while alt tabbing. | 32 // in OVERVIEW mode or if the user lingers on a window while alt tabbing. |
| 37 class ASH_EXPORT WindowSelector | 33 class ASH_EXPORT WindowSelector |
| 38 : public aura::WindowObserver, | 34 : public aura::WindowObserver, |
| 39 public aura::client::ActivationChangeObserver { | 35 public aura::client::ActivationChangeObserver { |
| 40 public: | 36 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; | 37 typedef std::vector<aura::Window*> WindowList; |
| 51 | 38 |
| 52 WindowSelector(const WindowList& windows, | 39 WindowSelector(const WindowList& windows, |
| 53 Mode mode, | |
| 54 WindowSelectorDelegate* delegate); | 40 WindowSelectorDelegate* delegate); |
| 55 virtual ~WindowSelector(); | 41 virtual ~WindowSelector(); |
| 56 | 42 |
| 57 // Step to the next window in |direction|. | |
| 58 void Step(Direction direction); | |
| 59 | |
| 60 // Choose the currently selected window. | 43 // Choose the currently selected window. |
| 61 void SelectWindow(); | 44 void SelectWindow(); |
|
flackr
2014/05/06 02:21:37
No such thing as "selected" window at present.
Nina
2014/05/06 12:46:04
Done.
| |
| 62 | 45 |
| 63 // Choose |window| from the available windows to select. | 46 // Choose |window| from the available windows to select. |
| 64 void SelectWindow(aura::Window* window); | 47 void SelectWindow(aura::Window* window); |
| 65 | 48 |
| 66 // Cancels window selection. | 49 // Cancels window selection. |
| 67 void CancelSelection(); | 50 void CancelSelection(); |
| 68 | 51 |
| 69 Mode mode() { return mode_; } | |
| 70 | |
| 71 // aura::WindowObserver: | 52 // aura::WindowObserver: |
| 72 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; | 53 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; |
| 73 virtual void OnWindowBoundsChanged(aura::Window* window, | 54 virtual void OnWindowBoundsChanged(aura::Window* window, |
| 74 const gfx::Rect& old_bounds, | 55 const gfx::Rect& old_bounds, |
| 75 const gfx::Rect& new_bounds) OVERRIDE; | 56 const gfx::Rect& new_bounds) OVERRIDE; |
| 76 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 57 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 77 | 58 |
| 78 // Overridden from aura::client::ActivationChangeObserver: | 59 // Overridden from aura::client::ActivationChangeObserver: |
| 79 virtual void OnWindowActivated(aura::Window* gained_active, | 60 virtual void OnWindowActivated(aura::Window* gained_active, |
| 80 aura::Window* lost_active) OVERRIDE; | 61 aura::Window* lost_active) OVERRIDE; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 92 // |focus|, restores focus to the stored window. | 73 // |focus|, restores focus to the stored window. |
| 93 void ResetFocusRestoreWindow(bool focus); | 74 void ResetFocusRestoreWindow(bool focus); |
| 94 | 75 |
| 95 // The collection of items in the overview wrapped by a helper class which | 76 // 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. | 77 // restores their state and helps transform them to other root windows. |
| 97 ScopedVector<WindowSelectorItem> windows_; | 78 ScopedVector<WindowSelectorItem> windows_; |
| 98 | 79 |
| 99 // Tracks observed windows. | 80 // Tracks observed windows. |
| 100 std::set<aura::Window*> observed_windows_; | 81 std::set<aura::Window*> observed_windows_; |
| 101 | 82 |
| 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_; | 83 scoped_ptr<WindowOverview> window_overview_; |
| 114 | 84 |
| 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 | 85 // Weak pointer to the selector delegate which will be called when a |
| 119 // selection is made. | 86 // selection is made. |
| 120 WindowSelectorDelegate* delegate_; | 87 WindowSelectorDelegate* delegate_; |
| 121 | 88 |
| 122 // Index of the currently selected window if the mode is CYCLE. | 89 // Index of the currently selected window if the mode is CYCLE. |
| 123 size_t selected_window_; | 90 size_t selected_window_; |
|
flackr
2014/05/06 02:21:37
I'd probably remove this for now.
| |
| 124 | 91 |
| 125 // A weak pointer to the window which was focused on beginning window | 92 // 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 | 93 // selection. If window selection is canceled the focus should be restored to |
| 127 // this window. | 94 // this window. |
| 128 aura::Window* restore_focus_window_; | 95 aura::Window* restore_focus_window_; |
| 129 | 96 |
| 130 // True when performing operations that may cause window activations. This is | 97 // True when performing operations that may cause window activations. This is |
| 131 // used to prevent handling the resulting expected activation. | 98 // used to prevent handling the resulting expected activation. |
| 132 bool ignore_activations_; | 99 bool ignore_activations_; |
| 133 | 100 |
| 134 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 101 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
| 135 }; | 102 }; |
| 136 | 103 |
| 137 } // namespace ash | 104 } // namespace ash |
| 138 | 105 |
| 139 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 106 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| OLD | NEW |