| 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/common/wm/panels/panel_window_resizer.h" | 5 #include "ash/common/wm/panels/panel_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/wm_shelf.h" | 7 #include "ash/common/shelf/wm_shelf.h" |
| 8 #include "ash/common/wm/panels/panel_layout_manager.h" | 8 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 9 #include "ash/common/wm/window_parenting_utils.h" | 9 #include "ash/common/wm/window_parenting_utils.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (!was_attached_) { | 157 if (!was_attached_) { |
| 158 // Attach the panel while dragging, placing it in front of other panels. | 158 // Attach the panel while dragging, placing it in front of other panels. |
| 159 WmWindow* target = GetTarget(); | 159 WmWindow* target = GetTarget(); |
| 160 target->aura_window()->SetProperty(kPanelAttachedKey, true); | 160 target->aura_window()->SetProperty(kPanelAttachedKey, true); |
| 161 // We use root window coordinates to ensure that during the drag the panel | 161 // We use root window coordinates to ensure that during the drag the panel |
| 162 // is reparented to a container in the root window that has that window. | 162 // is reparented to a container in the root window that has that window. |
| 163 WmWindow* target_root = target->GetRootWindow(); | 163 WmWindow* target_root = target->GetRootWindow(); |
| 164 WmWindow* old_parent = target->GetParent(); | 164 WmWindow* old_parent = target->GetParent(); |
| 165 target->SetParentUsingContext(target_root, | 165 target->SetParentUsingContext(target_root, |
| 166 target_root->GetBoundsInScreen()); | 166 target_root->GetBoundsInScreen()); |
| 167 wm::ReparentTransientChildrenOfChild(target, old_parent, | 167 wm::ReparentTransientChildrenOfChild(target->aura_window(), |
| 168 target->GetParent()); | 168 old_parent->aura_window(), |
| 169 target->GetParent()->aura_window()); |
| 169 } | 170 } |
| 170 } | 171 } |
| 171 | 172 |
| 172 void PanelWindowResizer::FinishDragging() { | 173 void PanelWindowResizer::FinishDragging() { |
| 173 if (!did_move_or_resize_) | 174 if (!did_move_or_resize_) |
| 174 return; | 175 return; |
| 175 if (GetTarget()->aura_window()->GetProperty(kPanelAttachedKey) != | 176 if (GetTarget()->aura_window()->GetProperty(kPanelAttachedKey) != |
| 176 details().should_attach_to_shelf) { | 177 details().should_attach_to_shelf) { |
| 177 GetTarget()->aura_window()->SetProperty(kPanelAttachedKey, | 178 GetTarget()->aura_window()->SetProperty(kPanelAttachedKey, |
| 178 details().should_attach_to_shelf); | 179 details().should_attach_to_shelf); |
| 179 // We use last known location to ensure that after the drag the panel | 180 // We use last known location to ensure that after the drag the panel |
| 180 // is reparented to a container in the root window that has that location. | 181 // is reparented to a container in the root window that has that location. |
| 181 WmWindow* target = GetTarget(); | 182 WmWindow* target = GetTarget(); |
| 182 WmWindow* target_root = target->GetRootWindow(); | 183 WmWindow* target_root = target->GetRootWindow(); |
| 183 WmWindow* old_parent = target->GetParent(); | 184 WmWindow* old_parent = target->GetParent(); |
| 184 target->SetParentUsingContext(target_root, | 185 target->SetParentUsingContext(target_root, |
| 185 gfx::Rect(last_location_, gfx::Size())); | 186 gfx::Rect(last_location_, gfx::Size())); |
| 186 wm::ReparentTransientChildrenOfChild(target, old_parent, | 187 wm::ReparentTransientChildrenOfChild(target->aura_window(), |
| 187 target->GetParent()); | 188 old_parent->aura_window(), |
| 189 target->GetParent()->aura_window()); |
| 188 } | 190 } |
| 189 | 191 |
| 190 // If we started the drag in one root window and moved into another root | 192 // If we started the drag in one root window and moved into another root |
| 191 // but then canceled the drag we may need to inform the original layout | 193 // but then canceled the drag we may need to inform the original layout |
| 192 // manager that the drag is finished. | 194 // manager that the drag is finished. |
| 193 if (initial_panel_container_ != panel_container_) | 195 if (initial_panel_container_ != panel_container_) |
| 194 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); | 196 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); |
| 195 if (panel_container_) | 197 if (panel_container_) |
| 196 PanelLayoutManager::Get(panel_container_)->FinishDragging(); | 198 PanelLayoutManager::Get(panel_container_)->FinishDragging(); |
| 197 } | 199 } |
| 198 | 200 |
| 199 void PanelWindowResizer::UpdateLauncherPosition() { | 201 void PanelWindowResizer::UpdateLauncherPosition() { |
| 200 if (panel_container_) { | 202 if (panel_container_) { |
| 201 PanelLayoutManager::Get(panel_container_) | 203 PanelLayoutManager::Get(panel_container_) |
| 202 ->shelf() | 204 ->shelf() |
| 203 ->UpdateIconPositionForPanel(GetTarget()); | 205 ->UpdateIconPositionForPanel(GetTarget()); |
| 204 } | 206 } |
| 205 } | 207 } |
| 206 | 208 |
| 207 } // namespace ash | 209 } // namespace ash |
| OLD | NEW |