Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Side by Side Diff: ash/wm/overview/window_selector.h

Issue 2012343002: Converts overview to use common ash types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/overview/window_grid.cc ('k') | ash/wm/overview/window_selector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <vector> 13 #include <vector>
14 14
15 #include "ash/ash_export.h" 15 #include "ash/ash_export.h"
16 #include "base/compiler_specific.h" 16 #include "ash/wm/common/wm_activation_observer.h"
17 #include "ash/wm/common/wm_window_observer.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/memory/scoped_vector.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "ui/aura/window_observer.h"
21 #include "ui/aura/window_tracker.h"
22 #include "ui/display/display_observer.h" 20 #include "ui/display/display_observer.h"
23 #include "ui/events/event_handler.h"
24 #include "ui/views/controls/textfield/textfield_controller.h" 21 #include "ui/views/controls/textfield/textfield_controller.h"
25 #include "ui/wm/public/activation_change_observer.h"
26
27 namespace aura {
28 class RootWindow;
29 class Window;
30 }
31
32 namespace gfx {
33 class Rect;
34 }
35
36 namespace ui {
37 class LocatedEvent;
38 }
39 22
40 namespace views { 23 namespace views {
41 class Textfield; 24 class Textfield;
42 class Widget; 25 class Widget;
43 } 26 }
44 27
45 namespace ash { 28 namespace ash {
46 class WindowSelectorDelegate; 29 class WindowSelectorDelegate;
47 class WindowSelectorItem; 30 class WindowSelectorItem;
48 class WindowSelectorTest; 31 class WindowSelectorTest;
49 class WindowGrid; 32 class WindowGrid;
50 33
51 // The WindowSelector shows a grid of all of your windows, allowing to select 34 // The WindowSelector shows a grid of all of your windows, allowing to select
52 // one by clicking or tapping on it. 35 // one by clicking or tapping on it.
53 class ASH_EXPORT WindowSelector : public display::DisplayObserver, 36 class ASH_EXPORT WindowSelector : public display::DisplayObserver,
54 public aura::WindowObserver, 37 public wm::WmWindowObserver,
55 public aura::client::ActivationChangeObserver, 38 public wm::WmActivationObserver,
56 public views::TextfieldController { 39 public views::TextfieldController {
57 public: 40 public:
58 // The distance between the top edge of the screen and the bottom edge of 41 // The distance between the top edge of the screen and the bottom edge of
59 // the text filtering textfield. 42 // the text filtering textfield.
60 static const int kTextFilterBottomEdge; 43 static const int kTextFilterBottomEdge;
61 44
62 // Returns true if the window can be selected in overview mode. 45 // Returns true if the window can be selected in overview mode.
63 static bool IsSelectable(aura::Window* window); 46 static bool IsSelectable(wm::WmWindow* window);
64 47
65 enum Direction { 48 enum Direction {
66 LEFT, 49 LEFT,
67 UP, 50 UP,
68 RIGHT, 51 RIGHT,
69 DOWN 52 DOWN
70 }; 53 };
71 54
72 typedef std::vector<aura::Window*> WindowList; 55 using WindowList = std::vector<wm::WmWindow*>;
73 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
74 56
75 explicit WindowSelector(WindowSelectorDelegate* delegate); 57 explicit WindowSelector(WindowSelectorDelegate* delegate);
76 ~WindowSelector() override; 58 ~WindowSelector() override;
77 59
78 // Initialize with the windows that can be selected. 60 // Initialize with the windows that can be selected.
79 void Init(const WindowList& windows); 61 void Init(const WindowList& windows);
80 62
81 // Perform cleanup that cannot be done in the destructor. 63 // Perform cleanup that cannot be done in the destructor.
82 void Shutdown(); 64 void Shutdown();
83 65
84 // Cancels window selection. 66 // Cancels window selection.
85 void CancelSelection(); 67 void CancelSelection();
86 68
87 // Called when the last window selector item from a grid is deleted. 69 // Called when the last window selector item from a grid is deleted.
88 void OnGridEmpty(WindowGrid* grid); 70 void OnGridEmpty(WindowGrid* grid);
89 71
90 // Activates |window|. 72 // Activates |window|.
91 void SelectWindow(aura::Window* window); 73 void SelectWindow(wm::WmWindow* window);
92 74
93 bool restoring_minimized_windows() const { 75 bool restoring_minimized_windows() const {
94 return restoring_minimized_windows_; 76 return restoring_minimized_windows_;
95 } 77 }
96 78
97 // display::DisplayObserver: 79 // display::DisplayObserver:
98 void OnDisplayAdded(const display::Display& display) override; 80 void OnDisplayAdded(const display::Display& display) override;
99 void OnDisplayRemoved(const display::Display& display) override; 81 void OnDisplayRemoved(const display::Display& display) override;
100 void OnDisplayMetricsChanged(const display::Display& display, 82 void OnDisplayMetricsChanged(const display::Display& display,
101 uint32_t metrics) override; 83 uint32_t metrics) override;
102 84
103 // aura::WindowObserver: 85 // wm::WmWindowObserver:
104 void OnWindowAdded(aura::Window* new_window) override; 86 void OnWindowTreeChanged(wm::WmWindow* window,
105 void OnWindowDestroying(aura::Window* window) override; 87 const TreeChangeParams& params) override;
88 void OnWindowDestroying(wm::WmWindow* window) override;
106 89
107 // aura::client::ActivationChangeObserver: 90 // wm::WmActivationObserver
108 void OnWindowActivated( 91 void OnWindowActivated(wm::WmWindow* gained_active,
109 aura::client::ActivationChangeObserver::ActivationReason reason, 92 wm::WmWindow* lost_active) override;
110 aura::Window* gained_active, 93 void OnAttemptToReactivateWindow(wm::WmWindow* request_active,
111 aura::Window* lost_active) override; 94 wm::WmWindow* actual_active) override;
112 void OnAttemptToReactivateWindow(aura::Window* request_active,
113 aura::Window* actual_active) override;
114 95
115 // views::TextfieldController: 96 // views::TextfieldController:
116 void ContentsChanged(views::Textfield* sender, 97 void ContentsChanged(views::Textfield* sender,
117 const base::string16& new_contents) override; 98 const base::string16& new_contents) override;
118 bool HandleKeyEvent(views::Textfield* sender, 99 bool HandleKeyEvent(views::Textfield* sender,
119 const ui::KeyEvent& key_event) override; 100 const ui::KeyEvent& key_event) override;
120 101
121 private: 102 private:
122 friend class WindowSelectorTest; 103 friend class WindowSelectorTest;
123 104
124 // Begins positioning windows such that all windows are visible on the screen. 105 // Returns the WmWindow for |text_filter_widget_|.
125 void StartOverview(); 106 wm::WmWindow* GetTextFilterWidgetWindow();
126 107
127 // Position all of the windows in the overview. 108 // Position all of the windows in the overview.
128 void PositionWindows(bool animate); 109 void PositionWindows(bool animate);
129 110
130 // Repositions and resizes |text_filter_widget_| on 111 // Repositions and resizes |text_filter_widget_| on
131 // DisplayMetricsChanged event. 112 // DisplayMetricsChanged event.
132 void RepositionTextFilterOnDisplayMetricsChange(); 113 void RepositionTextFilterOnDisplayMetricsChange();
133 114
134 // |focus|, restores focus to the stored window. 115 // |focus|, restores focus to the stored window.
135 void ResetFocusRestoreWindow(bool focus); 116 void ResetFocusRestoreWindow(bool focus);
136 117
137 // Helper function that moves the selection widget to |direction| on the 118 // Helper function that moves the selection widget to |direction| on the
138 // corresponding window grid. 119 // corresponding window grid.
139 void Move(Direction direction, bool animate); 120 void Move(Direction direction, bool animate);
140 121
141 // Removes all observers that were registered during construction and/or 122 // Removes all observers that were registered during construction and/or
142 // initialization. 123 // initialization.
143 void RemoveAllObservers(); 124 void RemoveAllObservers();
144 125
145 // Tracks observed windows. 126 // Tracks observed windows.
146 std::set<aura::Window*> observed_windows_; 127 std::set<wm::WmWindow*> observed_windows_;
147 128
148 // Weak pointer to the selector delegate which will be called when a 129 // Weak pointer to the selector delegate which will be called when a
149 // selection is made. 130 // selection is made.
150 WindowSelectorDelegate* delegate_; 131 WindowSelectorDelegate* delegate_;
151 132
152 // A weak pointer to the window which was focused on beginning window 133 // A weak pointer to the window which was focused on beginning window
153 // selection. If window selection is canceled the focus should be restored to 134 // selection. If window selection is canceled the focus should be restored to
154 // this window. 135 // this window.
155 aura::Window* restore_focus_window_; 136 wm::WmWindow* restore_focus_window_;
156 137
157 // True when performing operations that may cause window activations. This is 138 // True when performing operations that may cause window activations. This is
158 // used to prevent handling the resulting expected activation. 139 // used to prevent handling the resulting expected activation.
159 bool ignore_activations_; 140 bool ignore_activations_;
160 141
161 // List of all the window overview grids, one for each root window. 142 // List of all the window overview grids, one for each root window.
162 ScopedVector<WindowGrid> grid_list_; 143 std::vector<std::unique_ptr<WindowGrid>> grid_list_;
163 144
164 // Tracks the index of the root window the selection widget is in. 145 // Tracks the index of the root window the selection widget is in.
165 size_t selected_grid_index_; 146 size_t selected_grid_index_;
166 147
167 // The following variables are used for metric collection purposes. All of 148 // The following variables are used for metric collection purposes. All of
168 // them refer to this particular overview session and are not cumulative: 149 // them refer to this particular overview session and are not cumulative:
169 // The time when overview was started. 150 // The time when overview was started.
170 base::Time overview_start_time_; 151 base::Time overview_start_time_;
171 152
172 // The number of arrow key presses. 153 // The number of arrow key presses.
(...skipping 20 matching lines...) Expand all
193 // Tracks whether minimized windows are currently being restored for overview 174 // Tracks whether minimized windows are currently being restored for overview
194 // mode. 175 // mode.
195 bool restoring_minimized_windows_; 176 bool restoring_minimized_windows_;
196 177
197 DISALLOW_COPY_AND_ASSIGN(WindowSelector); 178 DISALLOW_COPY_AND_ASSIGN(WindowSelector);
198 }; 179 };
199 180
200 } // namespace ash 181 } // namespace ash
201 182
202 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ 183 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
OLDNEW
« no previous file with comments | « ash/wm/overview/window_grid.cc ('k') | ash/wm/overview/window_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698