OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/aura/aura_layout_manager_adapter.h" | 10 #include "ash/aura/aura_layout_manager_adapter.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return wm_root_window_controller_->workspace_controller(); | 236 return wm_root_window_controller_->workspace_controller(); |
237 } | 237 } |
238 | 238 |
239 void RootWindowController::Shutdown() { | 239 void RootWindowController::Shutdown() { |
240 WmShell::Get()->RemoveShellObserver(this); | 240 WmShell::Get()->RemoveShellObserver(this); |
241 | 241 |
242 #if defined(OS_CHROMEOS) | 242 #if defined(OS_CHROMEOS) |
243 touch_exploration_manager_.reset(); | 243 touch_exploration_manager_.reset(); |
244 #endif | 244 #endif |
245 | 245 |
246 aura::Window* root_window = GetRootWindow(); | 246 wm_root_window_controller_->ResetRootForNewWindowsIfNecessary(); |
247 WmWindow* root_shutting_down = WmWindowAura::Get(root_window); | |
248 WmShell* shell = WmShell::Get(); | |
249 // Change the target root window before closing child windows. If any child | |
250 // being removed triggers a relayout of the shelf it will try to build a | |
251 // window list adding windows from the target root window's containers which | |
252 // may have already gone away. | |
253 if (shell->GetRootWindowForNewWindows() == root_shutting_down) { | |
254 // The root window for new windows is being destroyed. Switch to the primary | |
255 // root window if possible. | |
256 WmWindow* primary_root = shell->GetPrimaryRootWindow(); | |
257 shell->set_root_window_for_new_windows( | |
258 primary_root == root_shutting_down ? nullptr : primary_root); | |
259 } | |
260 | 247 |
261 CloseChildWindows(); | 248 CloseChildWindows(); |
| 249 aura::Window* root_window = GetRootWindow(); |
262 GetRootWindowSettings(root_window)->controller = NULL; | 250 GetRootWindowSettings(root_window)->controller = NULL; |
263 // Forget with the display ID so that display lookup | 251 // Forget with the display ID so that display lookup |
264 // ends up with invalid display. | 252 // ends up with invalid display. |
265 GetRootWindowSettings(root_window)->display_id = | 253 GetRootWindowSettings(root_window)->display_id = |
266 display::Display::kInvalidDisplayID; | 254 display::Display::kInvalidDisplayID; |
267 ash_host_->PrepareForShutdown(); | 255 ash_host_->PrepareForShutdown(); |
268 | 256 |
269 system_wallpaper_.reset(); | 257 system_wallpaper_.reset(); |
270 aura::client::SetScreenPositionClient(root_window, NULL); | 258 aura::client::SetScreenPositionClient(root_window, NULL); |
271 } | 259 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // TODO(jamescook): Move this into WmShelf. | 317 // TODO(jamescook): Move this into WmShelf. |
330 wm_shelf_aura_->shelf_widget()->SetShelfVisibility(true); | 318 wm_shelf_aura_->shelf_widget()->SetShelfVisibility(true); |
331 wm_shelf_aura_->shelf_widget()->status_area_widget()->Show(); | 319 wm_shelf_aura_->shelf_widget()->status_area_widget()->Show(); |
332 } | 320 } |
333 | 321 |
334 void RootWindowController::CreateShelf() { | 322 void RootWindowController::CreateShelf() { |
335 if (wm_shelf_aura_->IsShelfInitialized()) | 323 if (wm_shelf_aura_->IsShelfInitialized()) |
336 return; | 324 return; |
337 wm_shelf_aura_->InitializeShelf(); | 325 wm_shelf_aura_->InitializeShelf(); |
338 | 326 |
339 if (panel_layout_manager_) | 327 if (panel_layout_manager()) |
340 panel_layout_manager_->SetShelf(wm_shelf_aura_.get()); | 328 panel_layout_manager()->SetShelf(wm_shelf_aura_.get()); |
341 if (docked_layout_manager_) { | 329 if (docked_window_layout_manager()) { |
342 docked_layout_manager_->SetShelf(wm_shelf_aura_.get()); | 330 docked_window_layout_manager()->SetShelf(wm_shelf_aura_.get()); |
343 if (wm_shelf_aura_->shelf_layout_manager()) { | 331 if (wm_shelf_aura_->shelf_layout_manager()) { |
344 docked_layout_manager_->AddObserver( | 332 docked_window_layout_manager()->AddObserver( |
345 wm_shelf_aura_->shelf_layout_manager()); | 333 wm_shelf_aura_->shelf_layout_manager()); |
346 } | 334 } |
347 } | 335 } |
348 | 336 |
349 // Notify shell observers that the shelf has been created. | 337 // Notify shell observers that the shelf has been created. |
350 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will | 338 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will |
351 // require changing AttachedPanelWidgetTargeter's access to WmShelf. | 339 // require changing AttachedPanelWidgetTargeter's access to WmShelf. |
352 WmShell::Get()->NotifyShelfCreatedForRootWindow( | 340 WmShell::Get()->NotifyShelfCreatedForRootWindow( |
353 WmWindowAura::Get(GetRootWindow())); | 341 WmWindowAura::Get(GetRootWindow())); |
354 | 342 |
(...skipping 26 matching lines...) Expand all Loading... |
381 // Make sure the wallpaper is visible. | 369 // Make sure the wallpaper is visible. |
382 system_wallpaper_->SetColor(SK_ColorBLACK); | 370 system_wallpaper_->SetColor(SK_ColorBLACK); |
383 #if defined(OS_CHROMEOS) | 371 #if defined(OS_CHROMEOS) |
384 boot_splash_screen_.reset(); | 372 boot_splash_screen_.reset(); |
385 #endif | 373 #endif |
386 } | 374 } |
387 | 375 |
388 void RootWindowController::CloseChildWindows() { | 376 void RootWindowController::CloseChildWindows() { |
389 mouse_event_target_.reset(); | 377 mouse_event_target_.reset(); |
390 | 378 |
391 // Remove observer as deactivating keyboard causes |docked_layout_manager_| | 379 // Remove observer as deactivating keyboard causes |
392 // to fire notifications. | 380 // docked_window_layout_manager() to fire notifications. |
393 if (docked_layout_manager_ && wm_shelf_aura_->shelf_layout_manager()) { | 381 if (docked_window_layout_manager() && |
394 docked_layout_manager_->RemoveObserver( | 382 wm_shelf_aura_->shelf_layout_manager()) { |
| 383 docked_window_layout_manager()->RemoveObserver( |
395 wm_shelf_aura_->shelf_layout_manager()); | 384 wm_shelf_aura_->shelf_layout_manager()); |
396 } | 385 } |
397 | 386 |
398 // Deactivate keyboard container before closing child windows and shutting | 387 // Deactivate keyboard container before closing child windows and shutting |
399 // down associated layout managers. | 388 // down associated layout managers. |
400 DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); | 389 DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
401 | 390 |
402 // panel_layout_manager_ needs to be shut down before windows are destroyed. | 391 wm_root_window_controller_->CloseChildWindows(); |
403 if (panel_layout_manager_) { | |
404 panel_layout_manager_->Shutdown(); | |
405 panel_layout_manager_ = NULL; | |
406 } | |
407 // docked_layout_manager_ needs to be shut down before windows are destroyed. | |
408 if (docked_layout_manager_) { | |
409 docked_layout_manager_->Shutdown(); | |
410 docked_layout_manager_ = NULL; | |
411 } | |
412 wm_shelf_aura_->ShutdownShelfWidget(); | |
413 | 392 |
414 wm_root_window_controller_->DeleteWorkspaceController(); | 393 aura::client::SetDragDropClient(GetRootWindow(), nullptr); |
415 | 394 aura::client::SetTooltipClient(GetRootWindow(), nullptr); |
416 // Explicitly destroy top level windows. We do this as during part of | |
417 // destruction such windows may query the RootWindow for state. | |
418 aura::Window* root_window = GetRootWindow(); | |
419 aura::WindowTracker non_toplevel_windows; | |
420 non_toplevel_windows.Add(root_window); | |
421 while (!non_toplevel_windows.windows().empty()) { | |
422 const aura::Window* non_toplevel_window = | |
423 *non_toplevel_windows.windows().begin(); | |
424 non_toplevel_windows.Remove(const_cast<aura::Window*>(non_toplevel_window)); | |
425 aura::WindowTracker toplevel_windows; | |
426 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { | |
427 aura::Window* child = non_toplevel_window->children()[i]; | |
428 if (!child->owned_by_parent()) | |
429 continue; | |
430 if (child->delegate()) | |
431 toplevel_windows.Add(child); | |
432 else | |
433 non_toplevel_windows.Add(child); | |
434 } | |
435 while (!toplevel_windows.windows().empty()) | |
436 delete *toplevel_windows.windows().begin(); | |
437 } | |
438 // And then remove the containers. | |
439 while (!root_window->children().empty()) { | |
440 aura::Window* window = root_window->children()[0]; | |
441 if (window->owned_by_parent()) { | |
442 delete window; | |
443 } else { | |
444 root_window->RemoveChild(window); | |
445 } | |
446 } | |
447 | |
448 wm_shelf_aura_->DestroyShelfWidget(); | |
449 | |
450 // CloseChildWindows may be called twice during the shutdown of ash unittests. | |
451 // Avoid notifying WmShelf that the shelf has been destroyed twice. | |
452 if (wm_shelf_aura_->IsShelfInitialized()) | |
453 wm_shelf_aura_->ShutdownShelf(); | |
454 | |
455 aura::client::SetDragDropClient(root_window, nullptr); | |
456 aura::client::SetTooltipClient(root_window, nullptr); | |
457 } | 395 } |
458 | 396 |
459 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 397 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
460 wm_root_window_controller_->MoveWindowsTo(WmWindowAura::Get(dst)); | 398 wm_root_window_controller_->MoveWindowsTo(WmWindowAura::Get(dst)); |
461 } | 399 } |
462 | 400 |
463 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 401 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
464 return wm_shelf_aura_->shelf_layout_manager(); | 402 return wm_shelf_aura_->shelf_layout_manager(); |
465 } | 403 } |
466 | 404 |
(...skipping 19 matching lines...) Expand all Loading... |
486 } | 424 } |
487 | 425 |
488 void RootWindowController::ActivateKeyboard( | 426 void RootWindowController::ActivateKeyboard( |
489 keyboard::KeyboardController* keyboard_controller) { | 427 keyboard::KeyboardController* keyboard_controller) { |
490 if (!keyboard::IsKeyboardEnabled() || | 428 if (!keyboard::IsKeyboardEnabled() || |
491 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { | 429 GetContainer(kShellWindowId_VirtualKeyboardContainer)) { |
492 return; | 430 return; |
493 } | 431 } |
494 DCHECK(keyboard_controller); | 432 DCHECK(keyboard_controller); |
495 keyboard_controller->AddObserver(wm_shelf_aura_->shelf_layout_manager()); | 433 keyboard_controller->AddObserver(wm_shelf_aura_->shelf_layout_manager()); |
496 keyboard_controller->AddObserver(panel_layout_manager_); | 434 keyboard_controller->AddObserver(panel_layout_manager()); |
497 keyboard_controller->AddObserver(docked_layout_manager_); | 435 keyboard_controller->AddObserver(docked_window_layout_manager()); |
498 keyboard_controller->AddObserver(workspace_controller()->layout_manager()); | 436 keyboard_controller->AddObserver(workspace_controller()->layout_manager()); |
499 keyboard_controller->AddObserver( | 437 keyboard_controller->AddObserver( |
500 always_on_top_controller_->GetLayoutManager()); | 438 wm_root_window_controller_->always_on_top_controller() |
| 439 ->GetLayoutManager()); |
501 WmShell::Get()->NotifyVirtualKeyboardActivated(true); | 440 WmShell::Get()->NotifyVirtualKeyboardActivated(true); |
502 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 441 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
503 DCHECK(parent); | 442 DCHECK(parent); |
504 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 443 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
505 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); | 444 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer); |
506 parent->AddChild(keyboard_container); | 445 parent->AddChild(keyboard_container); |
507 } | 446 } |
508 | 447 |
509 void RootWindowController::DeactivateKeyboard( | 448 void RootWindowController::DeactivateKeyboard( |
510 keyboard::KeyboardController* keyboard_controller) { | 449 keyboard::KeyboardController* keyboard_controller) { |
511 if (!keyboard_controller || | 450 if (!keyboard_controller || |
512 !keyboard_controller->keyboard_container_initialized()) { | 451 !keyboard_controller->keyboard_container_initialized()) { |
513 return; | 452 return; |
514 } | 453 } |
515 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); | 454 aura::Window* keyboard_container = keyboard_controller->GetContainerWindow(); |
516 if (keyboard_container->GetRootWindow() == GetRootWindow()) { | 455 if (keyboard_container->GetRootWindow() == GetRootWindow()) { |
517 aura::Window* parent = | 456 aura::Window* parent = |
518 GetContainer(kShellWindowId_ImeWindowParentContainer); | 457 GetContainer(kShellWindowId_ImeWindowParentContainer); |
519 DCHECK(parent); | 458 DCHECK(parent); |
520 parent->RemoveChild(keyboard_container); | 459 parent->RemoveChild(keyboard_container); |
521 // Virtual keyboard may be deactivated while still showing, notify all | 460 // Virtual keyboard may be deactivated while still showing, notify all |
522 // observers that keyboard bounds changed to 0 before remove them. | 461 // observers that keyboard bounds changed to 0 before remove them. |
523 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); | 462 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); |
524 keyboard_controller->RemoveObserver(wm_shelf_aura_->shelf_layout_manager()); | 463 keyboard_controller->RemoveObserver(wm_shelf_aura_->shelf_layout_manager()); |
525 keyboard_controller->RemoveObserver(panel_layout_manager_); | 464 keyboard_controller->RemoveObserver(panel_layout_manager()); |
526 keyboard_controller->RemoveObserver(docked_layout_manager_); | 465 keyboard_controller->RemoveObserver(docked_window_layout_manager()); |
527 keyboard_controller->RemoveObserver( | 466 keyboard_controller->RemoveObserver( |
528 workspace_controller()->layout_manager()); | 467 workspace_controller()->layout_manager()); |
529 keyboard_controller->RemoveObserver( | 468 keyboard_controller->RemoveObserver( |
530 always_on_top_controller_->GetLayoutManager()); | 469 wm_root_window_controller_->always_on_top_controller() |
| 470 ->GetLayoutManager()); |
531 WmShell::Get()->NotifyVirtualKeyboardActivated(false); | 471 WmShell::Get()->NotifyVirtualKeyboardActivated(false); |
532 } | 472 } |
533 } | 473 } |
534 | 474 |
535 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { | 475 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { |
536 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); | 476 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer); |
537 return parent ? parent->Contains(window) : false; | 477 return parent ? parent->Contains(window) : false; |
538 } | 478 } |
539 | 479 |
540 void RootWindowController::SetTouchAccessibilityAnchorPoint( | 480 void RootWindowController::SetTouchAccessibilityAnchorPoint( |
541 const gfx::Point& anchor_point) { | 481 const gfx::Point& anchor_point) { |
542 #if defined(OS_CHROMEOS) | 482 #if defined(OS_CHROMEOS) |
543 if (touch_exploration_manager_) | 483 if (touch_exploration_manager_) |
544 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); | 484 touch_exploration_manager_->SetTouchAccessibilityAnchorPoint(anchor_point); |
545 #endif // defined(OS_CHROMEOS) | 485 #endif // defined(OS_CHROMEOS) |
546 } | 486 } |
547 | 487 |
548 //////////////////////////////////////////////////////////////////////////////// | 488 //////////////////////////////////////////////////////////////////////////////// |
549 // RootWindowController, private: | 489 // RootWindowController, private: |
550 | 490 |
551 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) | 491 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) |
552 : ash_host_(ash_host), | 492 : ash_host_(ash_host), |
553 wm_shelf_aura_(new WmShelfAura), | 493 wm_shelf_aura_(new WmShelfAura), |
554 docked_layout_manager_(NULL), | |
555 panel_layout_manager_(NULL), | |
556 touch_hud_debug_(NULL), | 494 touch_hud_debug_(NULL), |
557 touch_hud_projection_(NULL) { | 495 touch_hud_projection_(NULL) { |
558 aura::Window* root_window = GetRootWindow(); | 496 aura::Window* root_window = GetRootWindow(); |
559 GetRootWindowSettings(root_window)->controller = this; | 497 GetRootWindowSettings(root_window)->controller = this; |
560 | 498 |
561 // Has to happen after this is set as |controller| of RootWindowSettings. | 499 // Has to happen after this is set as |controller| of RootWindowSettings. |
562 wm_root_window_controller_ = WmRootWindowControllerAura::Get(root_window); | 500 wm_root_window_controller_ = WmRootWindowControllerAura::Get(root_window); |
563 | 501 |
564 stacking_controller_.reset(new StackingController); | 502 stacking_controller_.reset(new StackingController); |
565 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); | 503 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 | 543 |
606 #if defined(OS_CHROMEOS) | 544 #if defined(OS_CHROMEOS) |
607 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 545 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
608 switches::kAshDisableTouchExplorationMode)) { | 546 switches::kAshDisableTouchExplorationMode)) { |
609 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); | 547 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); |
610 } | 548 } |
611 #endif | 549 #endif |
612 } | 550 } |
613 | 551 |
614 void RootWindowController::InitLayoutManagers() { | 552 void RootWindowController::InitLayoutManagers() { |
615 wm_root_window_controller_->CreateLayoutManagers(); | |
616 | |
617 aura::Window* root_window = GetRootWindow(); | |
618 | |
619 WmWindow* always_on_top_container = | |
620 WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer)); | |
621 always_on_top_controller_.reset( | |
622 new AlwaysOnTopController(always_on_top_container)); | |
623 | |
624 // Create the shelf and status area widgets. | 553 // Create the shelf and status area widgets. |
625 DCHECK(!wm_shelf_aura_->shelf_widget()); | 554 DCHECK(!wm_shelf_aura_->shelf_widget()); |
626 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); | 555 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); |
627 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); | 556 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer); |
628 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); | 557 WmWindow* wm_shelf_container = WmWindowAura::Get(shelf_container); |
629 WmWindow* wm_status_container = WmWindowAura::Get(status_container); | 558 WmWindow* wm_status_container = WmWindowAura::Get(status_container); |
630 wm_shelf_aura_->CreateShelfWidget(WmWindowAura::Get(root_window)); | 559 wm_shelf_aura_->CreateShelfWidget(WmWindowAura::Get(GetRootWindow())); |
| 560 |
| 561 wm_root_window_controller_->CreateLayoutManagers(); |
631 | 562 |
632 // Make it easier to resize windows that partially overlap the shelf. Must | 563 // Make it easier to resize windows that partially overlap the shelf. Must |
633 // occur after the ShelfLayoutManager is constructed by ShelfWidget. | 564 // occur after the ShelfLayoutManager is constructed by ShelfWidget. |
634 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( | 565 shelf_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
635 wm_shelf_container, wm_shelf_aura_.get())); | 566 wm_shelf_container, wm_shelf_aura_.get())); |
636 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( | 567 status_container->SetEventTargeter(base::MakeUnique<ShelfWindowTargeter>( |
637 wm_status_container, wm_shelf_aura_.get())); | 568 wm_status_container, wm_shelf_aura_.get())); |
638 | 569 |
639 if (!WmShell::Get() | 570 if (!WmShell::Get() |
640 ->GetSessionStateDelegate() | 571 ->GetSessionStateDelegate() |
641 ->IsActiveUserSessionStarted()) { | 572 ->IsActiveUserSessionStarted()) { |
642 // This window exists only to be a event target on login screen. | 573 // This window exists only to be a event target on login screen. |
643 // It does not have to handle events, nor be visible. | 574 // It does not have to handle events, nor be visible. |
644 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); | 575 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate)); |
645 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); | 576 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN); |
646 | 577 |
647 aura::Window* lock_wallpaper_container = | 578 aura::Window* lock_wallpaper_container = |
648 GetContainer(kShellWindowId_LockScreenWallpaperContainer); | 579 GetContainer(kShellWindowId_LockScreenWallpaperContainer); |
649 lock_wallpaper_container->AddChild(mouse_event_target_.get()); | 580 lock_wallpaper_container->AddChild(mouse_event_target_.get()); |
650 mouse_event_target_->Show(); | 581 mouse_event_target_->Show(); |
651 } | 582 } |
652 | 583 |
653 // Create Docked windows layout manager | 584 panel_container_handler_ = base::MakeUnique<PanelWindowEventHandler>(); |
654 WmWindow* docked_container = | 585 GetContainer(kShellWindowId_PanelContainer) |
655 WmWindowAura::Get(GetContainer(kShellWindowId_DockedContainer)); | 586 ->AddPreTargetHandler(panel_container_handler_.get()); |
656 docked_layout_manager_ = new DockedWindowLayoutManager(docked_container); | |
657 docked_container->SetLayoutManager(base::WrapUnique(docked_layout_manager_)); | |
658 | |
659 // Installs WmSnapLayoutManager on appropriate containers. | |
660 wm::WmSnapToPixelLayoutManager::InstallOnContainers( | |
661 WmWindowAura::Get(root_window)); | |
662 | |
663 // Create Panel layout manager | |
664 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); | |
665 WmWindow* wm_panel_container = WmWindowAura::Get(panel_container); | |
666 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); | |
667 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_)); | |
668 panel_container_handler_.reset(new PanelWindowEventHandler); | |
669 panel_container->AddPreTargetHandler(panel_container_handler_.get()); | |
670 | 587 |
671 // Install an AttachedPanelWindowTargeter on the panel container to make it | 588 // Install an AttachedPanelWindowTargeter on the panel container to make it |
672 // easier to correctly target shelf buttons with touch. | 589 // easier to correctly target shelf buttons with touch. |
673 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, | 590 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, |
674 -kResizeOutsideBoundsSize, | 591 -kResizeOutsideBoundsSize, |
675 -kResizeOutsideBoundsSize); | 592 -kResizeOutsideBoundsSize); |
676 gfx::Insets touch_extend = | 593 gfx::Insets touch_extend = |
677 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); | 594 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); |
678 panel_container->SetEventTargeter( | 595 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); |
679 std::unique_ptr<ui::EventTargeter>(new AttachedPanelWindowTargeter( | 596 panel_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
680 panel_container, mouse_extend, touch_extend, panel_layout_manager_))); | 597 new AttachedPanelWindowTargeter(panel_container, mouse_extend, |
| 598 touch_extend, panel_layout_manager()))); |
681 } | 599 } |
682 | 600 |
683 void RootWindowController::InitTouchHuds() { | 601 void RootWindowController::InitTouchHuds() { |
684 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 602 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
685 if (command_line->HasSwitch(switches::kAshTouchHud)) | 603 if (command_line->HasSwitch(switches::kAshTouchHud)) |
686 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); | 604 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); |
687 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) | 605 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) |
688 EnableTouchHudProjection(); | 606 EnableTouchHudProjection(); |
689 } | 607 } |
690 | 608 |
(...skipping 23 matching lines...) Expand all Loading... |
714 return; | 632 return; |
715 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); | 633 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); |
716 } | 634 } |
717 | 635 |
718 void RootWindowController::DisableTouchHudProjection() { | 636 void RootWindowController::DisableTouchHudProjection() { |
719 if (!touch_hud_projection_) | 637 if (!touch_hud_projection_) |
720 return; | 638 return; |
721 touch_hud_projection_->Remove(); | 639 touch_hud_projection_->Remove(); |
722 } | 640 } |
723 | 641 |
| 642 DockedWindowLayoutManager* |
| 643 RootWindowController::docked_window_layout_manager() { |
| 644 return wm_root_window_controller_->docked_window_layout_manager(); |
| 645 } |
| 646 |
| 647 PanelLayoutManager* RootWindowController::panel_layout_manager() { |
| 648 return wm_root_window_controller_->panel_layout_manager(); |
| 649 } |
| 650 |
724 void RootWindowController::OnLoginStateChanged(LoginStatus status) { | 651 void RootWindowController::OnLoginStateChanged(LoginStatus status) { |
725 wm_shelf_aura_->UpdateVisibilityState(); | 652 wm_shelf_aura_->UpdateVisibilityState(); |
726 } | 653 } |
727 | 654 |
728 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 655 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
729 if (enabled) | 656 if (enabled) |
730 EnableTouchHudProjection(); | 657 EnableTouchHudProjection(); |
731 else | 658 else |
732 DisableTouchHudProjection(); | 659 DisableTouchHudProjection(); |
733 } | 660 } |
734 | 661 |
735 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 662 RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
736 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 663 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
737 } | 664 } |
738 | 665 |
739 } // namespace ash | 666 } // namespace ash |
OLD | NEW |