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 |
(...skipping 21 matching lines...) Expand all Loading... | |
32 } | 32 } |
33 | 33 |
34 namespace ui { | 34 namespace ui { |
35 class LocatedEvent; | 35 class LocatedEvent; |
36 } | 36 } |
37 | 37 |
38 namespace ash { | 38 namespace ash { |
39 class WindowSelectorDelegate; | 39 class WindowSelectorDelegate; |
40 class WindowSelectorItem; | 40 class WindowSelectorItem; |
41 class WindowSelectorTest; | 41 class WindowSelectorTest; |
42 class WindowGrid; | |
42 | 43 |
43 // The WindowSelector shows a grid of all of your windows, allowing to select | 44 // The WindowSelector shows a grid of all of your windows, allowing to select |
44 // one by clicking or tapping on it. | 45 // one by clicking or tapping on it. |
45 class ASH_EXPORT WindowSelector | 46 class ASH_EXPORT WindowSelector |
46 : public ui::EventHandler, | 47 : public ui::EventHandler, |
47 public gfx::DisplayObserver, | 48 public gfx::DisplayObserver, |
48 public aura::WindowObserver, | 49 public aura::WindowObserver, |
49 public aura::client::ActivationChangeObserver { | 50 public aura::client::ActivationChangeObserver { |
50 public: | 51 public: |
52 enum Direction { | |
53 RIGHT, | |
54 DOWN, | |
55 LEFT, | |
56 UP | |
57 }; | |
58 | |
51 typedef std::vector<aura::Window*> WindowList; | 59 typedef std::vector<aura::Window*> WindowList; |
52 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | 60 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; |
53 | 61 |
54 WindowSelector(const WindowList& windows, | 62 WindowSelector(const WindowList& windows, |
55 WindowSelectorDelegate* delegate); | 63 WindowSelectorDelegate* delegate); |
56 virtual ~WindowSelector(); | 64 virtual ~WindowSelector(); |
57 | 65 |
58 // Choose |window| from the available windows to select. | 66 // Choose |window| from the available windows to select. |
59 void SelectWindow(aura::Window* window); | 67 void SelectWindow(aura::Window* window); |
60 | 68 |
(...skipping 25 matching lines...) Expand all Loading... | |
86 virtual void OnAttemptToReactivateWindow( | 94 virtual void OnAttemptToReactivateWindow( |
87 aura::Window* request_active, | 95 aura::Window* request_active, |
88 aura::Window* actual_active) OVERRIDE; | 96 aura::Window* actual_active) OVERRIDE; |
89 | 97 |
90 private: | 98 private: |
91 friend class WindowSelectorTest; | 99 friend class WindowSelectorTest; |
92 | 100 |
93 // Begins positioning windows such that all windows are visible on the screen. | 101 // Begins positioning windows such that all windows are visible on the screen. |
94 void StartOverview(); | 102 void StartOverview(); |
95 | 103 |
96 // Position all of the windows based on the current selection mode. | 104 // Position all of the windows in the overview. |
97 void PositionWindows(bool animate); | 105 void PositionWindows(bool animate); |
98 // Position all of the windows from |root_window| on |root_window|. | 106 |
99 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); | 107 // Creates the WindowGrid objects and populates them with the current windows. |
108 void CreateWindowGrids(); | |
100 | 109 |
101 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If | 110 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If |
102 // Hide and track all hidden windows not in overview. | 111 // Hide and track all hidden windows not in overview. |
103 void HideAndTrackNonOverviewWindows(); | 112 void HideAndTrackNonOverviewWindows(); |
104 | 113 |
105 // |focus|, restores focus to the stored window. | 114 // |focus|, restores focus to the stored window. |
106 void ResetFocusRestoreWindow(bool focus); | 115 void ResetFocusRestoreWindow(bool focus); |
107 | 116 |
108 // Returns the target of |event| or NULL if the event is not targeted at | 117 // Returns the target of |event| or NULL if the event is not targeted at |
109 // any of the windows in the selector. | 118 // any of the windows in the selector. |
110 aura::Window* GetEventTarget(ui::LocatedEvent* event); | 119 aura::Window* GetEventTarget(ui::LocatedEvent* event); |
111 | 120 |
112 // Returns the top-level window selected by targeting |window| or NULL if | 121 // Returns the top-level window selected by targeting |window| or NULL if |
113 // no overview window was found for |window|. | 122 // no overview window was found for |window|. |
114 aura::Window* GetTargetedWindow(aura::Window* window); | 123 aura::Window* GetTargetedWindow(aura::Window* window); |
115 | 124 |
125 // Helper function that moves the selection widget to |direction| on the | |
126 // corresponding window grid. | |
127 void Move(Direction direction); | |
128 | |
116 // The collection of items in the overview wrapped by a helper class which | 129 // The collection of items in the overview wrapped by a helper class which |
117 // restores their state and helps transform them to other root windows. | 130 // restores their state and helps transform them to other root windows. |
118 ScopedVector<WindowSelectorItem> windows_; | 131 ScopedVector<WindowSelectorItem> windows_; |
119 | 132 |
120 // Tracks observed windows. | 133 // Tracks observed windows. |
121 std::set<aura::Window*> observed_windows_; | 134 std::set<aura::Window*> observed_windows_; |
122 | 135 |
123 // Weak pointer to the selector delegate which will be called when a | 136 // Weak pointer to the selector delegate which will be called when a |
124 // selection is made. | 137 // selection is made. |
125 WindowSelectorDelegate* delegate_; | 138 WindowSelectorDelegate* delegate_; |
126 | 139 |
127 // A weak pointer to the window which was focused on beginning window | 140 // A weak pointer to the window which was focused on beginning window |
128 // selection. If window selection is canceled the focus should be restored to | 141 // selection. If window selection is canceled the focus should be restored to |
129 // this window. | 142 // this window. |
130 aura::Window* restore_focus_window_; | 143 aura::Window* restore_focus_window_; |
131 | 144 |
132 // True when performing operations that may cause window activations. This is | 145 // True when performing operations that may cause window activations. This is |
133 // used to prevent handling the resulting expected activation. | 146 // used to prevent handling the resulting expected activation. |
134 bool ignore_activations_; | 147 bool ignore_activations_; |
135 | 148 |
149 // List of all the window overview grids, one for each root window. | |
150 ScopedVector<WindowGrid> grid_list_; | |
151 | |
136 // The cursor client used to lock the current cursor during overview. | 152 // The cursor client used to lock the current cursor during overview. |
137 aura::client::CursorClient* cursor_client_; | 153 aura::client::CursorClient* cursor_client_; |
138 | 154 |
139 // The time when overview was started. | 155 // The time when overview was started. |
140 base::Time overview_start_time_; | 156 base::Time overview_start_time_; |
141 | 157 |
142 // Tracks windows which were hidden because they were not part of the | 158 // Tracks windows which were hidden because they were not part of the |
143 // overview. | 159 // overview. |
144 aura::WindowTracker hidden_windows_; | 160 aura::WindowTracker hidden_windows_; |
145 | 161 |
162 // Tracks the index of the root window the selection widget is in. | |
163 size_t root_index_; | |
flackr
2014/05/29 20:04:25
nit: selected_grid_index_ or something like that.
Nina
2014/06/02 22:04:38
Done.
| |
164 | |
146 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 165 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
147 }; | 166 }; |
148 | 167 |
149 } // namespace ash | 168 } // namespace ash |
150 | 169 |
151 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 170 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
OLD | NEW |