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