| 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 LEFT, |
| 51 UP, |
| 52 RIGHT, |
| 53 DOWN |
| 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 // Hide and track all hidden windows not in the overview item list. |
| 92 void PositionWindows(bool animate); | |
| 93 // Position all of the windows from |root_window| on |root_window|. | |
| 94 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); | |
| 95 | |
| 96 // Resets the stored window from RemoveFocusAndSetRestoreWindow to NULL. If | |
| 97 // Hide and track all hidden windows not in overview. | |
| 98 void HideAndTrackNonOverviewWindows(); | 99 void HideAndTrackNonOverviewWindows(); |
| 99 | 100 |
| 100 // |focus|, restores focus to the stored window. | 101 // |focus|, restores focus to the stored window. |
| 101 void ResetFocusRestoreWindow(bool focus); | 102 void ResetFocusRestoreWindow(bool focus); |
| 102 | 103 |
| 103 // The collection of items in the overview wrapped by a helper class which | 104 // Helper function that moves the selection widget to |direction| on the |
| 104 // restores their state and helps transform them to other root windows. | 105 // corresponding window grid. |
| 105 ScopedVector<WindowSelectorItem> windows_; | 106 void Move(Direction direction); |
| 106 | 107 |
| 107 // Tracks observed windows. | 108 // Tracks observed windows. |
| 108 std::set<aura::Window*> observed_windows_; | 109 std::set<aura::Window*> observed_windows_; |
| 109 | 110 |
| 110 // Weak pointer to the selector delegate which will be called when a | 111 // Weak pointer to the selector delegate which will be called when a |
| 111 // selection is made. | 112 // selection is made. |
| 112 WindowSelectorDelegate* delegate_; | 113 WindowSelectorDelegate* delegate_; |
| 113 | 114 |
| 114 // A weak pointer to the window which was focused on beginning window | 115 // 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 | 116 // selection. If window selection is canceled the focus should be restored to |
| 116 // this window. | 117 // this window. |
| 117 aura::Window* restore_focus_window_; | 118 aura::Window* restore_focus_window_; |
| 118 | 119 |
| 119 // True when performing operations that may cause window activations. This is | 120 // True when performing operations that may cause window activations. This is |
| 120 // used to prevent handling the resulting expected activation. | 121 // used to prevent handling the resulting expected activation. |
| 121 bool ignore_activations_; | 122 bool ignore_activations_; |
| 122 | 123 |
| 124 // List of all the window overview grids, one for each root window. |
| 125 ScopedVector<WindowGrid> grid_list_; |
| 126 |
| 123 // The time when overview was started. | 127 // The time when overview was started. |
| 124 base::Time overview_start_time_; | 128 base::Time overview_start_time_; |
| 125 | 129 |
| 126 // Tracks windows which were hidden because they were not part of the | 130 // Tracks windows which were hidden because they were not part of the |
| 127 // overview. | 131 // overview. |
| 128 aura::WindowTracker hidden_windows_; | 132 aura::WindowTracker hidden_windows_; |
| 129 | 133 |
| 134 // Tracks the index of the root window the selection widget is in. |
| 135 size_t selected_grid_index_; |
| 136 |
| 130 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 137 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
| 131 }; | 138 }; |
| 132 | 139 |
| 133 } // namespace ash | 140 } // namespace ash |
| 134 | 141 |
| 135 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 142 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
| OLD | NEW |