| 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/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shelf/shelf_types.h" | 9 #include "ash/shelf/shelf_types.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 const int kPanelSnapToLauncherDistance = 30; | 29 const int kPanelSnapToLauncherDistance = 30; |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 PanelWindowResizer::~PanelWindowResizer() { | 32 PanelWindowResizer::~PanelWindowResizer() { |
| 33 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); | 33 ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 PanelWindowResizer* | 37 PanelWindowResizer* |
| 38 PanelWindowResizer::Create(aura::Window* window, | 38 PanelWindowResizer::Create(aura::Window* window, |
| 39 const gfx::Point& location, | 39 const gfx::Point& location, |
| 40 int window_component) { | 40 int window_component) { |
| 41 Details details(window, location, window_component); | 41 Details details(window, location, window_component); |
| 42 return details.is_resizable ? new PanelWindowResizer(details) : NULL; | 42 return details.is_resizable ? new PanelWindowResizer(details) : NULL; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 45 void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 46 gfx::Rect bounds(CalculateBoundsForDrag(details_, location)); | 46 gfx::Rect bounds(CalculateBoundsForDrag(details_, location)); |
| 47 if (bounds != details_.window->bounds()) { | 47 if (bounds != details_.window->bounds()) { |
| 48 if (!did_move_or_resize_) { | 48 if (!did_move_or_resize_) { |
| 49 if (!details_.restore_bounds.IsEmpty()) | 49 if (!details_.restore_bounds.IsEmpty()) |
| 50 ClearRestoreBounds(details_.window); | 50 ClearRestoreBounds(details_.window); |
| 51 StartedDragging(); | 51 StartedDragging(); |
| 52 } | 52 } |
| 53 did_move_or_resize_ = true; | 53 did_move_or_resize_ = true; |
| 54 should_attach_ = AttachToLauncher(&bounds); | 54 should_attach_ = AttachToLauncher(&bounds); |
| 55 details_.window->SetBounds(bounds); | 55 details_.window->SetBounds(bounds); |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 void PanelWindowResizer::CompleteDrag(int event_flags) { | 59 void PanelWindowResizer::CompleteDrag(int event_flags) { |
| 60 if (should_attach_ != was_attached_) { | 60 if (details_.window->GetProperty(internal::kPanelAttachedKey) != |
| 61 should_attach_) { |
| 61 details_.window->SetProperty(internal::kPanelAttachedKey, should_attach_); | 62 details_.window->SetProperty(internal::kPanelAttachedKey, should_attach_); |
| 62 details_.window->SetDefaultParentByRootWindow( | 63 details_.window->SetDefaultParentByRootWindow( |
| 63 details_.window->GetRootWindow(), | 64 details_.window->GetRootWindow(), |
| 64 details_.window->bounds()); | 65 details_.window->bounds()); |
| 65 } | 66 } |
| 66 FinishDragging(); | 67 FinishDragging(); |
| 67 } | 68 } |
| 68 | 69 |
| 69 void PanelWindowResizer::RevertDrag() { | 70 void PanelWindowResizer::RevertDrag() { |
| 70 if (!did_move_or_resize_) | 71 if (!did_move_or_resize_) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 should_attach = true; | 134 should_attach = true; |
| 134 bounds->set_y(launcher_bounds.bottom()); | 135 bounds->set_y(launcher_bounds.bottom()); |
| 135 } | 136 } |
| 136 break; | 137 break; |
| 137 } | 138 } |
| 138 } | 139 } |
| 139 return should_attach; | 140 return should_attach; |
| 140 } | 141 } |
| 141 | 142 |
| 142 void PanelWindowResizer::StartedDragging() { | 143 void PanelWindowResizer::StartedDragging() { |
| 143 if (was_attached_) | 144 // Tell the panel layout manager that we are dragging this panel before |
| 144 panel_layout_manager_->StartDragging(details_.window); | 145 // attaching it so that it does not get repositioned. |
| 146 panel_layout_manager_->StartDragging(details_.window); |
| 147 if (!was_attached_) { |
| 148 // Attach the panel while dragging placing it in front of other panels. |
| 149 details_.window->SetProperty(internal::kContinueDragAfterReparent, true); |
| 150 details_.window->SetProperty(internal::kPanelAttachedKey, true); |
| 151 details_.window->SetDefaultParentByRootWindow( |
| 152 details_.window->GetRootWindow(), |
| 153 details_.window->bounds()); |
| 154 } |
| 145 } | 155 } |
| 146 | 156 |
| 147 void PanelWindowResizer::FinishDragging() { | 157 void PanelWindowResizer::FinishDragging() { |
| 148 if (was_attached_) | 158 panel_layout_manager_->FinishDragging(); |
| 149 panel_layout_manager_->FinishDragging(); | |
| 150 } | 159 } |
| 151 | 160 |
| 152 } // namespace aura | 161 } // namespace aura |
| OLD | NEW |