Chromium Code Reviews| Index: ash/shell.cc |
| diff --git a/ash/shell.cc b/ash/shell.cc |
| index 1b065669974cd22ada29c2081cfeb05916ee7a6b..59582e9e199c76cc11610ad79ab0a9465706a938 100644 |
| --- a/ash/shell.cc |
| +++ b/ash/shell.cc |
| @@ -57,6 +57,7 @@ namespace ash { |
| namespace { |
| +using aura::Window; |
| using views::Widget; |
| // Screen width at or below which we automatically start in compact window mode, |
| @@ -186,9 +187,11 @@ Shell::Shell(ShellDelegate* delegate) |
| status_widget_(NULL) { |
| aura::RootWindow::GetInstance()->SetEventFilter( |
| new internal::RootWindowEventFilter); |
| + aura::RootWindow::GetInstance()->AddRootWindowObserver(this); |
| } |
| Shell::~Shell() { |
| + aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this); |
| RemoveRootWindowEventFilter(input_method_filter_.get()); |
| RemoveRootWindowEventFilter(window_modality_controller_.get()); |
| RemoveRootWindowEventFilter(accelerator_filter_.get()); |
| @@ -252,6 +255,21 @@ void Shell::DeleteInstance() { |
| instance_ = NULL; |
| } |
| +void Shell::OnRootWindowResized(const gfx::Size& new_size) { |
| + // Developers often run the Aura shell in small windows on their desktop. |
| + // Don't switch window modes for them. |
| + if (!aura::RootWindow::use_fullscreen_host_window()) |
| + return; |
| + |
| + // If we're running on a device, a resize event means the user plugged in or |
| + // unplugged an external monitor. Change window mode to be appropriate for |
| + // the new screen resolution. |
| + gfx::Size monitor_size = gfx::Screen::GetPrimaryMonitorSize(); |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + WindowMode new_mode = ComputeWindowMode(monitor_size, command_line); |
| + ChangeWindowMode(new_mode); |
| +} |
| + |
| void Shell::Init() { |
| // InputMethodEventFilter must be added first since it has the highest |
| // priority. |
| @@ -401,8 +419,15 @@ void Shell::ChangeWindowMode(WindowMode mode) { |
| SetupCompactWindowMode(); |
| else |
| SetupNonCompactWindowMode(); |
| - // Force a layout. |
| - aura::RootWindow::GetInstance()->layout_manager()->OnWindowResized(); |
| + // Force a layout of all containers. |
| + aura::RootWindow* root_window = aura::RootWindow::GetInstance(); |
| + root_window->layout_manager()->OnWindowResized(); |
| + for (Window::Windows::const_iterator it = root_window->children().begin(); |
|
sky
2012/02/03 21:47:42
Don't the children handle this themselves?
James Cook
2012/02/03 22:02:44
They do, but too early for it to be useful for me.
|
| + it != root_window->children().end(); |
| + ++it) { |
| + if ((*it)->layout_manager()) |
| + (*it)->layout_manager()->OnWindowResized(); |
| + } |
| } |
| bool Shell::IsScreenLocked() const { |