| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/wm/dock/dock_window_resizer.h" |
| 6 |
| 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/launcher/launcher.h" |
| 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/screen_ash.h" |
| 11 #include "ash/shelf/shelf_types.h" |
| 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" |
| 14 #include "ash/shell_window_ids.h" |
| 15 #include "ash/wm/coordinate_conversion.h" |
| 16 #include "ash/wm/dock/dock_layout_manager.h" |
| 17 #include "ash/wm/property_util.h" |
| 18 #include "ash/wm/window_properties.h" |
| 19 #include "ui/aura/client/aura_constants.h" |
| 20 #include "ui/aura/env.h" |
| 21 #include "ui/aura/root_window.h" |
| 22 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_delegate.h" |
| 24 #include "ui/base/hit_test.h" |
| 25 #include "ui/base/ui_base_types.h" |
| 26 #include "ui/gfx/screen.h" |
| 27 #include "ui/views/widget/widget.h" |
| 28 |
| 29 namespace ash { |
| 30 |
| 31 namespace { |
| 32 internal::DockLayoutManager* GetDockLayoutManager( |
| 33 aura::Window* dock_container) { |
| 34 DCHECK(dock_container->id() == internal::kShellWindowId_DockContainer); |
| 35 return static_cast<internal::DockLayoutManager*>( |
| 36 dock_container->layout_manager()); |
| 37 } |
| 38 |
| 39 } // namespace |
| 40 |
| 41 DockWindowResizer::~DockWindowResizer() { |
| 42 } |
| 43 |
| 44 // static |
| 45 DockWindowResizer* |
| 46 DockWindowResizer::Create(WindowResizer* next_window_resizer, |
| 47 aura::Window* window, |
| 48 const gfx::Point& location, |
| 49 int window_component) { |
| 50 Details details(window, location, window_component); |
| 51 return details.is_resizable ? |
| 52 new DockWindowResizer(next_window_resizer, details) : NULL; |
| 53 } |
| 54 |
| 55 void DockWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 56 if (!did_move_or_resize_) { |
| 57 did_move_or_resize_ = true; |
| 58 StartedDragging(); |
| 59 } |
| 60 next_window_resizer_->Drag(location, event_flags); |
| 61 } |
| 62 |
| 63 void DockWindowResizer::CompleteDrag(int event_flags) { |
| 64 // The root window can change when dragging into a different screen. |
| 65 next_window_resizer_->CompleteDrag(event_flags); |
| 66 FinishDragging(); |
| 67 } |
| 68 |
| 69 void DockWindowResizer::RevertDrag() { |
| 70 next_window_resizer_->RevertDrag(); |
| 71 FinishDragging(); |
| 72 } |
| 73 |
| 74 aura::Window* DockWindowResizer::GetTarget() { |
| 75 return next_window_resizer_->GetTarget(); |
| 76 } |
| 77 |
| 78 DockWindowResizer::DockWindowResizer(WindowResizer* next_window_resizer, |
| 79 const Details& details) |
| 80 : details_(details), |
| 81 next_window_resizer_(next_window_resizer), |
| 82 dock_container_(NULL), |
| 83 did_move_or_resize_(false) { |
| 84 DCHECK(details_.is_resizable); |
| 85 dock_container_ = Shell::GetContainer(details.window->GetRootWindow(), |
| 86 internal::kShellWindowId_DockContainer); |
| 87 } |
| 88 |
| 89 void DockWindowResizer::StartedDragging() { |
| 90 // Tell the dock layout manager that we are dragging this window. |
| 91 if (dock_container_) |
| 92 GetDockLayoutManager(dock_container_)->StartDragging(GetTarget()); |
| 93 } |
| 94 |
| 95 void DockWindowResizer::FinishDragging() { |
| 96 if (!did_move_or_resize_) |
| 97 return; |
| 98 if (dock_container_) |
| 99 GetDockLayoutManager(dock_container_)->FinishDragging(); |
| 100 } |
| 101 |
| 102 } // namespace aura |
| OLD | NEW |