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

Side by Side Diff: ash/shell.cc

Issue 9701098: MultiMonitor support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix shutdown order Created 8 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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/app_list/app_list.h" 9 #include "ash/app_list/app_list.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/desktop_background/desktop_background_controller.h" 11 #include "ash/desktop_background/desktop_background_controller.h"
12 #include "ash/desktop_background/desktop_background_resources.h" 12 #include "ash/desktop_background/desktop_background_resources.h"
13 #include "ash/desktop_background/desktop_background_view.h" 13 #include "ash/desktop_background/desktop_background_view.h"
14 #include "ash/drag_drop/drag_drop_controller.h" 14 #include "ash/drag_drop/drag_drop_controller.h"
15 #include "ash/focus_cycler.h" 15 #include "ash/focus_cycler.h"
16 #include "ash/ime/input_method_event_filter.h" 16 #include "ash/ime/input_method_event_filter.h"
17 #include "ash/launcher/launcher.h" 17 #include "ash/launcher/launcher.h"
18 #include "ash/monitor/multi_monitor_manager.h"
19 #include "ash/monitor/monitor_controller.h"
18 #include "ash/screen_ash.h" 20 #include "ash/screen_ash.h"
19 #include "ash/shell_delegate.h" 21 #include "ash/shell_delegate.h"
20 #include "ash/shell_factory.h" 22 #include "ash/shell_factory.h"
21 #include "ash/shell_window_ids.h" 23 #include "ash/shell_window_ids.h"
22 #include "ash/system/audio/tray_volume.h" 24 #include "ash/system/audio/tray_volume.h"
23 #include "ash/system/brightness/tray_brightness.h" 25 #include "ash/system/brightness/tray_brightness.h"
24 #include "ash/system/network/tray_network.h" 26 #include "ash/system/network/tray_network.h"
25 #include "ash/system/power/power_status_observer.h" 27 #include "ash/system/power/power_status_observer.h"
26 #include "ash/system/power/power_supply_status.h" 28 #include "ash/system/power/power_supply_status.h"
27 #include "ash/system/power/tray_power_date.h" 29 #include "ash/system/power/tray_power_date.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 400
399 internal::WorkspaceController* Shell::TestApi::workspace_controller() { 401 internal::WorkspaceController* Shell::TestApi::workspace_controller() {
400 return shell_->workspace_controller_.get(); 402 return shell_->workspace_controller_.get();
401 } 403 }
402 404
403 //////////////////////////////////////////////////////////////////////////////// 405 ////////////////////////////////////////////////////////////////////////////////
404 // Shell, public: 406 // Shell, public:
405 407
406 Shell::Shell(ShellDelegate* delegate) 408 Shell::Shell(ShellDelegate* delegate)
407 : root_window_(aura::Env::GetInstance()->monitor_manager()-> 409 : root_window_(aura::Env::GetInstance()->monitor_manager()->
408 CreateRootWindowForPrimaryMonitor()), 410 CreateRootWindowForPrimaryMonitor()),
Ben Goodger (Google) 2012/03/20 17:09:02 and replace this with your helper function too (th
oshima 2012/03/20 19:26:36 Done.
409 screen_(new ScreenAsh(root_window_.get())), 411 screen_(new ScreenAsh(root_window_.get())),
410 root_filter_(NULL), 412 root_filter_(NULL),
411 delegate_(delegate), 413 delegate_(delegate),
412 shelf_(NULL), 414 shelf_(NULL),
413 root_window_layout_(NULL), 415 root_window_layout_(NULL),
414 status_widget_(NULL) { 416 status_widget_(NULL) {
415 gfx::Screen::SetInstance(screen_); 417 gfx::Screen::SetInstance(screen_);
416 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get())); 418 ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get()));
417 aura::Env::GetInstance()->monitor_manager()->AddObserver(this);
418 } 419 }
419 420
420 Shell::~Shell() { 421 Shell::~Shell() {
421 aura::Env::GetInstance()->monitor_manager()->RemoveObserver(this);
422 RemoveRootWindowEventFilter(partial_screenshot_filter_.get()); 422 RemoveRootWindowEventFilter(partial_screenshot_filter_.get());
423 RemoveRootWindowEventFilter(input_method_filter_.get()); 423 RemoveRootWindowEventFilter(input_method_filter_.get());
424 RemoveRootWindowEventFilter(window_modality_controller_.get()); 424 RemoveRootWindowEventFilter(window_modality_controller_.get());
425 #if !defined(OS_MACOSX) 425 #if !defined(OS_MACOSX)
426 RemoveRootWindowEventFilter(accelerator_filter_.get()); 426 RemoveRootWindowEventFilter(accelerator_filter_.get());
427 #endif 427 #endif
428 428
429 // Close background widget now so that the focus manager of the 429 // Close background widget now so that the focus manager of the
430 // widget gets deleted in the final message loop run. 430 // widget gets deleted in the final message loop run.
431 root_window_layout_->SetBackgroundWidget(NULL); 431 root_window_layout_->SetBackgroundWidget(NULL);
(...skipping 18 matching lines...) Expand all
450 } 450 }
451 451
452 // These need a valid Shell instance to clean up properly, so explicitly 452 // These need a valid Shell instance to clean up properly, so explicitly
453 // delete them before invalidating the instance. 453 // delete them before invalidating the instance.
454 // Alphabetical. 454 // Alphabetical.
455 activation_controller_.reset(); 455 activation_controller_.reset();
456 drag_drop_controller_.reset(); 456 drag_drop_controller_.reset();
457 resize_shadow_controller_.reset(); 457 resize_shadow_controller_.reset();
458 shadow_controller_.reset(); 458 shadow_controller_.reset();
459 window_cycle_controller_.reset(); 459 window_cycle_controller_.reset();
460 monitor_controller_.reset();
460 461
461 // Launcher widget has a InputMethodBridge that references to 462 // Launcher widget has a InputMethodBridge that references to
462 // input_method_filter_'s input_method_. So explicitly release launcher_ 463 // input_method_filter_'s input_method_. So explicitly release launcher_
463 // before input_method_filter_. And this needs to be after we delete all 464 // before input_method_filter_. And this needs to be after we delete all
464 // containers in case there are still live browser windows which access 465 // containers in case there are still live browser windows which access
465 // LauncherModel during close. 466 // LauncherModel during close.
466 launcher_.reset(); 467 launcher_.reset();
467 468
468 DCHECK(instance_ == this); 469 DCHECK(instance_ == this);
469 instance_ = NULL; 470 instance_ = NULL;
470 } 471 }
471 472
472 // static 473 // static
473 Shell* Shell::CreateInstance(ShellDelegate* delegate) { 474 Shell* Shell::CreateInstance(ShellDelegate* delegate) {
474 CHECK(!instance_); 475 CHECK(!instance_);
476 aura::Env::GetInstance()->SetMonitorManager(
477 new internal::MultiMonitorManager());
475 instance_ = new Shell(delegate); 478 instance_ = new Shell(delegate);
476 instance_->Init(); 479 instance_->Init();
477 return instance_; 480 return instance_;
478 } 481 }
479 482
480 // static 483 // static
481 Shell* Shell::GetInstance() { 484 Shell* Shell::GetInstance() {
482 DCHECK(instance_); 485 DCHECK(instance_);
483 return instance_; 486 return instance_;
484 } 487 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 621
619 visibility_controller_.reset(new internal::VisibilityController); 622 visibility_controller_.reset(new internal::VisibilityController);
620 623
621 tooltip_controller_.reset(new internal::TooltipController); 624 tooltip_controller_.reset(new internal::TooltipController);
622 AddRootWindowEventFilter(tooltip_controller_.get()); 625 AddRootWindowEventFilter(tooltip_controller_.get());
623 626
624 drag_drop_controller_.reset(new internal::DragDropController); 627 drag_drop_controller_.reset(new internal::DragDropController);
625 power_button_controller_.reset(new PowerButtonController); 628 power_button_controller_.reset(new PowerButtonController);
626 video_detector_.reset(new VideoDetector); 629 video_detector_.reset(new VideoDetector);
627 window_cycle_controller_.reset(new WindowCycleController); 630 window_cycle_controller_.reset(new WindowCycleController);
631 monitor_controller_.reset(new internal::MonitorController);
628 } 632 }
629 633
630 aura::Window* Shell::GetContainer(int container_id) { 634 aura::Window* Shell::GetContainer(int container_id) {
631 return const_cast<aura::Window*>( 635 return const_cast<aura::Window*>(
632 const_cast<const Shell*>(this)->GetContainer(container_id)); 636 const_cast<const Shell*>(this)->GetContainer(container_id));
633 } 637 }
634 638
635 const aura::Window* Shell::GetContainer(int container_id) const { 639 const aura::Window* Shell::GetContainer(int container_id) const {
636 return GetRootWindow()->GetChildById(container_id); 640 return GetRootWindow()->GetChildById(container_id);
637 } 641 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 714
711 void Shell::RemoveShellObserver(ShellObserver* observer) { 715 void Shell::RemoveShellObserver(ShellObserver* observer) {
712 observers_.RemoveObserver(observer); 716 observers_.RemoveObserver(observer);
713 } 717 }
714 718
715 int Shell::GetGridSize() const { 719 int Shell::GetGridSize() const {
716 return workspace_controller_->workspace_manager()->grid_size(); 720 return workspace_controller_->workspace_manager()->grid_size();
717 } 721 }
718 722
719 //////////////////////////////////////////////////////////////////////////////// 723 ////////////////////////////////////////////////////////////////////////////////
720 // Shell, aura::MonitorObserver implementation:
721
722 void Shell::OnMonitorBoundsChanged(const aura::Monitor* monitor) {
723 if (aura::RootWindow::use_fullscreen_host_window())
724 root_window_->SetHostSize(monitor->size());
725 }
726
727 ////////////////////////////////////////////////////////////////////////////////
728 // Shell, private: 724 // Shell, private:
729 725
730 void Shell::InitLayoutManagers() { 726 void Shell::InitLayoutManagers() {
731 DCHECK(root_window_layout_); 727 DCHECK(root_window_layout_);
732 DCHECK(status_widget_); 728 DCHECK(status_widget_);
733 729
734 internal::ShelfLayoutManager* shelf_layout_manager = 730 internal::ShelfLayoutManager* shelf_layout_manager =
735 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_); 731 new internal::ShelfLayoutManager(launcher_->widget(), status_widget_);
736 GetContainer(internal::kShellWindowId_LauncherContainer)-> 732 GetContainer(internal::kShellWindowId_LauncherContainer)->
737 SetLayoutManager(shelf_layout_manager); 733 SetLayoutManager(shelf_layout_manager);
(...skipping 17 matching lines...) Expand all
755 // Create the desktop background image. 751 // Create the desktop background image.
756 desktop_background_controller_->SetDefaultDesktopBackgroundImage(); 752 desktop_background_controller_->SetDefaultDesktopBackgroundImage();
757 } 753 }
758 754
759 void Shell::DisableWorkspaceGridLayout() { 755 void Shell::DisableWorkspaceGridLayout() {
760 if (workspace_controller_.get()) 756 if (workspace_controller_.get())
761 workspace_controller_->workspace_manager()->set_grid_size(0); 757 workspace_controller_->workspace_manager()->set_grid_size(0);
762 } 758 }
763 759
764 } // namespace ash 760 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698