Chromium Code Reviews| Index: athena/wm/window_manager_impl.cc |
| diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc |
| index 3e6e3904f63c3010949e1e95bfaf866ddf3bb69b..4dc1a307a656f9b71a1906c0e63fd361dfe37574 100644 |
| --- a/athena/wm/window_manager_impl.cc |
| +++ b/athena/wm/window_manager_impl.cc |
| @@ -16,8 +16,10 @@ |
| #include "athena/wm/window_overview_mode.h" |
| #include "base/bind.h" |
| #include "base/logging.h" |
| +#include "ui/aura/client/aura_constants.h" |
| #include "ui/aura/layout_manager.h" |
| #include "ui/aura/window.h" |
| +#include "ui/aura/window_delegate.h" |
| #include "ui/compositor/closure_animation_observer.h" |
| #include "ui/compositor/scoped_layer_animation_settings.h" |
| #include "ui/gfx/display.h" |
| @@ -40,6 +42,16 @@ void SetWindowState(aura::Window* window, |
| window->SetTransform(transform); |
| } |
| +// Tests whether the given window can be maximized |
| +bool CanWindowMaximize(const aura::Window* const window) { |
| + const aura::WindowDelegate* delegate = window->delegate(); |
| + const bool no_max_size = |
| + !delegate || delegate->GetMaximumSize().IsEmpty(); |
| + return (no_max_size && |
| + window->GetProperty(aura::client::kCanMaximizeKey) && |
| + window->GetProperty(aura::client::kCanResizeKey)); |
|
oshima
2014/10/24 18:39:55
nit: we don't use outmost () unless it's complicat
afakhry
2014/10/25 00:35:08
Done.
|
| +} |
| + |
| } // namespace |
| class AthenaContainerLayoutManager : public aura::LayoutManager { |
| @@ -91,10 +103,13 @@ void AthenaContainerLayoutManager::OnWindowResized() { |
| else if (window == instance->split_view_controller_->right_window()) |
| window->SetBounds( |
| gfx::Rect(gfx::Point(split_size.width(), 0), split_size)); |
| - else |
| - window->SetBounds(gfx::Rect(work_area)); |
| + else { |
| + if (CanWindowMaximize(window)) |
|
oshima
2014/10/24 18:39:56
else if
afakhry
2014/10/25 00:35:08
Done.
|
| + window->SetBounds(gfx::Rect(work_area)); |
| + } |
| } else { |
| - window->SetBounds(gfx::Rect(work_area)); |
| + if (CanWindowMaximize(window)) |
|
oshima
2014/10/24 18:39:56
ditto
afakhry
2014/10/25 00:35:08
Done.
|
| + window->SetBounds(gfx::Rect(work_area)); |
| } |
| } |
| } |
| @@ -138,6 +153,19 @@ void AthenaContainerLayoutManager::OnWindowRemovedFromLayout( |
| void AthenaContainerLayoutManager::OnChildWindowVisibilityChanged( |
| aura::Window* child, |
| bool visible) { |
| + if (visible && CanWindowMaximize(child)) { |
| + // Make sure we're resizing a window that actually exists in the window list |
| + // to avoid resizing the divider in the split mode. |
| + const aura::Window::Windows& list = instance->window_list_provider_ |
| + ->GetWindowList(); |
| + aura::Window::Windows::const_iterator itr = std::find(list.cbegin(), |
| + list.cend(), child); |
| + |
| + if (itr != list.end()) { |
| + child->SetBounds( |
| + gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area()); |
| + } |
|
oshima
2014/10/24 18:39:56
Can you add
// TODO(oshima): Fix WindowListProvid
oshima
2014/10/24 21:37:28
Actually, you should be able to just use InWnidowI
afakhry
2014/10/25 00:35:08
Done.
|
| + } |
| } |
| void AthenaContainerLayoutManager::SetChildBounds( |
| @@ -304,7 +332,11 @@ void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
| // resized. |
| const gfx::Size work_area = |
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
| - if (window->GetTargetBounds().size() != work_area) { |
| + |
| + // Resize to the screen bounds only if the window is maximize-able, and |
| + // is not already maximized |
| + if (window->GetTargetBounds().size() != work_area && |
| + CanWindowMaximize(window)) { |
| const gfx::Rect& window_bounds = window->bounds(); |
| const gfx::Rect desired_bounds(work_area); |
| gfx::Transform transform; |