| 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/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
| 11 #include "ash/wm/drag_window_controller.h" | 11 #include "ash/wm/drag_window_controller.h" |
| 12 #include "ash/wm/window_state.h" | 12 #include "ash/wm/window_state.h" |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
| 16 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
| 17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/aura/window_delegate.h" | 18 #include "ui/aura/window_delegate.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/base/hit_test.h" | 20 #include "ui/base/hit_test.h" |
| 21 #include "ui/base/ui_base_types.h" | 21 #include "ui/base/ui_base_types.h" |
| 22 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
| 23 #include "ui/wm/core/coordinate_conversion.h" |
| 23 #include "ui/wm/core/window_util.h" | 24 #include "ui/wm/core/window_util.h" |
| 24 | 25 |
| 25 namespace ash { | 26 namespace ash { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // The maximum opacity of the drag phantom window. | 29 // The maximum opacity of the drag phantom window. |
| 29 const float kMaxOpacity = 0.8f; | 30 const float kMaxOpacity = 0.8f; |
| 30 | 31 |
| 31 // Returns true if Ash has more than one root window. | 32 // Returns true if Ash has more than one root window. |
| 32 bool HasSecondaryRootWindow() { | 33 bool HasSecondaryRootWindow() { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 base::WeakPtr<DragWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr()); | 73 base::WeakPtr<DragWindowResizer> resizer(weak_ptr_factory_.GetWeakPtr()); |
| 73 next_window_resizer_->Drag(location, event_flags); | 74 next_window_resizer_->Drag(location, event_flags); |
| 74 | 75 |
| 75 if (!resizer) | 76 if (!resizer) |
| 76 return; | 77 return; |
| 77 | 78 |
| 78 last_mouse_location_ = location; | 79 last_mouse_location_ = location; |
| 79 // Show a phantom window for dragging in another root window. | 80 // Show a phantom window for dragging in another root window. |
| 80 if (HasSecondaryRootWindow()) { | 81 if (HasSecondaryRootWindow()) { |
| 81 gfx::Point location_in_screen = location; | 82 gfx::Point location_in_screen = location; |
| 82 wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen); | 83 ::wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen); |
| 83 const bool in_original_root = | 84 const bool in_original_root = |
| 84 wm::GetRootWindowAt(location_in_screen) == GetTarget()->GetRootWindow(); | 85 wm::GetRootWindowAt(location_in_screen) == GetTarget()->GetRootWindow(); |
| 85 UpdateDragWindow(GetTarget()->bounds(), in_original_root); | 86 UpdateDragWindow(GetTarget()->bounds(), in_original_root); |
| 86 } else { | 87 } else { |
| 87 drag_window_controller_.reset(); | 88 drag_window_controller_.reset(); |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 | 91 |
| 91 void DragWindowResizer::CompleteDrag() { | 92 void DragWindowResizer::CompleteDrag() { |
| 92 next_window_resizer_->CompleteDrag(); | 93 next_window_resizer_->CompleteDrag(); |
| 93 | 94 |
| 94 GetTarget()->layer()->SetOpacity(details().initial_opacity); | 95 GetTarget()->layer()->SetOpacity(details().initial_opacity); |
| 95 drag_window_controller_.reset(); | 96 drag_window_controller_.reset(); |
| 96 | 97 |
| 97 // Check if the destination is another display. | 98 // Check if the destination is another display. |
| 98 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 99 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
| 99 wm::ConvertPointToScreen(GetTarget()->parent(), | 100 ::wm::ConvertPointToScreen(GetTarget()->parent(), |
| 100 &last_mouse_location_in_screen); | 101 &last_mouse_location_in_screen); |
| 101 gfx::Screen* screen = Shell::GetScreen(); | 102 gfx::Screen* screen = Shell::GetScreen(); |
| 102 const gfx::Display dst_display = | 103 const gfx::Display dst_display = |
| 103 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); | 104 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); |
| 104 | 105 |
| 105 if (dst_display.id() != | 106 if (dst_display.id() != |
| 106 screen->GetDisplayNearestWindow(GetTarget()->GetRootWindow()).id()) { | 107 screen->GetDisplayNearestWindow(GetTarget()->GetRootWindow()).id()) { |
| 107 // Adjust the size and position so that it doesn't exceed the size of | 108 // Adjust the size and position so that it doesn't exceed the size of |
| 108 // work area. | 109 // work area. |
| 109 const gfx::Size& size = dst_display.work_area().size(); | 110 const gfx::Size& size = dst_display.work_area().size(); |
| 110 gfx::Rect bounds = GetTarget()->bounds(); | 111 gfx::Rect bounds = GetTarget()->bounds(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 204 } |
| 204 | 205 |
| 205 bool DragWindowResizer::ShouldAllowMouseWarp() { | 206 bool DragWindowResizer::ShouldAllowMouseWarp() { |
| 206 return (details().window_component == HTCAPTION) && | 207 return (details().window_component == HTCAPTION) && |
| 207 !::wm::GetTransientParent(GetTarget()) && | 208 !::wm::GetTransientParent(GetTarget()) && |
| 208 (GetTarget()->type() == ui::wm::WINDOW_TYPE_NORMAL || | 209 (GetTarget()->type() == ui::wm::WINDOW_TYPE_NORMAL || |
| 209 GetTarget()->type() == ui::wm::WINDOW_TYPE_PANEL); | 210 GetTarget()->type() == ui::wm::WINDOW_TYPE_PANEL); |
| 210 } | 211 } |
| 211 | 212 |
| 212 } // namespace ash | 213 } // namespace ash |
| OLD | NEW |