Chromium Code Reviews| Index: ui/aura_shell/show_state_controller.cc |
| diff --git a/ui/aura_shell/show_state_controller.cc b/ui/aura_shell/show_state_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8e08d3514e3f754da8c17d740a7e89c10b97ec1f |
| --- /dev/null |
| +++ b/ui/aura_shell/show_state_controller.cc |
| @@ -0,0 +1,50 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/aura_shell/show_state_controller.h" |
| + |
| +#include "ui/aura/aura_constants.h" |
| +#include "ui/aura/window.h" |
| +#include "ui/aura_shell/default_container_layout_manager.h" |
| +#include "ui/aura_shell/workspace/workspace.h" |
| +#include "ui/aura_shell/workspace/workspace_manager.h" |
| +#include "ui/base/ui_base_types.h" |
| + |
| +namespace aura_shell { |
| +namespace internal { |
| + |
| +ShowStateController::ShowStateController( |
| + DefaultContainerLayoutManager* layout_manager) |
| + : layout_manager_(layout_manager) { |
| +} |
| + |
| +ShowStateController::~ShowStateController() { |
| +} |
| + |
| +void ShowStateController::OnPropertyChanged(aura::Window* window, |
| + const char* name, |
| + void* old) OVERRIDE { |
| + if (name != aura::kShowStateKey) |
| + return; |
| + if (window->GetIntProperty(name) == ui::SHOW_STATE_NORMAL) { |
| + // Restore the size of window first, then let Workspace layout the window. |
| + gfx::Rect* restore = |
| + static_cast<gfx::Rect*>(window->GetProperty(aura::kRestoreBoundsKey)); |
|
sky
2011/10/31 23:17:34
This is accessed in a number of places. Could you
oshima
2011/11/01 00:40:33
I thought about it but didn't do it (for now) for
|
| + window->SetProperty(aura::kRestoreBoundsKey, NULL); |
| + if (restore) window->SetBounds(*restore); |
|
sky
2011/10/31 23:17:34
split into two lines.
oshima
2011/11/01 00:40:33
Done.
|
| + delete restore; |
| + } else if (old == reinterpret_cast<void*>(ui::SHOW_STATE_NORMAL)) { |
| + // Store the restore bounds only if previous state is normal. |
| + DCHECK(window->GetProperty(aura::kRestoreBoundsKey) == NULL); |
| + window->SetProperty(aura::kRestoreBoundsKey, |
| + new gfx::Rect(window->GetTargetBounds())); |
| + } |
| + |
| + layout_manager_->set_ignore_calculate_bounds(true); |
| + layout_manager_->workspace_manager()->FindBy(window)->Layout(NULL, window); |
| + layout_manager_->set_ignore_calculate_bounds(false); |
| +} |
| + |
| +} // namespace internal |
| +} // namespace aura_shell |