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/ash_constants.h" | 10 #include "ash/ash_constants.h" |
11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
12 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/desktop_background/desktop_background_controller.h" |
13 #include "ash/desktop_background/desktop_background_widget_controller.h" | 13 #include "ash/desktop_background/desktop_background_widget_controller.h" |
14 #include "ash/desktop_background/user_wallpaper_delegate.h" | 14 #include "ash/desktop_background/user_wallpaper_delegate.h" |
15 #include "ash/display/display_manager.h" | 15 #include "ash/display/display_manager.h" |
16 #include "ash/focus_cycler.h" | 16 #include "ash/focus_cycler.h" |
17 #include "ash/high_contrast/high_contrast_controller.h" | 17 #include "ash/high_contrast/high_contrast_controller.h" |
| 18 #include "ash/host/ash_window_tree_host.h" |
18 #include "ash/root_window_settings.h" | 19 #include "ash/root_window_settings.h" |
19 #include "ash/session_state_delegate.h" | 20 #include "ash/session_state_delegate.h" |
20 #include "ash/shelf/shelf_layout_manager.h" | 21 #include "ash/shelf/shelf_layout_manager.h" |
21 #include "ash/shelf/shelf_types.h" | 22 #include "ash/shelf/shelf_types.h" |
22 #include "ash/shelf/shelf_widget.h" | 23 #include "ash/shelf/shelf_widget.h" |
23 #include "ash/shell.h" | 24 #include "ash/shell.h" |
24 #include "ash/shell_delegate.h" | 25 #include "ash/shell_delegate.h" |
25 #include "ash/shell_factory.h" | 26 #include "ash/shell_factory.h" |
26 #include "ash/shell_window_ids.h" | 27 #include "ash/shell_window_ids.h" |
27 #include "ash/switchable_windows.h" | 28 #include "ash/switchable_windows.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 return false; | 252 return false; |
252 } | 253 } |
253 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {} | 254 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {} |
254 | 255 |
255 private: | 256 private: |
256 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); | 257 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); |
257 }; | 258 }; |
258 | 259 |
259 } // namespace | 260 } // namespace |
260 | 261 |
261 void RootWindowController::CreateForPrimaryDisplay(aura::WindowTreeHost* host) { | 262 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) { |
262 RootWindowController* controller = new RootWindowController(host); | 263 RootWindowController* controller = new RootWindowController(host); |
263 controller->Init(RootWindowController::PRIMARY, | 264 controller->Init(RootWindowController::PRIMARY, |
264 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot()); | 265 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot()); |
265 } | 266 } |
266 | 267 |
267 void RootWindowController::CreateForSecondaryDisplay( | 268 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { |
268 aura::WindowTreeHost* host) { | |
269 RootWindowController* controller = new RootWindowController(host); | 269 RootWindowController* controller = new RootWindowController(host); |
270 controller->Init(RootWindowController::SECONDARY, false /* first run */); | 270 controller->Init(RootWindowController::SECONDARY, false /* first run */); |
271 } | 271 } |
272 | 272 |
273 void RootWindowController::CreateForVirtualKeyboardDisplay( | 273 void RootWindowController::CreateForVirtualKeyboardDisplay( |
274 aura::WindowTreeHost* host) { | 274 AshWindowTreeHost* host) { |
275 RootWindowController* controller = new RootWindowController(host); | 275 RootWindowController* controller = new RootWindowController(host); |
276 controller->Init(RootWindowController::VIRTUAL_KEYBOARD, | 276 controller->Init(RootWindowController::VIRTUAL_KEYBOARD, |
277 false /* first run */); | 277 false /* first run */); |
278 } | 278 } |
279 | 279 |
280 // static | 280 // static |
281 RootWindowController* RootWindowController::ForShelf(aura::Window* window) { | 281 RootWindowController* RootWindowController::ForShelf(aura::Window* window) { |
282 return GetRootWindowController(window->GetRootWindow()); | 282 return GetRootWindowController(window->GetRootWindow()); |
283 } | 283 } |
284 | 284 |
(...skipping 12 matching lines...) Expand all Loading... |
297 aura::Window* RootWindowController::GetContainerForWindow( | 297 aura::Window* RootWindowController::GetContainerForWindow( |
298 aura::Window* window) { | 298 aura::Window* window) { |
299 aura::Window* container = window->parent(); | 299 aura::Window* container = window->parent(); |
300 while (container && container->type() != ui::wm::WINDOW_TYPE_UNKNOWN) | 300 while (container && container->type() != ui::wm::WINDOW_TYPE_UNKNOWN) |
301 container = container->parent(); | 301 container = container->parent(); |
302 return container; | 302 return container; |
303 } | 303 } |
304 | 304 |
305 RootWindowController::~RootWindowController() { | 305 RootWindowController::~RootWindowController() { |
306 Shutdown(); | 306 Shutdown(); |
307 host_.reset(); | 307 ash_host_.reset(); |
308 // The CaptureClient needs to be around for as long as the RootWindow is | 308 // The CaptureClient needs to be around for as long as the RootWindow is |
309 // valid. | 309 // valid. |
310 capture_client_.reset(); | 310 capture_client_.reset(); |
311 } | 311 } |
312 | 312 |
| 313 aura::WindowTreeHost* RootWindowController::GetHost() { |
| 314 return ash_host_->AsWindowTreeHost(); |
| 315 } |
| 316 |
| 317 const aura::WindowTreeHost* RootWindowController::GetHost() const { |
| 318 return ash_host_->AsWindowTreeHost(); |
| 319 } |
| 320 |
| 321 aura::Window* RootWindowController::GetRootWindow() { |
| 322 return GetHost()->window(); |
| 323 } |
| 324 |
| 325 const aura::Window* RootWindowController::GetRootWindow() const { |
| 326 return GetHost()->window(); |
| 327 } |
| 328 |
313 void RootWindowController::SetWallpaperController( | 329 void RootWindowController::SetWallpaperController( |
314 DesktopBackgroundWidgetController* controller) { | 330 DesktopBackgroundWidgetController* controller) { |
315 wallpaper_controller_.reset(controller); | 331 wallpaper_controller_.reset(controller); |
316 } | 332 } |
317 | 333 |
318 void RootWindowController::SetAnimatingWallpaperController( | 334 void RootWindowController::SetAnimatingWallpaperController( |
319 AnimatingDesktopController* controller) { | 335 AnimatingDesktopController* controller) { |
320 if (animating_wallpaper_controller_.get()) | 336 if (animating_wallpaper_controller_.get()) |
321 animating_wallpaper_controller_->StopAnimating(); | 337 animating_wallpaper_controller_->StopAnimating(); |
322 animating_wallpaper_controller_.reset(controller); | 338 animating_wallpaper_controller_.reset(controller); |
323 } | 339 } |
324 | 340 |
325 void RootWindowController::Shutdown() { | 341 void RootWindowController::Shutdown() { |
326 Shell::GetInstance()->RemoveShellObserver(this); | 342 Shell::GetInstance()->RemoveShellObserver(this); |
327 | 343 |
328 if (animating_wallpaper_controller_.get()) | 344 if (animating_wallpaper_controller_.get()) |
329 animating_wallpaper_controller_->StopAnimating(); | 345 animating_wallpaper_controller_->StopAnimating(); |
330 wallpaper_controller_.reset(); | 346 wallpaper_controller_.reset(); |
331 animating_wallpaper_controller_.reset(); | 347 animating_wallpaper_controller_.reset(); |
332 | 348 aura::Window* root_window = GetRootWindow(); |
333 // Change the target root window before closing child windows. If any child | 349 // Change the target root window before closing child windows. If any child |
334 // being removed triggers a relayout of the shelf it will try to build a | 350 // being removed triggers a relayout of the shelf it will try to build a |
335 // window list adding windows from the target root window's containers which | 351 // window list adding windows from the target root window's containers which |
336 // may have already gone away. | 352 // may have already gone away. |
337 if (Shell::GetTargetRootWindow() == root_window()) { | 353 if (Shell::GetTargetRootWindow() == root_window) { |
338 Shell::GetInstance()->set_target_root_window( | 354 Shell::GetInstance()->set_target_root_window( |
339 Shell::GetPrimaryRootWindow() == root_window() ? | 355 Shell::GetPrimaryRootWindow() == root_window |
340 NULL : Shell::GetPrimaryRootWindow()); | 356 ? NULL |
| 357 : Shell::GetPrimaryRootWindow()); |
341 } | 358 } |
342 | 359 |
343 CloseChildWindows(); | 360 CloseChildWindows(); |
344 GetRootWindowSettings(root_window())->controller = NULL; | 361 GetRootWindowSettings(root_window)->controller = NULL; |
345 screen_dimmer_.reset(); | 362 screen_dimmer_.reset(); |
346 workspace_controller_.reset(); | 363 workspace_controller_.reset(); |
347 // Forget with the display ID so that display lookup | 364 // Forget with the display ID so that display lookup |
348 // ends up with invalid display. | 365 // ends up with invalid display. |
349 GetRootWindowSettings(root_window())->display_id = | 366 GetRootWindowSettings(root_window)->display_id = |
350 gfx::Display::kInvalidDisplayID; | 367 gfx::Display::kInvalidDisplayID; |
351 GetRootWindowSettings(root_window())->shutdown = true; | 368 GetRootWindowSettings(root_window)->shutdown = true; |
352 | 369 |
353 system_background_.reset(); | 370 system_background_.reset(); |
354 aura::client::SetScreenPositionClient(root_window(), NULL); | 371 aura::client::SetScreenPositionClient(root_window, NULL); |
355 } | 372 } |
356 | 373 |
357 SystemModalContainerLayoutManager* | 374 SystemModalContainerLayoutManager* |
358 RootWindowController::GetSystemModalLayoutManager(aura::Window* window) { | 375 RootWindowController::GetSystemModalLayoutManager(aura::Window* window) { |
359 aura::Window* modal_container = NULL; | 376 aura::Window* modal_container = NULL; |
360 if (window) { | 377 if (window) { |
361 aura::Window* window_container = GetContainerForWindow(window); | 378 aura::Window* window_container = GetContainerForWindow(window); |
362 if (window_container && | 379 if (window_container && |
363 window_container->id() >= kShellWindowId_LockScreenContainer) { | 380 window_container->id() >= kShellWindowId_LockScreenContainer) { |
364 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer); | 381 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer); |
365 } else { | 382 } else { |
366 modal_container = GetContainer(kShellWindowId_SystemModalContainer); | 383 modal_container = GetContainer(kShellWindowId_SystemModalContainer); |
367 } | 384 } |
368 } else { | 385 } else { |
369 int modal_window_id = Shell::GetInstance()->session_state_delegate() | 386 int modal_window_id = Shell::GetInstance()->session_state_delegate() |
370 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer : | 387 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer : |
371 kShellWindowId_SystemModalContainer; | 388 kShellWindowId_SystemModalContainer; |
372 modal_container = GetContainer(modal_window_id); | 389 modal_container = GetContainer(modal_window_id); |
373 } | 390 } |
374 return modal_container ? static_cast<SystemModalContainerLayoutManager*>( | 391 return modal_container ? static_cast<SystemModalContainerLayoutManager*>( |
375 modal_container->layout_manager()) : NULL; | 392 modal_container->layout_manager()) : NULL; |
376 } | 393 } |
377 | 394 |
378 aura::Window* RootWindowController::GetContainer(int container_id) { | 395 aura::Window* RootWindowController::GetContainer(int container_id) { |
379 return root_window()->GetChildById(container_id); | 396 return GetRootWindow()->GetChildById(container_id); |
380 } | 397 } |
381 | 398 |
382 const aura::Window* RootWindowController::GetContainer(int container_id) const { | 399 const aura::Window* RootWindowController::GetContainer(int container_id) const { |
383 return host_->window()->GetChildById(container_id); | 400 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id); |
384 } | 401 } |
385 | 402 |
386 void RootWindowController::ShowShelf() { | 403 void RootWindowController::ShowShelf() { |
387 if (!shelf_->shelf()) | 404 if (!shelf_->shelf()) |
388 return; | 405 return; |
389 shelf_->shelf()->SetVisible(true); | 406 shelf_->shelf()->SetVisible(true); |
390 shelf_->status_area_widget()->Show(); | 407 shelf_->status_area_widget()->Show(); |
391 } | 408 } |
392 | 409 |
393 void RootWindowController::OnShelfCreated() { | 410 void RootWindowController::OnShelfCreated() { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 panel_layout_manager_->Shutdown(); | 474 panel_layout_manager_->Shutdown(); |
458 panel_layout_manager_ = NULL; | 475 panel_layout_manager_ = NULL; |
459 } | 476 } |
460 // docked_layout_manager_ needs to be shut down before windows are destroyed. | 477 // docked_layout_manager_ needs to be shut down before windows are destroyed. |
461 if (docked_layout_manager_) { | 478 if (docked_layout_manager_) { |
462 if (shelf_ && shelf_->shelf_layout_manager()) | 479 if (shelf_ && shelf_->shelf_layout_manager()) |
463 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager()); | 480 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager()); |
464 docked_layout_manager_->Shutdown(); | 481 docked_layout_manager_->Shutdown(); |
465 docked_layout_manager_ = NULL; | 482 docked_layout_manager_ = NULL; |
466 } | 483 } |
467 | 484 aura::Window* root_window = GetRootWindow(); |
468 aura::client::SetDragDropClient(root_window(), NULL); | 485 aura::client::SetDragDropClient(root_window, NULL); |
469 | 486 |
470 // TODO(harrym): Remove when Status Area Widget is a child view. | 487 // TODO(harrym): Remove when Status Area Widget is a child view. |
471 if (shelf_) { | 488 if (shelf_) { |
472 shelf_->ShutdownStatusAreaWidget(); | 489 shelf_->ShutdownStatusAreaWidget(); |
473 | 490 |
474 if (shelf_->shelf_layout_manager()) | 491 if (shelf_->shelf_layout_manager()) |
475 shelf_->shelf_layout_manager()->PrepareForShutdown(); | 492 shelf_->shelf_layout_manager()->PrepareForShutdown(); |
476 } | 493 } |
477 | 494 |
478 // Close background widget first as it depends on tooltip. | 495 // Close background widget first as it depends on tooltip. |
479 wallpaper_controller_.reset(); | 496 wallpaper_controller_.reset(); |
480 animating_wallpaper_controller_.reset(); | 497 animating_wallpaper_controller_.reset(); |
481 | 498 |
482 workspace_controller_.reset(); | 499 workspace_controller_.reset(); |
483 aura::client::SetTooltipClient(root_window(), NULL); | 500 aura::client::SetTooltipClient(root_window, NULL); |
484 | 501 |
485 // Explicitly destroy top level windows. We do this as during part of | 502 // Explicitly destroy top level windows. We do this as during part of |
486 // destruction such windows may query the RootWindow for state. | 503 // destruction such windows may query the RootWindow for state. |
487 std::queue<aura::Window*> non_toplevel_windows; | 504 std::queue<aura::Window*> non_toplevel_windows; |
488 non_toplevel_windows.push(root_window()); | 505 non_toplevel_windows.push(root_window); |
489 while (!non_toplevel_windows.empty()) { | 506 while (!non_toplevel_windows.empty()) { |
490 aura::Window* non_toplevel_window = non_toplevel_windows.front(); | 507 aura::Window* non_toplevel_window = non_toplevel_windows.front(); |
491 non_toplevel_windows.pop(); | 508 non_toplevel_windows.pop(); |
492 aura::WindowTracker toplevel_windows; | 509 aura::WindowTracker toplevel_windows; |
493 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { | 510 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) { |
494 aura::Window* child = non_toplevel_window->children()[i]; | 511 aura::Window* child = non_toplevel_window->children()[i]; |
495 if (!child->owned_by_parent()) | 512 if (!child->owned_by_parent()) |
496 continue; | 513 continue; |
497 if (child->delegate()) | 514 if (child->delegate()) |
498 toplevel_windows.Add(child); | 515 toplevel_windows.Add(child); |
499 else | 516 else |
500 non_toplevel_windows.push(child); | 517 non_toplevel_windows.push(child); |
501 } | 518 } |
502 while (!toplevel_windows.windows().empty()) | 519 while (!toplevel_windows.windows().empty()) |
503 delete *toplevel_windows.windows().begin(); | 520 delete *toplevel_windows.windows().begin(); |
504 } | 521 } |
505 // And then remove the containers. | 522 // And then remove the containers. |
506 while (!root_window()->children().empty()) { | 523 while (!root_window->children().empty()) { |
507 aura::Window* window = root_window()->children()[0]; | 524 aura::Window* window = root_window->children()[0]; |
508 if (window->owned_by_parent()) { | 525 if (window->owned_by_parent()) { |
509 delete window; | 526 delete window; |
510 } else { | 527 } else { |
511 root_window()->RemoveChild(window); | 528 root_window->RemoveChild(window); |
512 } | 529 } |
513 } | 530 } |
514 | 531 |
515 shelf_.reset(); | 532 shelf_.reset(); |
516 } | 533 } |
517 | 534 |
518 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 535 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
519 // Forget the shelf early so that shelf don't update itself using wrong | 536 // Forget the shelf early so that shelf don't update itself using wrong |
520 // display info. | 537 // display info. |
521 workspace_controller_->SetShelf(NULL); | 538 workspace_controller_->SetShelf(NULL); |
522 ReparentAllWindows(root_window(), dst); | 539 ReparentAllWindows(GetRootWindow(), dst); |
523 } | 540 } |
524 | 541 |
525 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 542 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
526 return shelf_->shelf_layout_manager(); | 543 return shelf_->shelf_layout_manager(); |
527 } | 544 } |
528 | 545 |
529 SystemTray* RootWindowController::GetSystemTray() { | 546 SystemTray* RootWindowController::GetSystemTray() { |
530 // We assume in throughout the code that this will not return NULL. If code | 547 // We assume in throughout the code that this will not return NULL. If code |
531 // triggers this for valid reasons, it should test status_area_widget first. | 548 // triggers this for valid reasons, it should test status_area_widget first. |
532 CHECK(shelf_->status_area_widget()); | 549 CHECK(shelf_->status_area_widget()); |
533 return shelf_->status_area_widget()->system_tray(); | 550 return shelf_->status_area_widget()->system_tray(); |
534 } | 551 } |
535 | 552 |
536 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, | 553 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen, |
537 ui::MenuSourceType source_type) { | 554 ui::MenuSourceType source_type) { |
538 DCHECK(Shell::GetInstance()->delegate()); | 555 DCHECK(Shell::GetInstance()->delegate()); |
539 scoped_ptr<ui::MenuModel> menu_model( | 556 scoped_ptr<ui::MenuModel> menu_model( |
540 Shell::GetInstance()->delegate()->CreateContextMenu(root_window(), | 557 Shell::GetInstance()->delegate()->CreateContextMenu( |
541 NULL, | 558 GetRootWindow(), NULL, NULL)); |
542 NULL)); | |
543 if (!menu_model) | 559 if (!menu_model) |
544 return; | 560 return; |
545 | 561 |
546 // Background controller may not be set yet if user clicked on status are | 562 // Background controller may not be set yet if user clicked on status are |
547 // before initial animation completion. See crbug.com/222218 | 563 // before initial animation completion. See crbug.com/222218 |
548 if (!wallpaper_controller_.get()) | 564 if (!wallpaper_controller_.get()) |
549 return; | 565 return; |
550 | 566 |
551 views::MenuRunner menu_runner(menu_model.get()); | 567 views::MenuRunner menu_runner(menu_model.get()); |
552 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(), | 568 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(), |
553 NULL, gfx::Rect(location_in_screen, gfx::Size()), | 569 NULL, gfx::Rect(location_in_screen, gfx::Size()), |
554 views::MenuItemView::TOPLEFT, source_type, | 570 views::MenuItemView::TOPLEFT, source_type, |
555 views::MenuRunner::CONTEXT_MENU) == | 571 views::MenuRunner::CONTEXT_MENU) == |
556 views::MenuRunner::MENU_DELETED) { | 572 views::MenuRunner::MENU_DELETED) { |
557 return; | 573 return; |
558 } | 574 } |
559 | 575 |
560 Shell::GetInstance()->UpdateShelfVisibility(); | 576 Shell::GetInstance()->UpdateShelfVisibility(); |
561 } | 577 } |
562 | 578 |
563 void RootWindowController::UpdateShelfVisibility() { | 579 void RootWindowController::UpdateShelfVisibility() { |
564 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 580 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
565 } | 581 } |
566 | 582 |
567 const aura::Window* RootWindowController::GetWindowForFullscreenMode() const { | 583 const aura::Window* RootWindowController::GetWindowForFullscreenMode() const { |
568 const aura::Window* topmost_window = NULL; | 584 const aura::Window* topmost_window = NULL; |
569 const aura::Window* active_window = wm::GetActiveWindow(); | 585 const aura::Window* active_window = wm::GetActiveWindow(); |
570 if (active_window && active_window->GetRootWindow() == root_window() && | 586 if (active_window && active_window->GetRootWindow() == GetRootWindow() && |
571 IsSwitchableContainer(active_window->parent())) { | 587 IsSwitchableContainer(active_window->parent())) { |
572 // Use the active window when it is on the current root window to determine | 588 // Use the active window when it is on the current root window to determine |
573 // the fullscreen state to allow temporarily using a panel or docked window | 589 // the fullscreen state to allow temporarily using a panel or docked window |
574 // (which are always above the default container) while a fullscreen | 590 // (which are always above the default container) while a fullscreen |
575 // window is open. We only use the active window when in a switchable | 591 // window is open. We only use the active window when in a switchable |
576 // container as the launcher should not exit fullscreen mode. | 592 // container as the launcher should not exit fullscreen mode. |
577 topmost_window = active_window; | 593 topmost_window = active_window; |
578 } else { | 594 } else { |
579 // Otherwise, use the topmost window on the root window's default container | 595 // Otherwise, use the topmost window on the root window's default container |
580 // when there is no active window on this root window. | 596 // when there is no active window on this root window. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } | 640 } |
625 | 641 |
626 void RootWindowController::DeactivateKeyboard( | 642 void RootWindowController::DeactivateKeyboard( |
627 keyboard::KeyboardController* keyboard_controller) { | 643 keyboard::KeyboardController* keyboard_controller) { |
628 if (!keyboard_controller || | 644 if (!keyboard_controller || |
629 !keyboard_controller->keyboard_container_initialized()) { | 645 !keyboard_controller->keyboard_container_initialized()) { |
630 return; | 646 return; |
631 } | 647 } |
632 aura::Window* keyboard_container = | 648 aura::Window* keyboard_container = |
633 keyboard_controller->GetContainerWindow(); | 649 keyboard_controller->GetContainerWindow(); |
634 if (keyboard_container->GetRootWindow() == root_window()) { | 650 if (keyboard_container->GetRootWindow() == GetRootWindow()) { |
635 aura::Window* parent = GetContainer( | 651 aura::Window* parent = GetContainer( |
636 kShellWindowId_VirtualKeyboardParentContainer); | 652 kShellWindowId_VirtualKeyboardParentContainer); |
637 DCHECK(parent); | 653 DCHECK(parent); |
638 parent->RemoveChild(keyboard_container); | 654 parent->RemoveChild(keyboard_container); |
639 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) { | 655 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) { |
640 // Virtual keyboard may be deactivated while still showing, notify all | 656 // Virtual keyboard may be deactivated while still showing, notify all |
641 // observers that keyboard bounds changed to 0 before remove them. | 657 // observers that keyboard bounds changed to 0 before remove them. |
642 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); | 658 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect()); |
643 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); | 659 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); |
644 keyboard_controller->RemoveObserver(panel_layout_manager_); | 660 keyboard_controller->RemoveObserver(panel_layout_manager_); |
645 keyboard_controller->RemoveObserver(docked_layout_manager_); | 661 keyboard_controller->RemoveObserver(docked_layout_manager_); |
646 Shell::GetInstance()->delegate()->VirtualKeyboardActivated(false); | 662 Shell::GetInstance()->delegate()->VirtualKeyboardActivated(false); |
647 } | 663 } |
648 } | 664 } |
649 } | 665 } |
650 | 666 |
651 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { | 667 bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) { |
652 aura::Window* parent = GetContainer( | 668 aura::Window* parent = GetContainer( |
653 kShellWindowId_VirtualKeyboardParentContainer); | 669 kShellWindowId_VirtualKeyboardParentContainer); |
654 return parent ? parent->Contains(window) : false; | 670 return parent ? parent->Contains(window) : false; |
655 } | 671 } |
656 | 672 |
657 //////////////////////////////////////////////////////////////////////////////// | 673 //////////////////////////////////////////////////////////////////////////////// |
658 // RootWindowController, private: | 674 // RootWindowController, private: |
659 | 675 |
660 RootWindowController::RootWindowController(aura::WindowTreeHost* host) | 676 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host) |
661 : host_(host), | 677 : ash_host_(ash_host), |
662 root_window_layout_(NULL), | 678 root_window_layout_(NULL), |
663 docked_layout_manager_(NULL), | 679 docked_layout_manager_(NULL), |
664 panel_layout_manager_(NULL), | 680 panel_layout_manager_(NULL), |
665 touch_hud_debug_(NULL), | 681 touch_hud_debug_(NULL), |
666 touch_hud_projection_(NULL) { | 682 touch_hud_projection_(NULL) { |
667 GetRootWindowSettings(root_window())->controller = this; | 683 aura::Window* root_window = GetRootWindow(); |
668 screen_dimmer_.reset(new ScreenDimmer(root_window())); | 684 GetRootWindowSettings(root_window)->controller = this; |
| 685 screen_dimmer_.reset(new ScreenDimmer(root_window)); |
669 | 686 |
670 stacking_controller_.reset(new StackingController); | 687 stacking_controller_.reset(new StackingController); |
671 aura::client::SetWindowTreeClient(root_window(), stacking_controller_.get()); | 688 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get()); |
672 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window())); | 689 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); |
673 } | 690 } |
674 | 691 |
675 void RootWindowController::Init(RootWindowType root_window_type, | 692 void RootWindowController::Init(RootWindowType root_window_type, |
676 bool first_run_after_boot) { | 693 bool first_run_after_boot) { |
| 694 aura::Window* root_window = GetRootWindow(); |
677 Shell* shell = Shell::GetInstance(); | 695 Shell* shell = Shell::GetInstance(); |
678 shell->InitRootWindow(root_window()); | 696 shell->InitRootWindow(root_window); |
679 | 697 |
680 host_->SetCursor(ui::kCursorPointer); | 698 ash_host_->AsWindowTreeHost()->SetCursor(ui::kCursorPointer); |
681 CreateContainersInRootWindow(root_window()); | 699 CreateContainersInRootWindow(root_window); |
682 | 700 |
683 if (root_window_type == VIRTUAL_KEYBOARD) { | 701 if (root_window_type == VIRTUAL_KEYBOARD) { |
684 shell->InitKeyboard(); | 702 shell->InitKeyboard(); |
685 return; | 703 return; |
686 } | 704 } |
687 | 705 |
688 CreateSystemBackground(first_run_after_boot); | 706 CreateSystemBackground(first_run_after_boot); |
689 | 707 |
690 InitLayoutManagers(); | 708 InitLayoutManagers(); |
691 InitTouchHuds(); | 709 InitTouchHuds(); |
692 | 710 |
693 if (Shell::GetPrimaryRootWindowController()-> | 711 if (Shell::GetPrimaryRootWindowController()-> |
694 GetSystemModalLayoutManager(NULL)->has_modal_background()) { | 712 GetSystemModalLayoutManager(NULL)->has_modal_background()) { |
695 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); | 713 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
696 } | 714 } |
697 | 715 |
698 shell->AddShellObserver(this); | 716 shell->AddShellObserver(this); |
699 | 717 |
700 if (root_window_type == PRIMARY) { | 718 if (root_window_type == PRIMARY) { |
701 root_window_layout()->OnWindowResized(); | 719 root_window_layout()->OnWindowResized(); |
702 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) | 720 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) |
703 shell->InitKeyboard(); | 721 shell->InitKeyboard(); |
704 } else { | 722 } else { |
705 root_window_layout()->OnWindowResized(); | 723 root_window_layout()->OnWindowResized(); |
706 shell->desktop_background_controller()->OnRootWindowAdded(root_window()); | 724 shell->desktop_background_controller()->OnRootWindowAdded(root_window); |
707 shell->high_contrast_controller()->OnRootWindowAdded(root_window()); | 725 shell->high_contrast_controller()->OnRootWindowAdded(root_window); |
708 host_->Show(); | 726 ash_host_->AsWindowTreeHost()->Show(); |
709 | 727 |
710 // Create a shelf if a user is already logged in. | 728 // Create a shelf if a user is already logged in. |
711 if (shell->session_state_delegate()->NumberOfLoggedInUsers()) | 729 if (shell->session_state_delegate()->NumberOfLoggedInUsers()) |
712 shelf()->CreateShelf(); | 730 shelf()->CreateShelf(); |
713 } | 731 } |
714 } | 732 } |
715 | 733 |
716 void RootWindowController::InitLayoutManagers() { | 734 void RootWindowController::InitLayoutManagers() { |
717 root_window_layout_ = new RootWindowLayoutManager(root_window()); | 735 aura::Window* root_window = GetRootWindow(); |
718 root_window()->SetLayoutManager(root_window_layout_); | 736 root_window_layout_ = new RootWindowLayoutManager(root_window); |
| 737 root_window->SetLayoutManager(root_window_layout_); |
719 | 738 |
720 aura::Window* default_container = | 739 aura::Window* default_container = |
721 GetContainer(kShellWindowId_DefaultContainer); | 740 GetContainer(kShellWindowId_DefaultContainer); |
722 // Workspace manager has its own layout managers. | 741 // Workspace manager has its own layout managers. |
723 workspace_controller_.reset( | 742 workspace_controller_.reset( |
724 new WorkspaceController(default_container)); | 743 new WorkspaceController(default_container)); |
725 | 744 |
726 aura::Window* always_on_top_container = | 745 aura::Window* always_on_top_container = |
727 GetContainer(kShellWindowId_AlwaysOnTopContainer); | 746 GetContainer(kShellWindowId_AlwaysOnTopContainer); |
728 always_on_top_container->SetLayoutManager( | 747 always_on_top_container->SetLayoutManager( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); | 779 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer); |
761 panel_layout_manager_ = new PanelLayoutManager(panel_container); | 780 panel_layout_manager_ = new PanelLayoutManager(panel_container); |
762 panel_container->SetLayoutManager(panel_layout_manager_); | 781 panel_container->SetLayoutManager(panel_layout_manager_); |
763 panel_container_handler_.reset(new PanelWindowEventHandler); | 782 panel_container_handler_.reset(new PanelWindowEventHandler); |
764 panel_container->AddPreTargetHandler(panel_container_handler_.get()); | 783 panel_container->AddPreTargetHandler(panel_container_handler_.get()); |
765 } | 784 } |
766 | 785 |
767 void RootWindowController::InitTouchHuds() { | 786 void RootWindowController::InitTouchHuds() { |
768 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 787 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
769 if (command_line->HasSwitch(switches::kAshTouchHud)) | 788 if (command_line->HasSwitch(switches::kAshTouchHud)) |
770 set_touch_hud_debug(new TouchHudDebug(root_window())); | 789 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); |
771 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) | 790 if (Shell::GetInstance()->is_touch_hud_projection_enabled()) |
772 EnableTouchHudProjection(); | 791 EnableTouchHudProjection(); |
773 } | 792 } |
774 | 793 |
775 void RootWindowController::CreateSystemBackground( | 794 void RootWindowController::CreateSystemBackground( |
776 bool is_first_run_after_boot) { | 795 bool is_first_run_after_boot) { |
777 SkColor color = SK_ColorBLACK; | 796 SkColor color = SK_ColorBLACK; |
778 #if defined(OS_CHROMEOS) | 797 #if defined(OS_CHROMEOS) |
779 if (is_first_run_after_boot) | 798 if (is_first_run_after_boot) |
780 color = kChromeOsBootColor; | 799 color = kChromeOsBootColor; |
781 #endif | 800 #endif |
782 system_background_.reset( | 801 system_background_.reset( |
783 new SystemBackgroundController(root_window(), color)); | 802 new SystemBackgroundController(GetRootWindow(), color)); |
784 | 803 |
785 #if defined(OS_CHROMEOS) | 804 #if defined(OS_CHROMEOS) |
786 // Make a copy of the system's boot splash screen so we can composite it | 805 // Make a copy of the system's boot splash screen so we can composite it |
787 // onscreen until the desktop background is ready. | 806 // onscreen until the desktop background is ready. |
788 if (is_first_run_after_boot && | 807 if (is_first_run_after_boot && |
789 (CommandLine::ForCurrentProcess()->HasSwitch( | 808 (CommandLine::ForCurrentProcess()->HasSwitch( |
790 switches::kAshCopyHostBackgroundAtBoot) || | 809 switches::kAshCopyHostBackgroundAtBoot) || |
791 CommandLine::ForCurrentProcess()->HasSwitch( | 810 CommandLine::ForCurrentProcess()->HasSwitch( |
792 switches::kAshAnimateFromBootSplashScreen))) | 811 switches::kAshAnimateFromBootSplashScreen))) |
793 boot_splash_screen_.reset(new BootSplashScreen(host())); | 812 boot_splash_screen_.reset(new BootSplashScreen(GetHost())); |
794 #endif | 813 #endif |
795 } | 814 } |
796 | 815 |
797 void RootWindowController::CreateContainersInRootWindow( | 816 void RootWindowController::CreateContainersInRootWindow( |
798 aura::Window* root_window) { | 817 aura::Window* root_window) { |
799 // These containers are just used by PowerButtonController to animate groups | 818 // These containers are just used by PowerButtonController to animate groups |
800 // of containers simultaneously without messing up the current transformations | 819 // of containers simultaneously without messing up the current transformations |
801 // on those containers. These are direct children of the root window; all of | 820 // on those containers. These are direct children of the root window; all of |
802 // the other containers are their children. | 821 // the other containers are their children. |
803 | 822 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 SetUsesScreenCoordinates(mouse_cursor_container); | 991 SetUsesScreenCoordinates(mouse_cursor_container); |
973 #endif | 992 #endif |
974 | 993 |
975 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, | 994 CreateContainer(kShellWindowId_PowerButtonAnimationContainer, |
976 "PowerButtonAnimationContainer", root_window); | 995 "PowerButtonAnimationContainer", root_window); |
977 } | 996 } |
978 | 997 |
979 void RootWindowController::EnableTouchHudProjection() { | 998 void RootWindowController::EnableTouchHudProjection() { |
980 if (touch_hud_projection_) | 999 if (touch_hud_projection_) |
981 return; | 1000 return; |
982 set_touch_hud_projection(new TouchHudProjection(root_window())); | 1001 set_touch_hud_projection(new TouchHudProjection(GetRootWindow())); |
983 } | 1002 } |
984 | 1003 |
985 void RootWindowController::DisableTouchHudProjection() { | 1004 void RootWindowController::DisableTouchHudProjection() { |
986 if (!touch_hud_projection_) | 1005 if (!touch_hud_projection_) |
987 return; | 1006 return; |
988 touch_hud_projection_->Remove(); | 1007 touch_hud_projection_->Remove(); |
989 } | 1008 } |
990 | 1009 |
991 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { | 1010 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) { |
992 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 1011 shelf_->shelf_layout_manager()->UpdateVisibilityState(); |
993 } | 1012 } |
994 | 1013 |
995 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 1014 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
996 if (enabled) | 1015 if (enabled) |
997 EnableTouchHudProjection(); | 1016 EnableTouchHudProjection(); |
998 else | 1017 else |
999 DisableTouchHudProjection(); | 1018 DisableTouchHudProjection(); |
1000 } | 1019 } |
1001 | 1020 |
1002 RootWindowController* GetRootWindowController( | 1021 RootWindowController* GetRootWindowController( |
1003 const aura::Window* root_window) { | 1022 const aura::Window* root_window) { |
1004 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; | 1023 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; |
1005 } | 1024 } |
1006 | 1025 |
1007 } // namespace ash | 1026 } // namespace ash |
OLD | NEW |