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 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 namespace ui { | 31 namespace ui { |
32 class LocatedEvent; | 32 class LocatedEvent; |
33 } | 33 } |
34 | 34 |
35 namespace ash { | 35 namespace ash { |
36 class WindowSelectorDelegate; | 36 class WindowSelectorDelegate; |
37 class WindowSelectorItem; | 37 class WindowSelectorItem; |
38 class WindowSelectorTest; | 38 class WindowSelectorTest; |
| 39 class WindowGrid; |
39 | 40 |
40 // The WindowSelector shows a grid of all of your windows, allowing to select | 41 // The WindowSelector shows a grid of all of your windows, allowing to select |
41 // one by clicking or tapping on it. | 42 // one by clicking or tapping on it. |
42 class ASH_EXPORT WindowSelector | 43 class ASH_EXPORT WindowSelector |
43 : public ui::EventHandler, | 44 : public ui::EventHandler, |
44 public gfx::DisplayObserver, | 45 public gfx::DisplayObserver, |
45 public aura::WindowObserver, | 46 public aura::WindowObserver, |
46 public aura::client::ActivationChangeObserver { | 47 public aura::client::ActivationChangeObserver { |
47 public: | 48 public: |
| 49 enum Direction { |
| 50 RIGHT, |
| 51 DOWN, |
| 52 LEFT, |
| 53 UP |
| 54 }; |
| 55 |
48 typedef std::vector<aura::Window*> WindowList; | 56 typedef std::vector<aura::Window*> WindowList; |
49 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | 57 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; |
50 | 58 |
51 WindowSelector(const WindowList& windows, | 59 WindowSelector(const WindowList& windows, |
52 WindowSelectorDelegate* delegate); | 60 WindowSelectorDelegate* delegate); |
53 virtual ~WindowSelector(); | 61 virtual ~WindowSelector(); |
54 | 62 |
55 // Cancels window selection. | 63 // Cancels window selection. |
56 void CancelSelection(); | 64 void CancelSelection(); |
57 | 65 |
| 66 // Called when the last window selector item from a grid is deleted. |
| 67 void OnGridEmpty(WindowGrid* grid); |
| 68 |
58 // ui::EventHandler: | 69 // ui::EventHandler: |
59 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 70 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
60 | 71 |
61 // gfx::DisplayObserver: | 72 // gfx::DisplayObserver: |
62 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | 73 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; |
63 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | 74 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; |
64 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 75 virtual void OnDisplayMetricsChanged(const gfx::Display& display, |
65 uint32_t metrics) OVERRIDE; | 76 uint32_t metrics) OVERRIDE; |
66 | 77 |
67 // aura::WindowObserver: | 78 // aura::WindowObserver: |
68 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; | 79 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; |
69 virtual void OnWindowBoundsChanged(aura::Window* window, | |
70 const gfx::Rect& old_bounds, | |
71 const gfx::Rect& new_bounds) OVERRIDE; | |
72 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 80 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
73 | 81 |
74 // aura::client::ActivationChangeObserver: | 82 // aura::client::ActivationChangeObserver: |
75 virtual void OnWindowActivated(aura::Window* gained_active, | 83 virtual void OnWindowActivated(aura::Window* gained_active, |
76 aura::Window* lost_active) OVERRIDE; | 84 aura::Window* lost_active) OVERRIDE; |
77 virtual void OnAttemptToReactivateWindow( | 85 virtual void OnAttemptToReactivateWindow( |
78 aura::Window* request_active, | 86 aura::Window* request_active, |
79 aura::Window* actual_active) OVERRIDE; | 87 aura::Window* actual_active) OVERRIDE; |
80 | 88 |
81 private: | 89 private: |
82 friend class WindowSelectorTest; | 90 friend class WindowSelectorTest; |
83 | 91 |
84 // Begins positioning windows such that all windows are visible on the screen. | 92 // Begins positioning windows such that all windows are visible on the screen. |
85 void StartOverview(); | 93 void StartOverview(); |
86 | 94 |
87 // Returns true if a window is contained in the overview, and therefore should | 95 // Position all of the windows in the overview. |
88 // not be hidden prior to entering overview mode. | 96 void PositionWindows(bool animate); |
89 bool Contains(const aura::Window* window); | |
90 | 97 |
91 // Position all of the windows based on the current selection mode. | 98 // Creates the WindowGrid objects and populates them with the current windows. |
92 void PositionWindows(bool animate); | 99 void CreateWindowGrids(); |
93 // Position all of the windows from |root_window| on |root_window|. | |
94 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); | |
95 | 100 |
96 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If | 101 // Hide and track all hidden windows not in the overview item list. |
97 // Hide and track all hidden windows not in overview. | |
98 void HideAndTrackNonOverviewWindows(); | 102 void HideAndTrackNonOverviewWindows(); |
99 | 103 |
100 // |focus|, restores focus to the stored window. | 104 // |focus|, restores focus to the stored window. |
101 void ResetFocusRestoreWindow(bool focus); | 105 void ResetFocusRestoreWindow(bool focus); |
102 | 106 |
103 // The collection of items in the overview wrapped by a helper class which | 107 // Helper function that moves the selection widget to |direction| on the |
104 // restores their state and helps transform them to other root windows. | 108 // corresponding window grid. |
105 ScopedVector<WindowSelectorItem> windows_; | 109 void Move(Direction direction); |
| 110 |
| 111 // Returns the WindowSelectorItem |
106 | 112 |
107 // Tracks observed windows. | 113 // Tracks observed windows. |
108 std::set<aura::Window*> observed_windows_; | 114 std::set<aura::Window*> observed_windows_; |
109 | 115 |
110 // Weak pointer to the selector delegate which will be called when a | 116 // Weak pointer to the selector delegate which will be called when a |
111 // selection is made. | 117 // selection is made. |
112 WindowSelectorDelegate* delegate_; | 118 WindowSelectorDelegate* delegate_; |
113 | 119 |
114 // A weak pointer to the window which was focused on beginning window | 120 // A weak pointer to the window which was focused on beginning window |
115 // selection. If window selection is canceled the focus should be restored to | 121 // selection. If window selection is canceled the focus should be restored to |
116 // this window. | 122 // this window. |
117 aura::Window* restore_focus_window_; | 123 aura::Window* restore_focus_window_; |
118 | 124 |
119 // True when performing operations that may cause window activations. This is | 125 // True when performing operations that may cause window activations. This is |
120 // used to prevent handling the resulting expected activation. | 126 // used to prevent handling the resulting expected activation. |
121 bool ignore_activations_; | 127 bool ignore_activations_; |
122 | 128 |
| 129 // List of all the window overview grids, one for each root window. |
| 130 ScopedVector<WindowGrid> grid_list_; |
| 131 |
123 // The time when overview was started. | 132 // The time when overview was started. |
124 base::Time overview_start_time_; | 133 base::Time overview_start_time_; |
125 | 134 |
126 // Tracks windows which were hidden because they were not part of the | 135 // Tracks windows which were hidden because they were not part of the |
127 // overview. | 136 // overview. |
128 aura::WindowTracker hidden_windows_; | 137 aura::WindowTracker hidden_windows_; |
129 | 138 |
| 139 // Tracks the index of the root window the selection widget is in. |
| 140 size_t selected_grid_index_; |
| 141 |
130 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 142 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
131 }; | 143 }; |
132 | 144 |
133 } // namespace ash | 145 } // namespace ash |
134 | 146 |
135 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 147 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
OLD | NEW |