| 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/drag_window_resizer.h" | 5 #include "ash/wm/drag_window_resizer.h" |
| 6 | 6 |
| 7 #include "ash/display/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/wm/aura/wm_window_aura.h" | 10 #include "ash/wm/aura/wm_window_aura.h" |
| 11 #include "ash/wm/common/window_positioning_utils.h" | 11 #include "ash/wm/common/window_positioning_utils.h" |
| 12 #include "ash/wm/common/window_state.h" | 12 #include "ash/wm/common/window_state.h" |
| 13 #include "ash/wm/drag_window_controller.h" | 13 #include "ash/wm/drag_window_controller.h" |
| 14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
| 17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_delegate.h" | 19 #include "ui/aura/window_delegate.h" |
| 20 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
| 21 #include "ui/base/hit_test.h" | 21 #include "ui/base/hit_test.h" |
| 22 #include "ui/base/ui_base_types.h" | 22 #include "ui/base/ui_base_types.h" |
| 23 #include "ui/gfx/screen.h" | 23 #include "ui/display/screen.h" |
| 24 #include "ui/wm/core/coordinate_conversion.h" | 24 #include "ui/wm/core/coordinate_conversion.h" |
| 25 #include "ui/wm/core/window_util.h" | 25 #include "ui/wm/core/window_util.h" |
| 26 | 26 |
| 27 namespace ash { | 27 namespace ash { |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 DragWindowResizer* DragWindowResizer::instance_ = NULL; | 30 DragWindowResizer* DragWindowResizer::instance_ = NULL; |
| 31 | 31 |
| 32 DragWindowResizer::~DragWindowResizer() { | 32 DragWindowResizer::~DragWindowResizer() { |
| 33 if (window_state_) | 33 if (window_state_) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 | 48 |
| 49 void DragWindowResizer::Drag(const gfx::Point& location, int event_flags) { | 49 void DragWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
| 50 base::WeakPtr<DragWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr()); | 50 base::WeakPtr<DragWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr()); |
| 51 next_window_resizer_->Drag(location, event_flags); | 51 next_window_resizer_->Drag(location, event_flags); |
| 52 | 52 |
| 53 if (!resizer) | 53 if (!resizer) |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 last_mouse_location_ = location; | 56 last_mouse_location_ = location; |
| 57 // Show a phantom window for dragging in another root window. | 57 // Show a phantom window for dragging in another root window. |
| 58 if (gfx::Screen::GetScreen()->GetNumDisplays() > 1) { | 58 if (display::Screen::GetScreen()->GetNumDisplays() > 1) { |
| 59 gfx::Point location_in_screen = location; | 59 gfx::Point location_in_screen = location; |
| 60 ::wm::ConvertPointToScreen(GetAuraTarget()->parent(), &location_in_screen); | 60 ::wm::ConvertPointToScreen(GetAuraTarget()->parent(), &location_in_screen); |
| 61 UpdateDragWindow(GetAuraTarget()->bounds(), location_in_screen); | 61 UpdateDragWindow(GetAuraTarget()->bounds(), location_in_screen); |
| 62 } else { | 62 } else { |
| 63 drag_window_controller_.reset(); | 63 drag_window_controller_.reset(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 void DragWindowResizer::CompleteDrag() { | 67 void DragWindowResizer::CompleteDrag() { |
| 68 next_window_resizer_->CompleteDrag(); | 68 next_window_resizer_->CompleteDrag(); |
| 69 | 69 |
| 70 GetAuraTarget()->layer()->SetOpacity(details().initial_opacity); | 70 GetAuraTarget()->layer()->SetOpacity(details().initial_opacity); |
| 71 drag_window_controller_.reset(); | 71 drag_window_controller_.reset(); |
| 72 | 72 |
| 73 // Check if the destination is another display. | 73 // Check if the destination is another display. |
| 74 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 74 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
| 75 ::wm::ConvertPointToScreen(GetAuraTarget()->parent(), | 75 ::wm::ConvertPointToScreen(GetAuraTarget()->parent(), |
| 76 &last_mouse_location_in_screen); | 76 &last_mouse_location_in_screen); |
| 77 gfx::Screen* screen = gfx::Screen::GetScreen(); | 77 display::Screen* screen = display::Screen::GetScreen(); |
| 78 const gfx::Display dst_display = | 78 const display::Display dst_display = |
| 79 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); | 79 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); |
| 80 | 80 |
| 81 if (dst_display.id() != | 81 if (dst_display.id() != |
| 82 screen->GetDisplayNearestWindow(GetAuraTarget()->GetRootWindow()).id()) { | 82 screen->GetDisplayNearestWindow(GetAuraTarget()->GetRootWindow()).id()) { |
| 83 // Adjust the size and position so that it doesn't exceed the size of | 83 // Adjust the size and position so that it doesn't exceed the size of |
| 84 // work area. | 84 // work area. |
| 85 const gfx::Size& size = dst_display.work_area().size(); | 85 const gfx::Size& size = dst_display.work_area().size(); |
| 86 gfx::Rect bounds = GetAuraTarget()->bounds(); | 86 gfx::Rect bounds = GetAuraTarget()->bounds(); |
| 87 if (bounds.width() > size.width()) { | 87 if (bounds.width() > size.width()) { |
| 88 int diff = bounds.width() - size.width(); | 88 int diff = bounds.width() - size.width(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return details().window_component == HTCAPTION && | 165 return details().window_component == HTCAPTION && |
| 166 !::wm::GetTransientParent(GetAuraTarget()) && | 166 !::wm::GetTransientParent(GetAuraTarget()) && |
| 167 wm::IsWindowUserPositionable(GetAuraTarget()); | 167 wm::IsWindowUserPositionable(GetAuraTarget()); |
| 168 } | 168 } |
| 169 | 169 |
| 170 aura::Window* DragWindowResizer::GetAuraTarget() { | 170 aura::Window* DragWindowResizer::GetAuraTarget() { |
| 171 return wm::WmWindowAura::GetAuraWindow(GetTarget()); | 171 return wm::WmWindowAura::GetAuraWindow(GetTarget()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 } // namespace ash | 174 } // namespace ash |
| OLD | NEW |