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

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

Issue 2087153003: Moves common code in ash/wm/overview to ash/common/wm/overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <memory>
12 #include <set>
13 #include <vector>
14
15 #include "ash/ash_export.h"
16 #include "ash/common/wm_activation_observer.h"
17 #include "ash/common/wm_window_observer.h"
18 #include "base/macros.h"
19 #include "base/time/time.h"
20 #include "ui/display/display_observer.h"
21 #include "ui/gfx/image/image_skia.h"
22 #include "ui/views/controls/textfield/textfield_controller.h"
23
24 namespace views {
25 class Textfield;
26 class Widget;
27 }
28
29 namespace ash {
30 class WindowSelectorDelegate;
31 class WindowSelectorItem;
32 class WindowSelectorTest;
33 class WindowGrid;
34
35 // The WindowSelector shows a grid of all of your windows, allowing to select
36 // one by clicking or tapping on it.
37 class ASH_EXPORT WindowSelector : public display::DisplayObserver,
38 public WmWindowObserver,
39 public WmActivationObserver,
40 public views::TextfieldController {
41 public:
42 // Returns true if the window can be selected in overview mode.
43 static bool IsSelectable(WmWindow* window);
44
45 enum Direction {
46 LEFT,
47 UP,
48 RIGHT,
49 DOWN
50 };
51
52 using WindowList = std::vector<WmWindow*>;
53
54 explicit WindowSelector(WindowSelectorDelegate* delegate);
55 ~WindowSelector() override;
56
57 // Initialize with the windows that can be selected.
58 void Init(const WindowList& windows);
59
60 // Perform cleanup that cannot be done in the destructor.
61 void Shutdown();
62
63 // Cancels window selection.
64 void CancelSelection();
65
66 // Called when the last window selector item from a grid is deleted.
67 void OnGridEmpty(WindowGrid* grid);
68
69 // Activates |window|.
70 void SelectWindow(WmWindow* window);
71
72 bool restoring_minimized_windows() const {
73 return restoring_minimized_windows_;
74 }
75
76 int text_filter_bottom() { return text_filter_bottom_; }
77
78 // display::DisplayObserver:
79 void OnDisplayAdded(const display::Display& display) override;
80 void OnDisplayRemoved(const display::Display& display) override;
81 void OnDisplayMetricsChanged(const display::Display& display,
82 uint32_t metrics) override;
83
84 // WmWindowObserver:
85 void OnWindowTreeChanged(WmWindow* window,
86 const TreeChangeParams& params) override;
87 void OnWindowDestroying(WmWindow* window) override;
88
89 // WmActivationObserver
90 void OnWindowActivated(WmWindow* gained_active,
91 WmWindow* lost_active) override;
92 void OnAttemptToReactivateWindow(WmWindow* request_active,
93 WmWindow* actual_active) override;
94
95 // views::TextfieldController:
96 void ContentsChanged(views::Textfield* sender,
97 const base::string16& new_contents) override;
98 bool HandleKeyEvent(views::Textfield* sender,
99 const ui::KeyEvent& key_event) override;
100
101 private:
102 friend class WindowSelectorTest;
103
104 // Returns the WmWindow for |text_filter_widget_|.
105 WmWindow* GetTextFilterWidgetWindow();
106
107 // Position all of the windows in the overview.
108 void PositionWindows(bool animate);
109
110 // Repositions and resizes |text_filter_widget_| on
111 // DisplayMetricsChanged event.
112 void RepositionTextFilterOnDisplayMetricsChange();
113
114 // |focus|, restores focus to the stored window.
115 void ResetFocusRestoreWindow(bool focus);
116
117 // Helper function that moves the selection widget to |direction| on the
118 // corresponding window grid.
119 void Move(Direction direction, bool animate);
120
121 // Removes all observers that were registered during construction and/or
122 // initialization.
123 void RemoveAllObservers();
124
125 // Tracks observed windows.
126 std::set<WmWindow*> observed_windows_;
127
128 // Weak pointer to the selector delegate which will be called when a
129 // selection is made.
130 WindowSelectorDelegate* delegate_;
131
132 // A weak pointer to the window which was focused on beginning window
133 // selection. If window selection is canceled the focus should be restored to
134 // this window.
135 WmWindow* restore_focus_window_;
136
137 // True when performing operations that may cause window activations. This is
138 // used to prevent handling the resulting expected activation.
139 bool ignore_activations_;
140
141 // List of all the window overview grids, one for each root window.
142 std::vector<std::unique_ptr<WindowGrid>> grid_list_;
143
144 // Tracks the index of the root window the selection widget is in.
145 size_t selected_grid_index_;
146
147 // The following variables are used for metric collection purposes. All of
148 // them refer to this particular overview session and are not cumulative:
149 // The time when overview was started.
150 base::Time overview_start_time_;
151
152 // The number of arrow key presses.
153 size_t num_key_presses_;
154
155 // The number of items in the overview.
156 size_t num_items_;
157
158 // Indicates if we are showing the selection widget.
159 bool showing_selection_widget_;
160
161 // Window text filter widget. As the user writes on it, we filter the items
162 // in the overview. It is also responsible for handling overview key events,
163 // such as enter key to select.
164 std::unique_ptr<views::Widget> text_filter_widget_;
165
166 // Image used for text filter textfield.
167 gfx::ImageSkia search_image_;
168
169 // The current length of the string entered into the text filtering textfield.
170 size_t text_filter_string_length_;
171
172 // The number of times the text filtering textfield has been cleared of text
173 // during this overview mode session.
174 size_t num_times_textfield_cleared_;
175
176 // Tracks whether minimized windows are currently being restored for overview
177 // mode.
178 bool restoring_minimized_windows_;
179
180 // The distance between the top edge of the screen and the bottom edge of
181 // the text filtering textfield.
182 int text_filter_bottom_;
183
184 DISALLOW_COPY_AND_ASSIGN(WindowSelector);
185 };
186
187 } // namespace ash
188
189 #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