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/workspace/workspace_window_resizer.h" | 5 #include "ash/wm/workspace/workspace_window_resizer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 gfx::Rect bounds(GetFinalBounds(details_.window->bounds(), grid_size)); | 100 gfx::Rect bounds(GetFinalBounds(details_.window->bounds(), grid_size)); |
101 if (bounds == details_.window->bounds()) | 101 if (bounds == details_.window->bounds()) |
102 return; | 102 return; |
103 | 103 |
104 if (bounds.size() != details_.window->bounds().size()) { | 104 if (bounds.size() != details_.window->bounds().size()) { |
105 // Don't attempt to animate a size change. | 105 // Don't attempt to animate a size change. |
106 details_.window->SetBounds(bounds); | 106 details_.window->SetBounds(bounds); |
107 return; | 107 return; |
108 } | 108 } |
109 | 109 // TODO(oshima|yusukes): This is temporary solution until better drag & move |
110 ui::ScopedLayerAnimationSettings scoped_setter( | 110 // is implemented. (crbug.com/136816). |
111 details_.window->layer()->GetAnimator()); | 111 gfx::Rect dst_bounds = |
112 // Use a small duration since the grid is small. | 112 ScreenAsh::ConvertRectToScreen(details_.window->parent(), bounds); |
113 scoped_setter.SetTransitionDuration( | 113 gfx::Display dst_display = gfx::Screen::GetDisplayMatching(dst_bounds); |
114 base::TimeDelta::FromMilliseconds(kSnapDurationMS)); | 114 if (dst_display.id() != |
115 details_.window->SetBounds(bounds); | 115 gfx::Screen::GetDisplayNearestWindow(details_.window).id()) { |
| 116 // Don't animate when moving to another display. |
| 117 details_.window->SetBoundsInScreen(dst_bounds); |
| 118 } else { |
| 119 ui::ScopedLayerAnimationSettings scoped_setter( |
| 120 details_.window->layer()->GetAnimator()); |
| 121 // Use a small duration since the grid is small. |
| 122 scoped_setter.SetTransitionDuration( |
| 123 base::TimeDelta::FromMilliseconds(kSnapDurationMS)); |
| 124 details_.window->SetBounds(bounds); |
| 125 } |
116 } | 126 } |
117 | 127 |
118 void WorkspaceWindowResizer::RevertDrag() { | 128 void WorkspaceWindowResizer::RevertDrag() { |
119 phantom_window_controller_.reset(); | 129 phantom_window_controller_.reset(); |
120 | 130 |
121 if (!did_move_or_resize_) | 131 if (!did_move_or_resize_) |
122 return; | 132 return; |
123 | 133 |
124 details_.window->SetBounds(details_.initial_bounds); | 134 details_.window->SetBounds(details_.initial_bounds); |
125 if (details_.window_component == HTRIGHT) { | 135 if (details_.window_component == HTRIGHT) { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(details_.window)); | 436 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(details_.window)); |
427 if (location.x() <= area.x()) | 437 if (location.x() <= area.x()) |
428 return SNAP_LEFT_EDGE; | 438 return SNAP_LEFT_EDGE; |
429 if (location.x() >= area.right() - 1) | 439 if (location.x() >= area.right() - 1) |
430 return SNAP_RIGHT_EDGE; | 440 return SNAP_RIGHT_EDGE; |
431 return SNAP_NONE; | 441 return SNAP_NONE; |
432 } | 442 } |
433 | 443 |
434 } // namespace internal | 444 } // namespace internal |
435 } // namespace ash | 445 } // namespace ash |
OLD | NEW |