| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura_shell/default_container_layout_manager.h" | 5 #include "ui/aura_shell/default_container_layout_manager.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/aura_constants.h" | 7 #include "ui/aura/client/aura_constants.h" |
| 8 #include "ui/aura/event.h" | 8 #include "ui/aura/event.h" |
| 9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
| 10 #include "ui/aura/screen_aura.h" | 10 #include "ui/aura/screen_aura.h" |
| 11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
| 13 #include "ui/aura/window_types.h" | |
| 14 #include "ui/aura_shell/property_util.h" | 13 #include "ui/aura_shell/property_util.h" |
| 15 #include "ui/aura_shell/show_state_controller.h" | 14 #include "ui/aura_shell/show_state_controller.h" |
| 16 #include "ui/aura_shell/window_util.h" | 15 #include "ui/aura_shell/window_util.h" |
| 17 #include "ui/aura_shell/workspace/workspace.h" | 16 #include "ui/aura_shell/workspace/workspace.h" |
| 18 #include "ui/aura_shell/workspace/workspace_manager.h" | 17 #include "ui/aura_shell/workspace/workspace_manager.h" |
| 19 #include "ui/base/ui_base_types.h" | 18 #include "ui/base/ui_base_types.h" |
| 20 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
| 21 #include "ui/views/widget/native_widget_aura.h" | 20 #include "ui/views/widget/native_widget_aura.h" |
| 22 | 21 |
| 23 namespace aura_shell { | 22 namespace aura_shell { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 88 } |
| 90 | 89 |
| 91 //////////////////////////////////////////////////////////////////////////////// | 90 //////////////////////////////////////////////////////////////////////////////// |
| 92 // DefaultContainerLayoutManager, aura::LayoutManager implementation: | 91 // DefaultContainerLayoutManager, aura::LayoutManager implementation: |
| 93 | 92 |
| 94 void DefaultContainerLayoutManager::OnWindowResized() { | 93 void DefaultContainerLayoutManager::OnWindowResized() { |
| 95 // Workspace is updated via RootWindowObserver::OnRootWindowResized. | 94 // Workspace is updated via RootWindowObserver::OnRootWindowResized. |
| 96 } | 95 } |
| 97 | 96 |
| 98 void DefaultContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 97 void DefaultContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| 99 if (child->type() != aura::WINDOW_TYPE_NORMAL || child->transient_parent()) | 98 if (child->type() != aura::client::WINDOW_TYPE_NORMAL || |
| 99 child->transient_parent()) { |
| 100 return; | 100 return; |
| 101 } |
| 101 | 102 |
| 102 if (!child->GetProperty(aura::kShowStateKey)) | 103 if (!child->GetProperty(aura::client::kShowStateKey)) |
| 103 child->SetIntProperty(aura::kShowStateKey, ui::SHOW_STATE_NORMAL); | 104 child->SetIntProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 104 | 105 |
| 105 child->AddObserver(show_state_controller_.get()); | 106 child->AddObserver(show_state_controller_.get()); |
| 106 | 107 |
| 107 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); | 108 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); |
| 108 if (workspace) { | 109 if (workspace) { |
| 109 aura::Window* active = aura_shell::GetActiveWindow(); | 110 aura::Window* active = aura_shell::GetActiveWindow(); |
| 110 // Active window may not be in the default container layer. | 111 // Active window may not be in the default container layer. |
| 111 if (!workspace->Contains(active)) | 112 if (!workspace->Contains(active)) |
| 112 active = NULL; | 113 active = NULL; |
| 113 if (workspace->AddWindowAfter(child, active)) | 114 if (workspace->AddWindowAfter(child, active)) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 137 bool visible) { | 138 bool visible) { |
| 138 NOTIMPLEMENTED(); | 139 NOTIMPLEMENTED(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void DefaultContainerLayoutManager::SetChildBounds( | 142 void DefaultContainerLayoutManager::SetChildBounds( |
| 142 aura::Window* child, | 143 aura::Window* child, |
| 143 const gfx::Rect& requested_bounds) { | 144 const gfx::Rect& requested_bounds) { |
| 144 gfx::Rect adjusted_bounds = requested_bounds; | 145 gfx::Rect adjusted_bounds = requested_bounds; |
| 145 | 146 |
| 146 // First, calculate the adjusted bounds. | 147 // First, calculate the adjusted bounds. |
| 147 if (child->type() != aura::WINDOW_TYPE_NORMAL || | 148 if (child->type() != aura::client::WINDOW_TYPE_NORMAL || |
| 148 workspace_manager_->layout_in_progress() || | 149 workspace_manager_->layout_in_progress() || |
| 149 child->transient_parent()) { | 150 child->transient_parent()) { |
| 150 // Use the requested bounds as is. | 151 // Use the requested bounds as is. |
| 151 } else if (child == workspace_manager_->ignored_window()) { | 152 } else if (child == workspace_manager_->ignored_window()) { |
| 152 // If a drag window is requesting bounds, make sure its attached to | 153 // If a drag window is requesting bounds, make sure its attached to |
| 153 // the workarea's top and fits within the total drag area. | 154 // the workarea's top and fits within the total drag area. |
| 154 gfx::Rect drag_area = workspace_manager_->GetDragAreaBounds(); | 155 gfx::Rect drag_area = workspace_manager_->GetDragAreaBounds(); |
| 155 adjusted_bounds.set_y(drag_area.y()); | 156 adjusted_bounds.set_y(drag_area.y()); |
| 156 adjusted_bounds = adjusted_bounds.AdjustToFit(drag_area); | 157 adjusted_bounds = adjusted_bounds.AdjustToFit(drag_area); |
| 157 } else { | 158 } else { |
| 158 Workspace* workspace = workspace_manager_->FindBy(child); | 159 Workspace* workspace = workspace_manager_->FindBy(child); |
| 159 gfx::Rect work_area = workspace->GetWorkAreaBounds(); | 160 gfx::Rect work_area = workspace->GetWorkAreaBounds(); |
| 160 adjusted_bounds.set_origin( | 161 adjusted_bounds.set_origin( |
| 161 gfx::Point(child->GetTargetBounds().x(), work_area.y())); | 162 gfx::Point(child->GetTargetBounds().x(), work_area.y())); |
| 162 adjusted_bounds = adjusted_bounds.AdjustToFit(work_area); | 163 adjusted_bounds = adjusted_bounds.AdjustToFit(work_area); |
| 163 } | 164 } |
| 164 | 165 |
| 165 ui::WindowShowState show_state = static_cast<ui::WindowShowState>( | 166 ui::WindowShowState show_state = static_cast<ui::WindowShowState>( |
| 166 child->GetIntProperty(aura::kShowStateKey)); | 167 child->GetIntProperty(aura::client::kShowStateKey)); |
| 167 | 168 |
| 168 // Second, check if the window is either maximized or in fullscreen mode. | 169 // Second, check if the window is either maximized or in fullscreen mode. |
| 169 if (show_state == ui::SHOW_STATE_MAXIMIZED || | 170 if (show_state == ui::SHOW_STATE_MAXIMIZED || |
| 170 show_state == ui::SHOW_STATE_FULLSCREEN) { | 171 show_state == ui::SHOW_STATE_FULLSCREEN) { |
| 171 // If the request is not from workspace manager, | 172 // If the request is not from workspace manager, |
| 172 // remember the requested bounds. | 173 // remember the requested bounds. |
| 173 if (!workspace_manager_->layout_in_progress()) | 174 if (!workspace_manager_->layout_in_progress()) |
| 174 SetRestoreBounds(child, adjusted_bounds); | 175 SetRestoreBounds(child, adjusted_bounds); |
| 175 | 176 |
| 176 Workspace* workspace = workspace_manager_->FindBy(child); | 177 Workspace* workspace = workspace_manager_->FindBy(child); |
| 177 if (show_state == ui::SHOW_STATE_MAXIMIZED) | 178 if (show_state == ui::SHOW_STATE_MAXIMIZED) |
| 178 adjusted_bounds = workspace->GetWorkAreaBounds(); | 179 adjusted_bounds = workspace->GetWorkAreaBounds(); |
| 179 else | 180 else |
| 180 adjusted_bounds = workspace->bounds(); | 181 adjusted_bounds = workspace->bounds(); |
| 181 // Don't | 182 // Don't |
| 182 if (child->GetTargetBounds() == adjusted_bounds) | 183 if (child->GetTargetBounds() == adjusted_bounds) |
| 183 return; | 184 return; |
| 184 } | 185 } |
| 185 SetChildBoundsDirect(child, adjusted_bounds); | 186 SetChildBoundsDirect(child, adjusted_bounds); |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace internal | 189 } // namespace internal |
| 189 } // namespace aura_shell | 190 } // namespace aura_shell |
| OLD | NEW |