| 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/display/window_tree_host_manager.h" | 7 #include "ash/display/window_tree_host_manager.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
| 11 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
| 14 #include "ash/wm/common/window_parenting_utils.h" |
| 14 #include "ash/wm/panels/panel_layout_manager.h" | 15 #include "ash/wm/panels/panel_layout_manager.h" |
| 15 #include "ash/wm/window_state.h" | 16 #include "ash/wm/window_state.h" |
| 16 #include "ash/wm/window_util.h" | 17 #include "ash/wm/window_util.h" |
| 17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 18 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
| 19 #include "ui/aura/client/window_tree_client.h" | 20 #include "ui/aura/client/window_tree_client.h" |
| 20 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
| 21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_delegate.h" | 23 #include "ui/aura/window_delegate.h" |
| 23 #include "ui/aura/window_event_dispatcher.h" | 24 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (!was_attached_) { | 174 if (!was_attached_) { |
| 174 // Attach the panel while dragging placing it in front of other panels. | 175 // Attach the panel while dragging placing it in front of other panels. |
| 175 window_state_->set_panel_attached(true); | 176 window_state_->set_panel_attached(true); |
| 176 // We use root window coordinates to ensure that during the drag the panel | 177 // We use root window coordinates to ensure that during the drag the panel |
| 177 // is reparented to a container in the root window that has that window. | 178 // is reparented to a container in the root window that has that window. |
| 178 aura::Window* target = GetTarget(); | 179 aura::Window* target = GetTarget(); |
| 179 aura::Window* target_root = target->GetRootWindow(); | 180 aura::Window* target_root = target->GetRootWindow(); |
| 180 aura::Window* old_parent = target->parent(); | 181 aura::Window* old_parent = target->parent(); |
| 181 aura::client::ParentWindowWithContext( | 182 aura::client::ParentWindowWithContext( |
| 182 target, target_root, target_root->GetBoundsInScreen()); | 183 target, target_root, target_root->GetBoundsInScreen()); |
| 183 wm::ReparentTransientChildrenOfChild(target, old_parent, target->parent()); | 184 ash::wm::ReparentTransientChildrenOfChild( |
| 185 ash::wm::WmWindowAura::Get(target), |
| 186 ash::wm::WmWindowAura::Get(old_parent), |
| 187 ash::wm::WmWindowAura::Get(target->parent())); |
| 184 } | 188 } |
| 185 } | 189 } |
| 186 | 190 |
| 187 void PanelWindowResizer::FinishDragging() { | 191 void PanelWindowResizer::FinishDragging() { |
| 188 if (!did_move_or_resize_) | 192 if (!did_move_or_resize_) |
| 189 return; | 193 return; |
| 190 if (window_state_->panel_attached() != details().should_attach_to_shelf) { | 194 if (window_state_->panel_attached() != details().should_attach_to_shelf) { |
| 191 window_state_->set_panel_attached(details().should_attach_to_shelf); | 195 window_state_->set_panel_attached(details().should_attach_to_shelf); |
| 192 // We use last known location to ensure that after the drag the panel | 196 // We use last known location to ensure that after the drag the panel |
| 193 // is reparented to a container in the root window that has that location. | 197 // is reparented to a container in the root window that has that location. |
| 194 aura::Window* target = GetTarget(); | 198 aura::Window* target = GetTarget(); |
| 195 aura::Window* target_root = target->GetRootWindow(); | 199 aura::Window* target_root = target->GetRootWindow(); |
| 196 aura::Window* old_parent = target->parent(); | 200 aura::Window* old_parent = target->parent(); |
| 197 aura::client::ParentWindowWithContext( | 201 aura::client::ParentWindowWithContext( |
| 198 target, target_root, gfx::Rect(last_location_, gfx::Size())); | 202 target, target_root, gfx::Rect(last_location_, gfx::Size())); |
| 199 wm::ReparentTransientChildrenOfChild(target, old_parent, target->parent()); | 203 ash::wm::ReparentTransientChildrenOfChild( |
| 204 ash::wm::WmWindowAura::Get(target), |
| 205 ash::wm::WmWindowAura::Get(old_parent), |
| 206 ash::wm::WmWindowAura::Get(target->parent())); |
| 200 } | 207 } |
| 201 | 208 |
| 202 // If we started the drag in one root window and moved into another root | 209 // If we started the drag in one root window and moved into another root |
| 203 // but then canceled the drag we may need to inform the original layout | 210 // but then canceled the drag we may need to inform the original layout |
| 204 // manager that the drag is finished. | 211 // manager that the drag is finished. |
| 205 if (initial_panel_container_ != panel_container_) | 212 if (initial_panel_container_ != panel_container_) |
| 206 GetPanelLayoutManager(initial_panel_container_)->FinishDragging(); | 213 GetPanelLayoutManager(initial_panel_container_)->FinishDragging(); |
| 207 if (panel_container_) | 214 if (panel_container_) |
| 208 GetPanelLayoutManager(panel_container_)->FinishDragging(); | 215 GetPanelLayoutManager(panel_container_)->FinishDragging(); |
| 209 } | 216 } |
| 210 | 217 |
| 211 void PanelWindowResizer::UpdateLauncherPosition() { | 218 void PanelWindowResizer::UpdateLauncherPosition() { |
| 212 if (panel_container_) { | 219 if (panel_container_) { |
| 213 GetPanelLayoutManager(panel_container_)->shelf()-> | 220 GetPanelLayoutManager(panel_container_)->shelf()-> |
| 214 UpdateIconPositionForWindow(GetTarget()); | 221 UpdateIconPositionForWindow(GetTarget()); |
| 215 } | 222 } |
| 216 } | 223 } |
| 217 | 224 |
| 218 } // namespace aura | 225 } // namespace aura |
| OLD | NEW |