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

Side by Side Diff: athena/wm/window_manager_impl.cc

Issue 635223004: Refactor SetInOverview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove bug fixes, leaving only refactor Created 6 years, 2 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 | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "athena/wm/window_manager_impl.h" 5 #include "athena/wm/window_manager_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "athena/screen/public/screen_manager.h" 9 #include "athena/screen/public/screen_manager.h"
10 #include "athena/util/container_priorities.h" 10 #include "athena/util/container_priorities.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Relayout so that windows are maximzied. 186 // Relayout so that windows are maximzied.
187 container_->layout_manager()->OnWindowResized(); 187 container_->layout_manager()->OnWindowResized();
188 } else if (split_view_controller_->CanActivateSplitViewMode()) { 188 } else if (split_view_controller_->CanActivateSplitViewMode()) {
189 FOR_EACH_OBSERVER(WindowManagerObserver, 189 FOR_EACH_OBSERVER(WindowManagerObserver,
190 observers_, 190 observers_,
191 OnSplitViewModeEnter()); 191 OnSplitViewModeEnter());
192 split_view_controller_->ActivateSplitMode(NULL, NULL, NULL); 192 split_view_controller_->ActivateSplitMode(NULL, NULL, NULL);
193 } 193 }
194 } 194 }
195 195
196 void WindowManagerImpl::ToggleOverview() { 196 void WindowManagerImpl::EnterOverview() {
197 if (IsOverviewModeActive()) { 197 if (IsOverviewModeActive())
198 SetInOverview(false); 198 return;
199 199
200 // Activate the window which was active prior to entering overview. 200 bezel_controller_->set_left_right_delegate(NULL);
201 const aura::Window::Windows windows = 201 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter());
202 window_list_provider_->GetWindowList();
203 if (!windows.empty()) {
204 aura::Window* window = windows.back();
205 // Show the window in case the exit overview animation has finished and
206 // |window| was hidden.
207 window->Show();
208 202
209 wm::ActivateWindow(window); 203 // Note: The window_list_provider_ resembles the exact window list of the
210 } 204 // container, so no re-stacking is required before showing the OverviewMode.
211 } else { 205 overview_ = WindowOverviewMode::Create(
212 SetInOverview(true); 206 container_.get(), window_list_provider_.get(),
207 split_view_controller_.get(), this);
208 }
209
210 // Will reactivate the previously active window
pkotwicz 2014/10/09 21:13:59 Nit: This comment should be in the window_manager.
Greg Levin 2014/10/10 21:13:45 Done.
211 void WindowManagerImpl::ExitOverview() {
212 if (!IsOverviewModeActive())
213 return;
214
215 ExitOverviewNoActivate();
216
217 // Activate the window which was active prior to entering overview.
218 const aura::Window::Windows windows = window_list_provider_->GetWindowList();
219 if (!windows.empty()) {
220 aura::Window* window_to_activate = windows.back();
221
222 // Show the window in case the exit overview animation has finished and
223 // |window| was hidden.
224 window_to_activate->Show();
225 wm::ActivateWindow(window_to_activate);
213 } 226 }
214 } 227 }
215 228
216 bool WindowManagerImpl::IsOverviewModeActive() { 229 bool WindowManagerImpl::IsOverviewModeActive() {
217 return overview_; 230 return overview_;
218 } 231 }
219 232
220 void WindowManagerImpl::SetInOverview(bool active) { 233 // Only handles overview mode, will not actiavte any windows
pkotwicz 2014/10/09 21:13:59 Nit: The comment should be in the .h file For the
Greg Levin 2014/10/10 21:13:45 Done.
221 bool in_overview = !!overview_; 234 void WindowManagerImpl::ExitOverviewNoActivate() {
222 if (active == in_overview) 235 if (!IsOverviewModeActive())
223 return; 236 return;
224 237
225 bezel_controller_->set_left_right_delegate( 238 bezel_controller_->set_left_right_delegate(split_view_controller_.get());
226 active ? NULL : split_view_controller_.get()); 239 overview_.reset();
227 if (active) { 240 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit());
228 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter());
229
230 // Note: The window_list_provider_ resembles the exact window list of the
231 // container, so no re-stacking is required before showing the OverviewMode.
232 overview_ = WindowOverviewMode::Create(
233 container_.get(), window_list_provider_.get(),
234 split_view_controller_.get(), this);
235 } else {
236 overview_.reset();
237 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit());
238 }
239 } 241 }
240 242
241 void WindowManagerImpl::InstallAccelerators() { 243 void WindowManagerImpl::InstallAccelerators() {
242 const AcceleratorData accelerator_data[] = { 244 const AcceleratorData accelerator_data[] = {
243 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, 245 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW,
244 AF_NONE}, 246 AF_NONE},
245 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, 247 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN,
246 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, 248 CMD_TOGGLE_SPLIT_VIEW, AF_NONE},
247 }; 249 };
248 AcceleratorManager::Get()->RegisterAccelerators( 250 AcceleratorManager::Get()->RegisterAccelerators(
(...skipping 10 matching lines...) Expand all
259 261
260 void WindowManagerImpl::ToggleSplitViewForTest() { 262 void WindowManagerImpl::ToggleSplitViewForTest() {
261 ToggleSplitView(); 263 ToggleSplitView();
262 } 264 }
263 265
264 WindowListProvider* WindowManagerImpl::GetWindowListProvider() { 266 WindowListProvider* WindowManagerImpl::GetWindowListProvider() {
265 return window_list_provider_.get(); 267 return window_list_provider_.get();
266 } 268 }
267 269
268 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 270 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
269 SetInOverview(false); 271 ExitOverviewNoActivate();
270 272
271 // Show the window in case the exit overview animation has finished and 273 // Show the window in case the exit overview animation has finished and
272 // |window| was hidden. 274 // |window| was hidden.
273 window->Show(); 275 window->Show();
274
pkotwicz 2014/10/09 21:13:59 Nit: Keep the white space. In this case, it is am
Greg Levin 2014/10/10 21:13:45 Done.
275 wm::ActivateWindow(window); 276 wm::ActivateWindow(window);
276 277
277 if (split_view_controller_->IsSplitViewModeActive()) { 278 if (split_view_controller_->IsSplitViewModeActive()) {
278 split_view_controller_->DeactivateSplitMode(); 279 split_view_controller_->DeactivateSplitMode();
279 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); 280 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit());
280 } 281 }
281 // If |window| does not have the size of the work-area, then make sure it is 282 // If |window| does not have the size of the work-area, then make sure it is
282 // resized. 283 // resized.
283 const gfx::Size work_area = 284 const gfx::Size work_area =
284 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); 285 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
(...skipping 13 matching lines...) Expand all
298 base::Unretained(window), 299 base::Unretained(window),
299 desired_bounds, 300 desired_bounds,
300 gfx::Transform()))); 301 gfx::Transform())));
301 window->SetTransform(transform); 302 window->SetTransform(transform);
302 } 303 }
303 } 304 }
304 305
305 void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left, 306 void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left,
306 aura::Window* right, 307 aura::Window* right,
307 aura::Window* to_activate) { 308 aura::Window* to_activate) {
308 SetInOverview(false); 309 ExitOverviewNoActivate();
309 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); 310 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter());
310 split_view_controller_->ActivateSplitMode(left, right, to_activate); 311 split_view_controller_->ActivateSplitMode(left, right, to_activate);
311 } 312 }
312 313
313 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 314 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
314 if (window == container_) 315 if (window == container_)
315 container_.reset(); 316 container_.reset();
316 } 317 }
317 318
318 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { 319 bool WindowManagerImpl::IsCommandEnabled(int command_id) const {
319 return true; 320 return true;
320 } 321 }
321 322
322 bool WindowManagerImpl::OnAcceleratorFired(int command_id, 323 bool WindowManagerImpl::OnAcceleratorFired(int command_id,
323 const ui::Accelerator& accelerator) { 324 const ui::Accelerator& accelerator) {
324 switch (command_id) { 325 switch (command_id) {
325 case CMD_TOGGLE_OVERVIEW: 326 case CMD_TOGGLE_OVERVIEW:
326 ToggleOverview(); 327 if (IsOverviewModeActive())
328 ExitOverview();
329 else
330 EnterOverview();
327 break; 331 break;
328 case CMD_TOGGLE_SPLIT_VIEW: 332 case CMD_TOGGLE_SPLIT_VIEW:
329 ToggleSplitView(); 333 ToggleSplitView();
330 break; 334 break;
331 } 335 }
332 return true; 336 return true;
333 } 337 }
334 338
335 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { 339 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) {
336 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); 340 const aura::Window::Windows& windows = window_list_provider_->GetWindowList();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 DCHECK(!instance); 429 DCHECK(!instance);
426 } 430 }
427 431
428 // static 432 // static
429 WindowManager* WindowManager::Get() { 433 WindowManager* WindowManager::Get() {
430 DCHECK(instance); 434 DCHECK(instance);
431 return instance; 435 return instance;
432 } 436 }
433 437
434 } // namespace athena 438 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698