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 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 namespace internal { | 75 namespace internal { |
76 | 76 |
77 namespace { | 77 namespace { |
78 | 78 |
79 // Distance in pixels that the cursor must move past an edge for a window | 79 // Distance in pixels that the cursor must move past an edge for a window |
80 // to move or resize beyond that edge. | 80 // to move or resize beyond that edge. |
81 const int kStickyDistancePixels = 64; | 81 const int kStickyDistancePixels = 64; |
82 | 82 |
| 83 // Snapping distance used instead of WorkspaceWindowResizer::kScreenEdgeInset |
| 84 // when resizing a window using touchscreen. |
| 85 const int kScreenEdgeInsetForTouchResize = 16; |
| 86 |
83 // Returns true if the window should stick to the edge. | 87 // Returns true if the window should stick to the edge. |
84 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) { | 88 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) { |
85 if (CommandLine::ForCurrentProcess()->HasSwitch( | 89 if (CommandLine::ForCurrentProcess()->HasSwitch( |
86 switches::kAshEnableStickyEdges)) { | 90 switches::kAshEnableStickyEdges)) { |
87 return distance_from_edge < 0 && | 91 return distance_from_edge < 0 && |
88 distance_from_edge > -sticky_size; | 92 distance_from_edge > -sticky_size; |
89 } | 93 } |
90 return distance_from_edge < sticky_size && | 94 return distance_from_edge < sticky_size && |
91 distance_from_edge > -sticky_size * 2; | 95 distance_from_edge > -sticky_size * 2; |
92 } | 96 } |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 int event_flags) { | 324 int event_flags) { |
321 last_mouse_location_ = location_in_parent; | 325 last_mouse_location_ = location_in_parent; |
322 | 326 |
323 int sticky_size; | 327 int sticky_size; |
324 if (event_flags & ui::EF_CONTROL_DOWN) { | 328 if (event_flags & ui::EF_CONTROL_DOWN) { |
325 sticky_size = 0; | 329 sticky_size = 0; |
326 } else if (CommandLine::ForCurrentProcess()->HasSwitch( | 330 } else if (CommandLine::ForCurrentProcess()->HasSwitch( |
327 switches::kAshEnableStickyEdges)) { | 331 switches::kAshEnableStickyEdges)) { |
328 sticky_size = kStickyDistancePixels; | 332 sticky_size = kStickyDistancePixels; |
329 } else { | 333 } else { |
330 sticky_size = kScreenEdgeInset; | 334 if ((details_.bounds_change & kBoundsChange_Resizes) && details_.is_touch) |
| 335 sticky_size = kScreenEdgeInsetForTouchResize; |
| 336 else |
| 337 sticky_size = kScreenEdgeInset; |
331 } | 338 } |
332 // |bounds| is in |window()->parent()|'s coordinates. | 339 // |bounds| is in |window()->parent()|'s coordinates. |
333 gfx::Rect bounds = CalculateBoundsForDrag(details_, location_in_parent); | 340 gfx::Rect bounds = CalculateBoundsForDrag(details_, location_in_parent); |
334 | 341 |
335 if (wm::IsWindowNormal(window())) | 342 if (wm::IsWindowNormal(window())) |
336 AdjustBoundsForMainWindow(sticky_size, &bounds); | 343 AdjustBoundsForMainWindow(sticky_size, &bounds); |
337 | 344 |
338 if (bounds != window()->bounds()) { | 345 if (bounds != window()->bounds()) { |
339 if (!did_move_or_resize_) { | 346 if (!did_move_or_resize_) { |
340 if (!details_.restore_bounds.IsEmpty()) | 347 if (!details_.restore_bounds.IsEmpty()) |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); | 851 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window())); |
845 if (location.x() <= area.x()) | 852 if (location.x() <= area.x()) |
846 return SNAP_LEFT_EDGE; | 853 return SNAP_LEFT_EDGE; |
847 if (location.x() >= area.right() - 1) | 854 if (location.x() >= area.right() - 1) |
848 return SNAP_RIGHT_EDGE; | 855 return SNAP_RIGHT_EDGE; |
849 return SNAP_NONE; | 856 return SNAP_NONE; |
850 } | 857 } |
851 | 858 |
852 } // namespace internal | 859 } // namespace internal |
853 } // namespace ash | 860 } // namespace ash |
OLD | NEW |