OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/panels/panel_window_resizer.h" | 5 #include "ash/wm/panels/panel_window_resizer.h" |
6 | 6 |
7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
8 #include "ash/public/cpp/window_properties.h" | 8 #include "ash/public/cpp/window_properties.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/wm_shelf.h" | 10 #include "ash/shelf/wm_shelf.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (GetTarget()->parent() != panel_container_) | 60 if (GetTarget()->parent() != panel_container_) |
61 GetPanelLayoutManager()->FinishDragging(); | 61 GetPanelLayoutManager()->FinishDragging(); |
62 aura::Window* dst_root = | 62 aura::Window* dst_root = |
63 Shell::GetRootWindowControllerWithDisplayId(dst_display.id()) | 63 Shell::GetRootWindowControllerWithDisplayId(dst_display.id()) |
64 ->GetRootWindow(); | 64 ->GetRootWindow(); |
65 panel_container_ = dst_root->GetChildById(kShellWindowId_PanelContainer); | 65 panel_container_ = dst_root->GetChildById(kShellWindowId_PanelContainer); |
66 | 66 |
67 // The panel's parent already knows that the drag is in progress for this | 67 // The panel's parent already knows that the drag is in progress for this |
68 // panel. | 68 // panel. |
69 if (panel_container_ && GetTarget()->parent() != panel_container_) | 69 if (panel_container_ && GetTarget()->parent() != panel_container_) |
70 GetPanelLayoutManager()->StartDragging(WmWindow::Get(GetTarget())); | 70 GetPanelLayoutManager()->StartDragging(GetTarget()); |
71 } | 71 } |
72 gfx::Point offset; | 72 gfx::Point offset; |
73 gfx::Rect bounds(CalculateBoundsForDrag(location)); | 73 gfx::Rect bounds(CalculateBoundsForDrag(location)); |
74 if (!(details().bounds_change & WindowResizer::kBoundsChange_Resizes)) { | 74 if (!(details().bounds_change & WindowResizer::kBoundsChange_Resizes)) { |
75 window_state_->drag_details()->should_attach_to_shelf = | 75 window_state_->drag_details()->should_attach_to_shelf = |
76 AttachToLauncher(bounds, &offset); | 76 AttachToLauncher(bounds, &offset); |
77 } | 77 } |
78 gfx::Point modified_location(location.x() + offset.x(), | 78 gfx::Point modified_location(location.x() + offset.x(), |
79 location.y() + offset.y()); | 79 location.y() + offset.y()); |
80 | 80 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 break; | 149 break; |
150 } | 150 } |
151 } | 151 } |
152 return should_attach; | 152 return should_attach; |
153 } | 153 } |
154 | 154 |
155 void PanelWindowResizer::StartedDragging() { | 155 void PanelWindowResizer::StartedDragging() { |
156 // Tell the panel layout manager that we are dragging this panel before | 156 // Tell the panel layout manager that we are dragging this panel before |
157 // attaching it so that it does not get repositioned. | 157 // attaching it so that it does not get repositioned. |
158 if (panel_container_) | 158 if (panel_container_) |
159 GetPanelLayoutManager()->StartDragging(WmWindow::Get(GetTarget())); | 159 GetPanelLayoutManager()->StartDragging(GetTarget()); |
160 if (!was_attached_) { | 160 if (!was_attached_) { |
161 // Attach the panel while dragging, placing it in front of other panels. | 161 // Attach the panel while dragging, placing it in front of other panels. |
162 aura::Window* target = GetTarget(); | 162 aura::Window* target = GetTarget(); |
163 target->SetProperty(kPanelAttachedKey, true); | 163 target->SetProperty(kPanelAttachedKey, true); |
164 // We use root window coordinates to ensure that during the drag the panel | 164 // We use root window coordinates to ensure that during the drag the panel |
165 // is reparented to a container in the root window that has that window. | 165 // is reparented to a container in the root window that has that window. |
166 aura::Window* target_root = target->GetRootWindow(); | 166 aura::Window* target_root = target->GetRootWindow(); |
167 aura::Window* old_parent = target->parent(); | 167 aura::Window* old_parent = target->parent(); |
168 aura::client::ParentWindowWithContext(target, target_root, | 168 aura::client::ParentWindowWithContext(target, target_root, |
169 target_root->GetBoundsInScreen()); | 169 target_root->GetBoundsInScreen()); |
(...skipping 14 matching lines...) Expand all Loading... |
184 aura::Window* target_root = target->GetRootWindow(); | 184 aura::Window* target_root = target->GetRootWindow(); |
185 aura::Window* old_parent = target->parent(); | 185 aura::Window* old_parent = target->parent(); |
186 aura::client::ParentWindowWithContext(target, target_root, | 186 aura::client::ParentWindowWithContext(target, target_root, |
187 target_root->GetBoundsInScreen()); | 187 target_root->GetBoundsInScreen()); |
188 wm::ReparentTransientChildrenOfChild(target, old_parent, target->parent()); | 188 wm::ReparentTransientChildrenOfChild(target, old_parent, target->parent()); |
189 } | 189 } |
190 | 190 |
191 // If we started the drag in one root window and moved into another root | 191 // If we started the drag in one root window and moved into another root |
192 // but then canceled the drag we may need to inform the original layout | 192 // but then canceled the drag we may need to inform the original layout |
193 // manager that the drag is finished. | 193 // manager that the drag is finished. |
194 if (initial_panel_container_ != panel_container_) { | 194 if (initial_panel_container_ != panel_container_) |
195 PanelLayoutManager::Get(WmWindow::Get(initial_panel_container_)) | 195 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); |
196 ->FinishDragging(); | |
197 } | |
198 if (panel_container_) | 196 if (panel_container_) |
199 GetPanelLayoutManager()->FinishDragging(); | 197 GetPanelLayoutManager()->FinishDragging(); |
200 } | 198 } |
201 | 199 |
202 void PanelWindowResizer::UpdateLauncherPosition() { | 200 void PanelWindowResizer::UpdateLauncherPosition() { |
203 if (panel_container_) { | 201 if (panel_container_) { |
204 GetPanelLayoutManager()->shelf()->UpdateIconPositionForPanel( | 202 GetPanelLayoutManager()->shelf()->UpdateIconPositionForPanel( |
205 WmWindow::Get(GetTarget())); | 203 WmWindow::Get(GetTarget())); |
206 } | 204 } |
207 } | 205 } |
208 | 206 |
209 PanelLayoutManager* PanelWindowResizer::GetPanelLayoutManager() { | 207 PanelLayoutManager* PanelWindowResizer::GetPanelLayoutManager() { |
210 return PanelLayoutManager::Get(WmWindow::Get(panel_container_)); | 208 return PanelLayoutManager::Get(panel_container_); |
211 } | 209 } |
212 | 210 |
213 } // namespace ash | 211 } // namespace ash |
OLD | NEW |