summaryrefslogtreecommitdiffstats
path: root/ash/shell.cc
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 07:38:23 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-15 07:38:23 +0000
commitbe65be36422183ca14c6e61bdcca8b79eb36c668 (patch)
tree37ba9417fdf52544c6f0e4195136e6a8457ea5f5 /ash/shell.cc
parent56c2ee9abf440e57c3b133c625067743f237c324 (diff)
downloadchromium_src-be65be36422183ca14c6e61bdcca8b79eb36c668.zip
chromium_src-be65be36422183ca14c6e61bdcca8b79eb36c668.tar.gz
chromium_src-be65be36422183ca14c6e61bdcca8b79eb36c668.tar.bz2
Add Extended Desktop mode behind --ash-extended-desktop flag.
A lot of stuff still doesn't work but you can create and use a window on 2nd display. MonitorController now owns all root windows. BUG=123160 TEST=see http://codereview.chromium.org/10536187/ Review URL: https://chromiumcodereview.appspot.com/10535149 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142350 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/shell.cc')
-rw-r--r--ash/shell.cc125
1 files changed, 80 insertions, 45 deletions
diff --git a/ash/shell.cc b/ash/shell.cc
index 3070679..f889182 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -166,6 +166,7 @@ internal::WorkspaceController* Shell::TestApi::workspace_controller() {
Shell::Shell(ShellDelegate* delegate)
: screen_(new ScreenAsh),
+ active_root_window_(NULL),
env_filter_(NULL),
delegate_(delegate),
#if defined(OS_CHROMEOS)
@@ -215,17 +216,14 @@ Shell::~Shell() {
// TODO(xiyuan): Move it back when app list container is no longer needed.
app_list_controller_.reset();
- // Destroy secondary monitor's widgets before all the windows are destroyed.
- monitor_controller_.reset();
-
- root_window_controller_->CloseChildWindows();
+ // Destroy all child windows including widgets.
+ monitor_controller_->CloseChildWindows();
// These need a valid Shell instance to clean up properly, so explicitly
// delete them before invalidating the instance.
// Alphabetical.
drag_drop_controller_.reset();
magnification_controller_.reset();
- monitor_controller_.reset();
power_button_controller_.reset();
resize_shadow_controller_.reset();
shadow_controller_.reset();
@@ -236,7 +234,8 @@ Shell::~Shell() {
user_action_client_.reset();
visibility_controller_.reset();
- root_window_controller_.reset();
+ // This also deletes all RootWindows.
+ monitor_controller_.reset();
// Launcher widget has a InputMethodBridge that references to
// input_method_filter_'s input_method_. So explicitly release launcher_
@@ -289,12 +288,18 @@ void Shell::DeleteInstance() {
// static
internal::RootWindowController* Shell::GetPrimaryRootWindowController() {
- return GetInstance()->root_window_controller_.get();
+ return wm::GetRootWindowController(GetPrimaryRootWindow());
+}
+
+// static
+Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() {
+ return Shell::GetInstance()->monitor_controller()->
+ GetAllRootWindowControllers();
}
// static
aura::RootWindow* Shell::GetPrimaryRootWindow() {
- return GetPrimaryRootWindowController()->root_window();
+ return GetInstance()->monitor_controller()->GetPrimaryRootWindow();
}
// static
@@ -309,6 +314,12 @@ aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) {
}
// static
+Shell::RootWindowList Shell::GetAllRootWindows() {
+ return Shell::GetInstance()->monitor_controller()->
+ GetAllRootWindows();
+}
+
+// static
aura::Window* Shell::GetContainer(aura::RootWindow* root_window,
int container_id) {
return root_window->GetChildById(container_id);
@@ -334,11 +345,16 @@ void Shell::Init() {
aura::Env::GetInstance()->SetEventFilter(env_filter_);
aura::Env::GetInstance()->cursor_manager()->set_delegate(this);
- aura::RootWindow* root_window =
- aura::MonitorManager::CreateRootWindowForPrimaryMonitor();
- active_root_window_ = root_window;
+
focus_manager_.reset(new aura::FocusManager);
+ activation_controller_.reset(
+ new internal::ActivationController(focus_manager_.get()));
+
+ monitor_controller_.reset(new internal::MonitorController);
+ monitor_controller_->InitPrimaryDisplay();
+ aura::RootWindow* root_window = monitor_controller_->GetPrimaryRootWindow();
+ active_root_window_ = root_window;
#if !defined(OS_MACOSX)
nested_dispatcher_controller_.reset(new NestedDispatcherController);
@@ -375,9 +391,6 @@ void Shell::Init() {
slow_animation_filter_.reset(new internal::SlowAnimationEventFilter);
AddEnvEventFilter(slow_animation_filter_.get());
- activation_controller_.reset(
- new internal::ActivationController(focus_manager_.get()));
-
capture_controller_.reset(new internal::CaptureController);
CommandLine* command_line = CommandLine::ForCurrentProcess();
@@ -386,10 +399,9 @@ void Shell::Init() {
touch_observer_hud_.reset(new internal::TouchObserverHUD);
AddEnvEventFilter(touch_observer_hud_.get());
}
-
- root_window_controller_.reset(
- new internal::RootWindowController(root_window));
- root_window_controller_->CreateContainers();
+ internal::RootWindowController* root_window_controller =
+ new internal::RootWindowController(root_window);
+ root_window_controller->CreateContainers();
// Create Controllers that may need root window.
// TODO(oshima): Move as many controllers before creating
@@ -409,9 +421,8 @@ void Shell::Init() {
high_contrast_controller_.reset(new HighContrastController);
video_detector_.reset(new VideoDetector);
window_cycle_controller_.reset(new WindowCycleController);
- monitor_controller_.reset(new internal::MonitorController);
- InitRootWindow(root_window);
+ InitRootWindowController(root_window_controller);
// Initialize Primary RootWindow specific items.
status_area_widget_ = new internal::StatusAreaWidget();
@@ -428,7 +439,7 @@ void Shell::Init() {
if (!user_wallpaper_delegate_.get())
user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate());
- InitLayoutManagersForPrimaryDisplay(root_window_controller_.get());
+ InitLayoutManagersForPrimaryDisplay(root_window_controller);
if (!command_line->HasSwitch(switches::kAuraNoShadows)) {
resize_shadow_controller_.reset(new internal::ResizeShadowController());
@@ -439,7 +450,7 @@ void Shell::Init() {
CreateLauncher();
// Force Layout
- root_window_controller_->root_window_layout()->OnWindowResized();
+ root_window_controller->root_window_layout()->OnWindowResized();
// It needs to be created after OnWindowResized has been called, otherwise the
// widget will not paint when restoring after a browser crash.
@@ -448,6 +459,8 @@ void Shell::Init() {
power_button_controller_.reset(new PowerButtonController);
AddShellObserver(power_button_controller_.get());
+ monitor_controller_->InitSecondaryDisplays();
+
if (initially_hide_cursor_)
aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
}
@@ -587,7 +600,10 @@ ShelfAlignment Shell::GetShelfAlignment() {
}
void Shell::SetDimming(bool should_dim) {
- GetPrimaryRootWindowController()->screen_dimmer()->SetDimming(should_dim);
+ RootWindowControllerList controllers = GetAllRootWindowControllers();
+ for (RootWindowControllerList::iterator iter = controllers.begin();
+ iter != controllers.end(); ++iter)
+ (*iter)->screen_dimmer()->SetDimming(should_dim);
}
SystemTrayDelegate* Shell::tray_delegate() {
@@ -605,22 +621,34 @@ int Shell::GetGridSize() const {
void Shell::InitRootWindowForSecondaryMonitor(aura::RootWindow* root) {
root->set_focus_manager(focus_manager_.get());
- root->SetFocusWhenShown(false);
- root->SetLayoutManager(new internal::RootWindowLayoutManager(root));
- aura::Window* container = new aura::Window(NULL);
- container->SetName("SecondaryMonitorContainer");
- container->Init(ui::LAYER_NOT_DRAWN);
- root->AddChild(container);
- container->SetLayoutManager(new internal::BaseLayoutManager(root));
- CreateSecondaryMonitorWidget(container);
- container->Show();
- root->layout_manager()->OnWindowResized();
- root->ShowRootWindow();
-
- aura::client::SetCaptureClient(root, capture_controller_.get());
-}
-
-void Shell::InitRootWindow(aura::RootWindow* root_window) {
+ if (internal::MonitorController::IsExtendedDesktopEnabled()) {
+ internal::RootWindowController* controller =
+ new internal::RootWindowController(root);
+ controller->CreateContainers();
+ InitRootWindowController(controller);
+ controller->root_window_layout()->OnWindowResized();
+ root->ShowRootWindow();
+ // Activate new root for testing.
+ active_root_window_ = root;
+ } else {
+ root->SetFocusWhenShown(false);
+ root->SetLayoutManager(new internal::RootWindowLayoutManager(root));
+ aura::Window* container = new aura::Window(NULL);
+ container->SetName("SecondaryMonitorContainer");
+ container->Init(ui::LAYER_NOT_DRAWN);
+ root->AddChild(container);
+ container->SetLayoutManager(new internal::BaseLayoutManager(root));
+ CreateSecondaryMonitorWidget(container);
+ container->Show();
+ root->layout_manager()->OnWindowResized();
+ root->ShowRootWindow();
+ aura::client::SetCaptureClient(root, capture_controller_.get());
+ }
+}
+
+void Shell::InitRootWindowController(
+ internal::RootWindowController* controller) {
+ aura::RootWindow* root_window = controller->root_window();
DCHECK(activation_controller_.get());
DCHECK(visibility_controller_.get());
DCHECK(drag_drop_controller_.get());
@@ -642,7 +670,7 @@ void Shell::InitRootWindow(aura::RootWindow* root_window) {
aura::client::SetUserActionClient(root_window, user_action_client_.get());
root_window->SetCursor(ui::kCursorPointer);
- root_window_controller_->InitLayoutManagers();
+ controller->InitLayoutManagers();
}
////////////////////////////////////////////////////////////////////////////////
@@ -686,17 +714,24 @@ void Shell::InitLayoutManagersForPrimaryDisplay(
}
void Shell::DisableWorkspaceGridLayout() {
- GetPrimaryRootWindowController()->
- workspace_controller()->workspace_manager()->set_grid_size(0);
+ RootWindowControllerList controllers = GetAllRootWindowControllers();
+ for (RootWindowControllerList::iterator iter = controllers.begin();
+ iter != controllers.end(); ++iter)
+ (*iter)->workspace_controller()->workspace_manager()->set_grid_size(0);
}
void Shell::SetCursor(gfx::NativeCursor cursor) {
- // TODO(oshima): set cursor to all root windows.
- GetPrimaryRootWindow()->SetCursor(cursor);
+ RootWindowList root_windows = GetAllRootWindows();
+ for (RootWindowList::iterator iter = root_windows.begin();
+ iter != root_windows.end(); ++iter)
+ (*iter)->SetCursor(cursor);
}
void Shell::ShowCursor(bool visible) {
- GetPrimaryRootWindow()->ShowCursor(visible);
+ RootWindowList root_windows = GetAllRootWindows();
+ for (RootWindowList::iterator iter = root_windows.begin();
+ iter != root_windows.end(); ++iter)
+ (*iter)->ShowCursor(visible);
}
} // namespace ash