Chromium Code Reviews| 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/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/launcher/launcher.h" | 8 #include "ash/launcher/launcher.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shelf/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 } | 57 } |
| 58 | 58 |
| 59 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 59 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 60 last_location_ = location; | 60 last_location_ = location; |
| 61 wm::ConvertPointToScreen(GetTarget()->parent(), &last_location_); | 61 wm::ConvertPointToScreen(GetTarget()->parent(), &last_location_); |
| 62 bool destroyed = false; | 62 bool destroyed = false; |
| 63 if (!did_move_or_resize_) { | 63 if (!did_move_or_resize_) { |
| 64 did_move_or_resize_ = true; | 64 did_move_or_resize_ = true; |
| 65 StartedDragging(); | 65 StartedDragging(); |
| 66 } | 66 } |
| 67 gfx::Point location_in_screen = location; | |
| 68 wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen); | |
| 69 | 67 |
| 70 // Check if the destination has changed displays. | 68 // Check if the destination has changed displays. |
| 71 gfx::Screen* screen = Shell::GetScreen(); | 69 gfx::Screen* screen = Shell::GetScreen(); |
| 72 const gfx::Display dst_display = | 70 const gfx::Display dst_display = |
| 73 screen->GetDisplayNearestPoint(location_in_screen); | 71 screen->GetDisplayNearestPoint(last_location_); |
| 74 if (dst_display.id() != | 72 if (dst_display.id() != |
| 75 screen->GetDisplayNearestWindow(panel_container_->GetRootWindow()).id()) { | 73 screen->GetDisplayNearestWindow(panel_container_->GetRootWindow()).id()) { |
| 76 // The panel is being dragged to a new display. If the previous container is | 74 // The panel is being dragged to a new display. If the previous container is |
| 77 // the current parent of the panel it will be informed of the end of drag | 75 // the current parent of the panel it will be informed of the end of drag |
| 78 // when the panel is reparented, otherwise let the previous container know | 76 // when the panel is reparented, otherwise let the previous container know |
| 79 // the drag is complete. If we told the panel's parent that the drag was | 77 // the drag is complete. If we told the panel's parent that the drag was |
| 80 // complete it would begin positioning the panel. | 78 // complete it would begin positioning the panel. |
| 81 if (GetTarget()->parent() != panel_container_) | 79 if (GetTarget()->parent() != panel_container_) |
| 82 GetPanelLayoutManager(panel_container_)->FinishDragging(); | 80 GetPanelLayoutManager(panel_container_)->FinishDragging(); |
| 83 aura::RootWindow* dst_root = Shell::GetInstance()->display_controller()-> | 81 aura::RootWindow* dst_root = Shell::GetInstance()->display_controller()-> |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 | 189 |
| 192 void PanelWindowResizer::StartedDragging() { | 190 void PanelWindowResizer::StartedDragging() { |
| 193 // Tell the panel layout manager that we are dragging this panel before | 191 // Tell the panel layout manager that we are dragging this panel before |
| 194 // attaching it so that it does not get repositioned. | 192 // attaching it so that it does not get repositioned. |
| 195 if (panel_container_) | 193 if (panel_container_) |
| 196 GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget()); | 194 GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget()); |
| 197 if (!was_attached_) { | 195 if (!was_attached_) { |
| 198 // Attach the panel while dragging placing it in front of other panels. | 196 // Attach the panel while dragging placing it in front of other panels. |
| 199 GetTarget()->SetProperty(internal::kContinueDragAfterReparent, true); | 197 GetTarget()->SetProperty(internal::kContinueDragAfterReparent, true); |
| 200 GetTarget()->SetProperty(internal::kPanelAttachedKey, true); | 198 GetTarget()->SetProperty(internal::kPanelAttachedKey, true); |
| 201 GetTarget()->SetDefaultParentByRootWindow( | 199 gfx::Point start_location_in_screen(GetInitialLocation()); |
|
flackr
2013/06/19 15:16:49
Add comment that we use the start location to make
varkha
2013/06/19 15:49:22
Done.
| |
| 202 GetTarget()->GetRootWindow(), | 200 wm::ConvertPointToScreen(GetTarget()->parent(), &start_location_in_screen); |
| 203 GetTarget()->GetBoundsInScreen()); | 201 gfx::Rect near_start_location(start_location_in_screen, gfx::Size()); |
| 202 GetTarget()->SetDefaultParentByRootWindow(GetTarget()->GetRootWindow(), | |
| 203 near_start_location); | |
|
flackr
2013/06/19 15:16:49
nit: Construct gfx::Rect in place for the paramete
varkha
2013/06/19 15:49:22
No need with using the root coordinates.
| |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void PanelWindowResizer::FinishDragging() { | 207 void PanelWindowResizer::FinishDragging() { |
| 208 if (!did_move_or_resize_) | 208 if (!did_move_or_resize_) |
| 209 return; | 209 return; |
| 210 if (GetTarget()->GetProperty(internal::kPanelAttachedKey) != | 210 if (GetTarget()->GetProperty(internal::kPanelAttachedKey) != |
| 211 should_attach_) { | 211 should_attach_) { |
| 212 GetTarget()->SetProperty(internal::kPanelAttachedKey, should_attach_); | 212 GetTarget()->SetProperty(internal::kPanelAttachedKey, should_attach_); |
| 213 gfx::Rect near_last_location(last_location_, gfx::Size()); | 213 gfx::Rect near_last_location(last_location_, gfx::Size()); |
| 214 GetTarget()->SetDefaultParentByRootWindow(GetTarget()->GetRootWindow(), | 214 GetTarget()->SetDefaultParentByRootWindow(GetTarget()->GetRootWindow(), |
| 215 near_last_location); | 215 near_last_location); |
| 216 } | 216 } |
| 217 if (panel_container_) | 217 if (panel_container_) |
| 218 GetPanelLayoutManager(panel_container_)->FinishDragging(); | 218 GetPanelLayoutManager(panel_container_)->FinishDragging(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void PanelWindowResizer::UpdateLauncherPosition() { | 221 void PanelWindowResizer::UpdateLauncherPosition() { |
| 222 if (panel_container_) { | 222 if (panel_container_) { |
| 223 GetPanelLayoutManager(panel_container_)->launcher()-> | 223 GetPanelLayoutManager(panel_container_)->launcher()-> |
| 224 UpdateIconPositionForWindow(GetTarget()); | 224 UpdateIconPositionForWindow(GetTarget()); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace aura | 228 } // namespace aura |
| OLD | NEW |