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

Side by Side Diff: ash/root_window_controller.cc

Issue 201573015: Introdcue AshWindowTreeHost and move ash/chrome specific code in WTH to ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 ui::Layer* new_layer) OVERRIDE {} 258 ui::Layer* new_layer) OVERRIDE {}
258 259
259 private: 260 private:
260 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate); 261 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
261 }; 262 };
262 263
263 } // namespace 264 } // namespace
264 265
265 namespace internal { 266 namespace internal {
266 267
267 void RootWindowController::CreateForPrimaryDisplay(aura::WindowTreeHost* host) { 268 void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) {
268 RootWindowController* controller = new RootWindowController(host); 269 RootWindowController* controller = new RootWindowController(host);
269 controller->Init(RootWindowController::PRIMARY, 270 controller->Init(RootWindowController::PRIMARY,
270 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot()); 271 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot());
271 } 272 }
272 273
273 void RootWindowController::CreateForSecondaryDisplay( 274 void RootWindowController::CreateForSecondaryDisplay(
274 aura::WindowTreeHost* host) { 275 AshWindowTreeHost* host) {
275 RootWindowController* controller = new RootWindowController(host); 276 RootWindowController* controller = new RootWindowController(host);
276 controller->Init(RootWindowController::SECONDARY, false /* first run */); 277 controller->Init(RootWindowController::SECONDARY, false /* first run */);
277 } 278 }
278 279
279 void RootWindowController::CreateForVirtualKeyboardDisplay( 280 void RootWindowController::CreateForVirtualKeyboardDisplay(
280 aura::WindowTreeHost* host) { 281 AshWindowTreeHost* host) {
281 RootWindowController* controller = new RootWindowController(host); 282 RootWindowController* controller = new RootWindowController(host);
282 controller->Init(RootWindowController::VIRTUAL_KEYBOARD, 283 controller->Init(RootWindowController::VIRTUAL_KEYBOARD,
283 false /* first run */); 284 false /* first run */);
284 } 285 }
285 286
286 // static 287 // static
287 RootWindowController* RootWindowController::ForShelf(aura::Window* window) { 288 RootWindowController* RootWindowController::ForShelf(aura::Window* window) {
288 return GetRootWindowController(window->GetRootWindow()); 289 return GetRootWindowController(window->GetRootWindow());
289 } 290 }
290 291
(...skipping 12 matching lines...) Expand all
303 aura::Window* RootWindowController::GetContainerForWindow( 304 aura::Window* RootWindowController::GetContainerForWindow(
304 aura::Window* window) { 305 aura::Window* window) {
305 aura::Window* container = window->parent(); 306 aura::Window* container = window->parent();
306 while (container && container->type() != ui::wm::WINDOW_TYPE_UNKNOWN) 307 while (container && container->type() != ui::wm::WINDOW_TYPE_UNKNOWN)
307 container = container->parent(); 308 container = container->parent();
308 return container; 309 return container;
309 } 310 }
310 311
311 RootWindowController::~RootWindowController() { 312 RootWindowController::~RootWindowController() {
312 Shutdown(); 313 Shutdown();
313 host_.reset(); 314 ash_host_.reset();
314 // The CaptureClient needs to be around for as long as the RootWindow is 315 // The CaptureClient needs to be around for as long as the RootWindow is
315 // valid. 316 // valid.
316 capture_client_.reset(); 317 capture_client_.reset();
317 } 318 }
318 319
319 void RootWindowController::SetWallpaperController( 320 void RootWindowController::SetWallpaperController(
320 DesktopBackgroundWidgetController* controller) { 321 DesktopBackgroundWidgetController* controller) {
321 wallpaper_controller_.reset(controller); 322 wallpaper_controller_.reset(controller);
322 } 323 }
323 324
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 380 }
380 return modal_container ? static_cast<SystemModalContainerLayoutManager*>( 381 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
381 modal_container->layout_manager()) : NULL; 382 modal_container->layout_manager()) : NULL;
382 } 383 }
383 384
384 aura::Window* RootWindowController::GetContainer(int container_id) { 385 aura::Window* RootWindowController::GetContainer(int container_id) {
385 return root_window()->GetChildById(container_id); 386 return root_window()->GetChildById(container_id);
386 } 387 }
387 388
388 const aura::Window* RootWindowController::GetContainer(int container_id) const { 389 const aura::Window* RootWindowController::GetContainer(int container_id) const {
389 return host_->window()->GetChildById(container_id); 390 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id);
390 } 391 }
391 392
392 void RootWindowController::ShowShelf() { 393 void RootWindowController::ShowShelf() {
393 if (!shelf_->shelf()) 394 if (!shelf_->shelf())
394 return; 395 return;
395 shelf_->shelf()->SetVisible(true); 396 shelf_->shelf()->SetVisible(true);
396 shelf_->status_area_widget()->Show(); 397 shelf_->status_area_widget()->Show();
397 } 398 }
398 399
399 void RootWindowController::OnShelfCreated() { 400 void RootWindowController::OnShelfCreated() {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager()); 649 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
649 keyboard_controller->RemoveObserver(panel_layout_manager_); 650 keyboard_controller->RemoveObserver(panel_layout_manager_);
650 keyboard_controller->RemoveObserver(docked_layout_manager_); 651 keyboard_controller->RemoveObserver(docked_layout_manager_);
651 } 652 }
652 } 653 }
653 } 654 }
654 655
655 //////////////////////////////////////////////////////////////////////////////// 656 ////////////////////////////////////////////////////////////////////////////////
656 // RootWindowController, private: 657 // RootWindowController, private:
657 658
658 RootWindowController::RootWindowController(aura::WindowTreeHost* host) 659 RootWindowController::RootWindowController(AshWindowTreeHost* ash_host)
659 : host_(host), 660 : ash_host_(ash_host),
660 root_window_layout_(NULL), 661 root_window_layout_(NULL),
661 docked_layout_manager_(NULL), 662 docked_layout_manager_(NULL),
662 panel_layout_manager_(NULL), 663 panel_layout_manager_(NULL),
663 touch_hud_debug_(NULL), 664 touch_hud_debug_(NULL),
664 touch_hud_projection_(NULL) { 665 touch_hud_projection_(NULL) {
665 GetRootWindowSettings(root_window())->controller = this; 666 GetRootWindowSettings(root_window())->controller = this;
666 screen_dimmer_.reset(new ScreenDimmer(root_window())); 667 screen_dimmer_.reset(new ScreenDimmer(root_window()));
667 668
668 stacking_controller_.reset(new StackingController); 669 stacking_controller_.reset(new StackingController);
669 aura::client::SetWindowTreeClient(root_window(), stacking_controller_.get()); 670 aura::client::SetWindowTreeClient(root_window(), stacking_controller_.get());
670 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window())); 671 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window()));
671 } 672 }
672 673
673 void RootWindowController::Init(RootWindowType root_window_type, 674 void RootWindowController::Init(RootWindowType root_window_type,
674 bool first_run_after_boot) { 675 bool first_run_after_boot) {
675 Shell* shell = Shell::GetInstance(); 676 Shell* shell = Shell::GetInstance();
676 shell->InitRootWindow(root_window()); 677 shell->InitRootWindow(root_window());
677 678
678 host_->SetCursor(ui::kCursorPointer); 679 ash_host_->AsWindowTreeHost()->SetCursor(ui::kCursorPointer);
679 CreateContainersInRootWindow(root_window()); 680 CreateContainersInRootWindow(root_window());
680 681
681 if (root_window_type == VIRTUAL_KEYBOARD) { 682 if (root_window_type == VIRTUAL_KEYBOARD) {
682 shell->InitKeyboard(); 683 shell->InitKeyboard();
683 return; 684 return;
684 } 685 }
685 686
686 CreateSystemBackground(first_run_after_boot); 687 CreateSystemBackground(first_run_after_boot);
687 688
688 InitLayoutManagers(); 689 InitLayoutManagers();
689 InitTouchHuds(); 690 InitTouchHuds();
690 691
691 if (Shell::GetPrimaryRootWindowController()-> 692 if (Shell::GetPrimaryRootWindowController()->
692 GetSystemModalLayoutManager(NULL)->has_modal_background()) { 693 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
693 GetSystemModalLayoutManager(NULL)->CreateModalBackground(); 694 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
694 } 695 }
695 696
696 shell->AddShellObserver(this); 697 shell->AddShellObserver(this);
697 698
698 if (root_window_type == PRIMARY) { 699 if (root_window_type == PRIMARY) {
699 root_window_layout()->OnWindowResized(); 700 root_window_layout()->OnWindowResized();
700 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) 701 if (!keyboard::IsKeyboardUsabilityExperimentEnabled())
701 shell->InitKeyboard(); 702 shell->InitKeyboard();
702 } else { 703 } else {
703 root_window_layout()->OnWindowResized(); 704 root_window_layout()->OnWindowResized();
704 shell->desktop_background_controller()->OnRootWindowAdded(root_window()); 705 shell->desktop_background_controller()->OnRootWindowAdded(root_window());
705 shell->high_contrast_controller()->OnRootWindowAdded(root_window()); 706 shell->high_contrast_controller()->OnRootWindowAdded(root_window());
706 host_->Show(); 707 ash_host_->AsWindowTreeHost()->Show();
707 708
708 // Create a shelf if a user is already logged in. 709 // Create a shelf if a user is already logged in.
709 if (shell->session_state_delegate()->NumberOfLoggedInUsers()) 710 if (shell->session_state_delegate()->NumberOfLoggedInUsers())
710 shelf()->CreateShelf(); 711 shelf()->CreateShelf();
711 } 712 }
712 } 713 }
713 714
714 void RootWindowController::InitLayoutManagers() { 715 void RootWindowController::InitLayoutManagers() {
715 root_window_layout_ = new RootWindowLayoutManager(root_window()); 716 root_window_layout_ = new RootWindowLayoutManager(root_window());
716 root_window()->SetLayoutManager(root_window_layout_); 717 root_window()->SetLayoutManager(root_window_layout_);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 DisableTouchHudProjection(); 1006 DisableTouchHudProjection();
1006 } 1007 }
1007 1008
1008 RootWindowController* GetRootWindowController( 1009 RootWindowController* GetRootWindowController(
1009 const aura::Window* root_window) { 1010 const aura::Window* root_window) {
1010 return root_window ? GetRootWindowSettings(root_window)->controller : NULL; 1011 return root_window ? GetRootWindowSettings(root_window)->controller : NULL;
1011 } 1012 }
1012 1013
1013 } // namespace internal 1014 } // namespace internal
1014 } // namespace ash 1015 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698