diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 23:19:12 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-01 23:19:12 +0000 |
commit | 37974ad4ffcf30f18c25c28e9dccd098ab5e71d8 (patch) | |
tree | 808da500f37170706e695c9a029a1b649a1a87bc /ui/aura_shell/default_container_layout_manager.cc | |
parent | e8ba615ab61359130553c7dd6419c331be5c49ad (diff) | |
download | chromium_src-37974ad4ffcf30f18c25c28e9dccd098ab5e71d8.zip chromium_src-37974ad4ffcf30f18c25c28e9dccd098ab5e71d8.tar.gz chromium_src-37974ad4ffcf30f18c25c28e9dccd098ab5e71d8.tar.bz2 |
Move maximize/fullscreen/restore to shell
With this CL, window is now correctly maximized/fullscreen'ed on aura desktop.
* Added OnPropertyChanged to WindowObserver
* Added Get/Set IntProperty to simplify handling int value properties.
* Remove IsOrContainsFullscreen. Added Workspace::ContainsFullscreen instead. We need this to autohide launcher.
BUG=97257,97259
TEST=new test for property change notification. existing tests are updated, except maximized/fullscreen drag test. I'll add it to new set of tests that verifies window dragging within workspace.
Review URL: http://codereview.chromium.org/8400063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura_shell/default_container_layout_manager.cc')
-rw-r--r-- | ui/aura_shell/default_container_layout_manager.cc | 71 |
1 files changed, 54 insertions, 17 deletions
diff --git a/ui/aura_shell/default_container_layout_manager.cc b/ui/aura_shell/default_container_layout_manager.cc index 54b6f53..d9658e0 100644 --- a/ui/aura_shell/default_container_layout_manager.cc +++ b/ui/aura_shell/default_container_layout_manager.cc @@ -5,13 +5,18 @@ #include "ui/aura_shell/default_container_layout_manager.h" #include "base/auto_reset.h" +#include "ui/aura/aura_constants.h" #include "ui/aura/desktop.h" #include "ui/aura/event.h" #include "ui/aura/window.h" #include "ui/aura/screen_aura.h" #include "ui/aura/window_types.h" +#include "ui/aura/window_observer.h" +#include "ui/aura_shell/property_util.h" +#include "ui/aura_shell/show_state_controller.h" #include "ui/aura_shell/workspace/workspace.h" #include "ui/aura_shell/workspace/workspace_manager.h" +#include "ui/base/ui_base_types.h" #include "ui/gfx/rect.h" #include "views/widget/native_widget_aura.h" @@ -27,7 +32,8 @@ DefaultContainerLayoutManager::DefaultContainerLayoutManager( : owner_(owner), workspace_manager_(workspace_manager), drag_window_(NULL), - ignore_calculate_bounds_(false) { + ignore_calculate_bounds_(false), + show_state_controller_(new ShowStateController(this)) { } DefaultContainerLayoutManager::~DefaultContainerLayoutManager() {} @@ -102,6 +108,11 @@ void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { if (child->type() != aura::WINDOW_TYPE_NORMAL || child->transient_parent()) return; + if (!child->GetProperty(aura::kShowStateKey)) + child->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); + + child->AddObserver(show_state_controller_.get()); + AutoReset<bool> reset(&ignore_calculate_bounds_, true); Workspace* workspace = workspace_manager_->GetActiveWorkspace(); @@ -121,6 +132,9 @@ void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { void DefaultContainerLayoutManager::OnWillRemoveWindow(aura::Window* child) { AutoReset<bool> reset(&ignore_calculate_bounds_, true); + child->RemoveObserver(show_state_controller_.get()); + ClearRestoreBounds(child); + Workspace* workspace = workspace_manager_->FindBy(child); if (!workspace) return; @@ -135,28 +149,51 @@ void DefaultContainerLayoutManager::OnChildWindowVisibilityChanged( NOTIMPLEMENTED(); } -void DefaultContainerLayoutManager::CalculateBoundsForChild( +void DefaultContainerLayoutManager::SetChildBounds( aura::Window* child, - gfx::Rect* requested_bounds) { + const gfx::Rect& requested_bounds) { + gfx::Rect adjusted_bounds = requested_bounds; + + // First, calculate the adjusted bounds. if (child->type() != aura::WINDOW_TYPE_NORMAL || ignore_calculate_bounds_ || - child->transient_parent()) - return; - - // If a drag window is requesting bounds, make sure its attached to - // the workarea's top and fits within the total drag area. - if (drag_window_) { + child->transient_parent()) { + // Use the requested bounds as is. + } else if (drag_window_) { + // If a drag window is requesting bounds, make sure its attached to + // the workarea's top and fits within the total drag area. gfx::Rect drag_area = workspace_manager_->GetDragAreaBounds(); - requested_bounds->set_y(drag_area.y()); - *requested_bounds = requested_bounds->AdjustToFit(drag_area); - return; + adjusted_bounds.set_y(drag_area.y()); + adjusted_bounds = adjusted_bounds.AdjustToFit(drag_area); + } else { + Workspace* workspace = workspace_manager_->FindBy(child); + gfx::Rect work_area = workspace->GetWorkAreaBounds(); + adjusted_bounds.set_origin( + gfx::Point(child->GetTargetBounds().x(), work_area.y())); + adjusted_bounds = adjusted_bounds.AdjustToFit(work_area); } - Workspace* workspace = workspace_manager_->FindBy(child); - gfx::Rect work_area = workspace->GetWorkAreaBounds(); - requested_bounds->set_origin( - gfx::Point(child->GetTargetBounds().x(), work_area.y())); - *requested_bounds = requested_bounds->AdjustToFit(work_area); + ui::WindowShowState show_state = static_cast<ui::WindowShowState>( + child->GetIntProperty(aura::kShowStateKey)); + + // Second, check if the window is either maximized or in fullscreen mode. + if (show_state == ui::SHOW_STATE_MAXIMIZED || + show_state == ui::SHOW_STATE_FULLSCREEN) { + // If the request is not from workspace manager, + // remember the requested bounds. + if (!ignore_calculate_bounds_) + SetRestoreBounds(child, adjusted_bounds); + + Workspace* workspace = workspace_manager_->FindBy(child); + if (show_state == ui::SHOW_STATE_MAXIMIZED) + adjusted_bounds = workspace->GetWorkAreaBounds(); + else + adjusted_bounds = workspace->bounds(); + // Don't + if (child->GetTargetBounds() == adjusted_bounds) + return; + } + SetChildBoundsDirect(child, adjusted_bounds); } } // namespace internal |