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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 // attaching it so that it does not get repositioned. | 154 // attaching it so that it does not get repositioned. |
155 if (panel_container_) | 155 if (panel_container_) |
156 PanelLayoutManager::Get(panel_container_)->StartDragging(GetTarget()); | 156 PanelLayoutManager::Get(panel_container_)->StartDragging(GetTarget()); |
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 aura::Window* old_parent = target->aura_window()->parent(); |
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(), old_parent, |
168 target->GetParent()); | 168 target->aura_window()->parent()); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 void PanelWindowResizer::FinishDragging() { | 172 void PanelWindowResizer::FinishDragging() { |
173 if (!did_move_or_resize_) | 173 if (!did_move_or_resize_) |
174 return; | 174 return; |
175 if (GetTarget()->aura_window()->GetProperty(kPanelAttachedKey) != | 175 if (GetTarget()->aura_window()->GetProperty(kPanelAttachedKey) != |
176 details().should_attach_to_shelf) { | 176 details().should_attach_to_shelf) { |
177 GetTarget()->aura_window()->SetProperty(kPanelAttachedKey, | 177 GetTarget()->aura_window()->SetProperty(kPanelAttachedKey, |
178 details().should_attach_to_shelf); | 178 details().should_attach_to_shelf); |
179 // We use last known location to ensure that after the drag the panel | 179 // 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. | 180 // is reparented to a container in the root window that has that location. |
181 WmWindow* target = GetTarget(); | 181 WmWindow* target = GetTarget(); |
182 WmWindow* target_root = target->GetRootWindow(); | 182 WmWindow* target_root = target->GetRootWindow(); |
183 WmWindow* old_parent = target->GetParent(); | 183 aura::Window* old_parent = target->aura_window()->parent(); |
184 target->SetParentUsingContext(target_root, | 184 target->SetParentUsingContext(target_root, |
185 gfx::Rect(last_location_, gfx::Size())); | 185 target_root->GetBoundsInScreen()); |
186 wm::ReparentTransientChildrenOfChild(target, old_parent, | 186 wm::ReparentTransientChildrenOfChild(target->aura_window(), old_parent, |
187 target->GetParent()); | 187 target->aura_window()->parent()); |
188 ; | |
sky
2017/03/09 23:31:00
Not needed.
yiyix
2017/03/10 00:55:57
Done.
| |
188 } | 189 } |
189 | 190 |
190 // 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 |
191 // 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 |
192 // manager that the drag is finished. | 193 // manager that the drag is finished. |
193 if (initial_panel_container_ != panel_container_) | 194 if (initial_panel_container_ != panel_container_) |
194 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); | 195 PanelLayoutManager::Get(initial_panel_container_)->FinishDragging(); |
195 if (panel_container_) | 196 if (panel_container_) |
196 PanelLayoutManager::Get(panel_container_)->FinishDragging(); | 197 PanelLayoutManager::Get(panel_container_)->FinishDragging(); |
197 } | 198 } |
198 | 199 |
199 void PanelWindowResizer::UpdateLauncherPosition() { | 200 void PanelWindowResizer::UpdateLauncherPosition() { |
200 if (panel_container_) { | 201 if (panel_container_) { |
201 PanelLayoutManager::Get(panel_container_) | 202 PanelLayoutManager::Get(panel_container_) |
202 ->shelf() | 203 ->shelf() |
203 ->UpdateIconPositionForPanel(GetTarget()); | 204 ->UpdateIconPositionForPanel(GetTarget()); |
204 } | 205 } |
205 } | 206 } |
206 | 207 |
207 } // namespace ash | 208 } // namespace ash |
OLD | NEW |