| 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" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void DragWindowResizer::CompleteDrag() { | 93 void DragWindowResizer::CompleteDrag() { |
| 94 next_window_resizer_->CompleteDrag(); | 94 next_window_resizer_->CompleteDrag(); |
| 95 | 95 |
| 96 GetTarget()->layer()->SetOpacity(details().initial_opacity); | 96 GetTarget()->layer()->SetOpacity(details().initial_opacity); |
| 97 drag_window_controllers_.clear(); | 97 drag_window_controllers_.clear(); |
| 98 | 98 |
| 99 // Check if the destination is another display. | 99 // Check if the destination is another display. |
| 100 gfx::Point last_mouse_location_in_screen = last_mouse_location_; | 100 gfx::Point last_mouse_location_in_screen = last_mouse_location_; |
| 101 ::wm::ConvertPointToScreen(GetTarget()->parent(), | 101 ::wm::ConvertPointToScreen(GetTarget()->parent(), |
| 102 &last_mouse_location_in_screen); | 102 &last_mouse_location_in_screen); |
| 103 gfx::Screen* screen = Shell::GetScreen(); | 103 gfx::Screen* screen = gfx::Screen::GetScreen(); |
| 104 const gfx::Display dst_display = | 104 const gfx::Display dst_display = |
| 105 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); | 105 screen->GetDisplayNearestPoint(last_mouse_location_in_screen); |
| 106 | 106 |
| 107 if (dst_display.id() != | 107 if (dst_display.id() != |
| 108 screen->GetDisplayNearestWindow(GetTarget()->GetRootWindow()).id()) { | 108 screen->GetDisplayNearestWindow(GetTarget()->GetRootWindow()).id()) { |
| 109 // Adjust the size and position so that it doesn't exceed the size of | 109 // Adjust the size and position so that it doesn't exceed the size of |
| 110 // work area. | 110 // work area. |
| 111 const gfx::Size& size = dst_display.work_area().size(); | 111 const gfx::Size& size = dst_display.work_area().size(); |
| 112 gfx::Rect bounds = GetTarget()->bounds(); | 112 gfx::Rect bounds = GetTarget()->bounds(); |
| 113 if (bounds.width() > size.width()) { | 113 if (bounds.width() > size.width()) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 183 |
| 184 if (fraction_in_another_window > 0) { | 184 if (fraction_in_another_window > 0) { |
| 185 if (drag_window_controllers_.size() < ++drag_window_controller_count) | 185 if (drag_window_controllers_.size() < ++drag_window_controller_count) |
| 186 drag_window_controllers_.resize(drag_window_controller_count); | 186 drag_window_controllers_.resize(drag_window_controller_count); |
| 187 ScopedVector<DragWindowController>::reference drag_window_controller = | 187 ScopedVector<DragWindowController>::reference drag_window_controller = |
| 188 drag_window_controllers_.back(); | 188 drag_window_controllers_.back(); |
| 189 if (!drag_window_controller) { | 189 if (!drag_window_controller) { |
| 190 drag_window_controller = new DragWindowController(GetTarget()); | 190 drag_window_controller = new DragWindowController(GetTarget()); |
| 191 // Always show the drag phantom on the |another_root| window. | 191 // Always show the drag phantom on the |another_root| window. |
| 192 drag_window_controller->SetDestinationDisplay( | 192 drag_window_controller->SetDestinationDisplay( |
| 193 Shell::GetScreen()->GetDisplayNearestWindow(another_root)); | 193 gfx::Screen::GetScreen()->GetDisplayNearestWindow(another_root)); |
| 194 drag_window_controller->Show(); | 194 drag_window_controller->Show(); |
| 195 } else { | 195 } else { |
| 196 // No animation. | 196 // No animation. |
| 197 drag_window_controller->SetBounds(bounds_in_screen); | 197 drag_window_controller->SetBounds(bounds_in_screen); |
| 198 } | 198 } |
| 199 const float phantom_opacity = | 199 const float phantom_opacity = |
| 200 !in_original_root ? 1 : (kMaxOpacity * fraction_in_another_window); | 200 !in_original_root ? 1 : (kMaxOpacity * fraction_in_another_window); |
| 201 const float window_opacity = | 201 const float window_opacity = |
| 202 in_original_root ? 1 | 202 in_original_root ? 1 |
| 203 : (kMaxOpacity * (1 - fraction_in_another_window)); | 203 : (kMaxOpacity * (1 - fraction_in_another_window)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 215 drag_window_controllers_.resize(drag_window_controller_count); | 215 drag_window_controllers_.resize(drag_window_controller_count); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool DragWindowResizer::ShouldAllowMouseWarp() { | 218 bool DragWindowResizer::ShouldAllowMouseWarp() { |
| 219 return details().window_component == HTCAPTION && | 219 return details().window_component == HTCAPTION && |
| 220 !::wm::GetTransientParent(GetTarget()) && | 220 !::wm::GetTransientParent(GetTarget()) && |
| 221 wm::IsWindowUserPositionable(GetTarget()); | 221 wm::IsWindowUserPositionable(GetTarget()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace ash | 224 } // namespace ash |
| OLD | NEW |