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