| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/desktop.h" |
| 9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 93 } |
| 94 | 94 |
| 95 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
| 96 // DefaultContainerLayoutManager, aura::LayoutManager implementation: | 96 // DefaultContainerLayoutManager, aura::LayoutManager implementation: |
| 97 | 97 |
| 98 void DefaultContainerLayoutManager::OnWindowResized() { | 98 void DefaultContainerLayoutManager::OnWindowResized() { |
| 99 // Workspace is updated via DesktopObserver::OnDesktopResized. | 99 // Workspace is updated via DesktopObserver::OnDesktopResized. |
| 100 } | 100 } |
| 101 | 101 |
| 102 void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { | 102 void DefaultContainerLayoutManager::OnWindowAdded(aura::Window* child) { |
| 103 intptr_t type = reinterpret_cast<intptr_t>( | 103 if (child->type() != aura::WINDOW_TYPE_NORMAL || child->transient_parent()) |
| 104 ui::ViewProp::GetValue(child, views::NativeWidgetAura::kWindowTypeKey)); | |
| 105 if (type != views::Widget::InitParams::TYPE_WINDOW || | |
| 106 child->transient_parent()) | |
| 107 return; | 104 return; |
| 108 | 105 |
| 109 AutoReset<bool> reset(&ignore_calculate_bounds_, true); | 106 AutoReset<bool> reset(&ignore_calculate_bounds_, true); |
| 110 | 107 |
| 111 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); | 108 Workspace* workspace = workspace_manager_->GetActiveWorkspace(); |
| 112 if (workspace) { | 109 if (workspace) { |
| 113 aura::Window* active = aura::Desktop::GetInstance()->active_window(); | 110 aura::Window* active = aura::Desktop::GetInstance()->active_window(); |
| 114 // Active window may not be in the default container layer. | 111 // Active window may not be in the default container layer. |
| 115 if (!workspace->Contains(active)) | 112 if (!workspace->Contains(active)) |
| 116 active = NULL; | 113 active = NULL; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 135 | 132 |
| 136 void DefaultContainerLayoutManager::OnChildWindowVisibilityChanged( | 133 void DefaultContainerLayoutManager::OnChildWindowVisibilityChanged( |
| 137 aura::Window* child, | 134 aura::Window* child, |
| 138 bool visible) { | 135 bool visible) { |
| 139 NOTIMPLEMENTED(); | 136 NOTIMPLEMENTED(); |
| 140 } | 137 } |
| 141 | 138 |
| 142 void DefaultContainerLayoutManager::CalculateBoundsForChild( | 139 void DefaultContainerLayoutManager::CalculateBoundsForChild( |
| 143 aura::Window* child, | 140 aura::Window* child, |
| 144 gfx::Rect* requested_bounds) { | 141 gfx::Rect* requested_bounds) { |
| 145 intptr_t type = reinterpret_cast<intptr_t>( | 142 if (child->type() != aura::WINDOW_TYPE_NORMAL || |
| 146 ui::ViewProp::GetValue(child, views::NativeWidgetAura::kWindowTypeKey)); | 143 ignore_calculate_bounds_ || |
| 147 if (type != views::Widget::InitParams::TYPE_WINDOW || | 144 child->transient_parent()) |
| 148 ignore_calculate_bounds_ || child->transient_parent()) | |
| 149 return; | 145 return; |
| 150 | 146 |
| 151 // If a drag window is requesting bounds, make sure its attached to | 147 // If a drag window is requesting bounds, make sure its attached to |
| 152 // the workarea's top and fits within the total drag area. | 148 // the workarea's top and fits within the total drag area. |
| 153 if (drag_window_) { | 149 if (drag_window_) { |
| 154 gfx::Rect drag_area = workspace_manager_->GetDragAreaBounds(); | 150 gfx::Rect drag_area = workspace_manager_->GetDragAreaBounds(); |
| 155 requested_bounds->set_y(drag_area.y()); | 151 requested_bounds->set_y(drag_area.y()); |
| 156 *requested_bounds = requested_bounds->AdjustToFit(drag_area); | 152 *requested_bounds = requested_bounds->AdjustToFit(drag_area); |
| 157 return; | 153 return; |
| 158 } | 154 } |
| 159 | 155 |
| 160 Workspace* workspace = workspace_manager_->FindBy(child); | 156 Workspace* workspace = workspace_manager_->FindBy(child); |
| 161 gfx::Rect work_area = workspace->GetWorkAreaBounds(); | 157 gfx::Rect work_area = workspace->GetWorkAreaBounds(); |
| 162 requested_bounds->set_origin( | 158 requested_bounds->set_origin( |
| 163 gfx::Point(child->GetTargetBounds().x(), work_area.y())); | 159 gfx::Point(child->GetTargetBounds().x(), work_area.y())); |
| 164 *requested_bounds = requested_bounds->AdjustToFit(work_area); | 160 *requested_bounds = requested_bounds->AdjustToFit(work_area); |
| 165 } | 161 } |
| 166 | 162 |
| 167 } // namespace internal | 163 } // namespace internal |
| 168 } // namespace aura_shell | 164 } // namespace aura_shell |
| OLD | NEW |