Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Unified Diff: ui/aura_shell/default_container_layout_manager.cc

Issue 8400063: Move maximize/fullscreen/restore to shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready for review Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/aura_shell/default_container_layout_manager.cc
diff --git a/ui/aura_shell/default_container_layout_manager.cc b/ui/aura_shell/default_container_layout_manager.cc
index 98d3dc31bd0eddcb7dd6756d7ac40c3bee292c0e..654ac6472448245d705adc8cb9ba8473e6f75917 100644
--- a/ui/aura_shell/default_container_layout_manager.cc
+++ b/ui/aura_shell/default_container_layout_manager.cc
@@ -5,17 +5,30 @@
#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/show_state_controller.h"
#include "ui/aura_shell/workspace/workspace.h"
#include "ui/aura_shell/workspace/workspace_manager.h"
-#include "ui/base/view_prop.h"
+#include "ui/base/ui_base_types.h"
#include "ui/gfx/rect.h"
#include "views/widget/native_widget_aura.h"
+namespace {
+
+// Removes and deletes restore bounds property.
+void ClearRestoreBounds(aura::Window* child) {
+ delete static_cast<gfx::Rect*>(child->GetProperty(aura::kRestoreBoundsKey));
+ child->SetProperty(aura::kRestoreBoundsKey, NULL);
+}
+
+} // namespace
+
namespace aura_shell {
namespace internal {
@@ -28,7 +41,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() {}
sky 2011/10/31 23:17:34 Should this iterate over all top level windows des
oshima 2011/11/01 00:40:33 They're deleted in OnWillRemoveWindow, which is ca
@@ -100,11 +114,16 @@ void DefaultContainerLayoutManager::OnWindowResized() {
}
void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) {
- intptr_t type = reinterpret_cast<intptr_t>(
- ui::ViewProp::GetValue(child, views::NativeWidgetAura::kWindowTypeKey));
- if (type != views::Widget::InitParams::TYPE_WINDOW)
+
+ if (child->GetIntProperty(views::NativeWidgetAura::kWindowTypeKey) !=
+ views::Widget::InitParams::TYPE_WINDOW)
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();
@@ -124,6 +143,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;
@@ -138,29 +160,54 @@ void DefaultContainerLayoutManager::OnChildWindowVisibilityChanged(
NOTIMPLEMENTED();
}
-void DefaultContainerLayoutManager::CalculateBoundsForChild(
+void DefaultContainerLayoutManager::SetChildBounds(
aura::Window* child,
- gfx::Rect* requested_bounds) {
- intptr_t type = reinterpret_cast<intptr_t>(
- ui::ViewProp::GetValue(child, views::NativeWidgetAura::kWindowTypeKey));
- if (type != views::Widget::InitParams::TYPE_WINDOW ||
- ignore_calculate_bounds_)
- 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_) {
+ const gfx::Rect& requested_bounds) {
+ gfx::Rect adjusted_bounds = requested_bounds;
+
+ // First, calculate the adjusted bounds.
+ if (child->GetIntProperty(views::NativeWidgetAura::kWindowTypeKey) !=
+ views::Widget::InitParams::TYPE_WINDOW ||
sky 2011/10/31 23:17:34 Make sure you ignore windows with a transient pare
oshima 2011/11/01 00:40:33 I need your change. Is it checked in?
oshima 2011/11/01 00:52:30 Sorry this is old comment. Done.
+ ignore_calculate_bounds_) {
+ // 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_) {
+ ClearRestoreBounds(child);
+ child->SetProperty(aura::kRestoreBoundsKey,
+ new gfx::Rect(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

Powered by Google App Engine
This is Rietveld 408576698