Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 170863003: Removes #ash-enable-sticky-edges flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/ash_switches.cc ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 return make_scoped_ptr<WindowResizer>(window_resizer); 105 return make_scoped_ptr<WindowResizer>(window_resizer);
106 } 106 }
107 107
108 namespace internal { 108 namespace internal {
109 109
110 namespace { 110 namespace {
111 111
112 // Returns true if the window should stick to the edge. 112 // Returns true if the window should stick to the edge.
113 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) { 113 bool ShouldStickToEdge(int distance_from_edge, int sticky_size) {
114 if (CommandLine::ForCurrentProcess()->HasSwitch(
115 switches::kAshEnableStickyEdges)) {
116 // TODO(varkha): Consider keeping snapping behavior for touch drag.
117 return distance_from_edge < 0 &&
118 distance_from_edge > -sticky_size;
119 }
120 return distance_from_edge < sticky_size && 114 return distance_from_edge < sticky_size &&
121 distance_from_edge > -sticky_size * 2; 115 distance_from_edge > -sticky_size * 2;
122 } 116 }
123 117
124 // Returns the coordinate along the secondary axis to snap to. 118 // Returns the coordinate along the secondary axis to snap to.
125 int CoordinateAlongSecondaryAxis(SecondaryMagnetismEdge edge, 119 int CoordinateAlongSecondaryAxis(SecondaryMagnetismEdge edge,
126 int leading, 120 int leading,
127 int trailing, 121 int trailing,
128 int none) { 122 int none) {
129 switch (edge) { 123 switch (edge) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // static 249 // static
256 const int WorkspaceWindowResizer::kMinOnscreenSize = 20; 250 const int WorkspaceWindowResizer::kMinOnscreenSize = 20;
257 251
258 // static 252 // static
259 const int WorkspaceWindowResizer::kMinOnscreenHeight = 32; 253 const int WorkspaceWindowResizer::kMinOnscreenHeight = 32;
260 254
261 // static 255 // static
262 const int WorkspaceWindowResizer::kScreenEdgeInset = 8; 256 const int WorkspaceWindowResizer::kScreenEdgeInset = 8;
263 257
264 // static 258 // static
265 const int WorkspaceWindowResizer::kStickyDistancePixels = 64;
266
267 // static
268 WorkspaceWindowResizer* WorkspaceWindowResizer::instance_ = NULL; 259 WorkspaceWindowResizer* WorkspaceWindowResizer::instance_ = NULL;
269 260
270 // Represents the width or height of a window with constraints on its minimum 261 // Represents the width or height of a window with constraints on its minimum
271 // and maximum size. 0 represents a lack of a constraint. 262 // and maximum size. 0 represents a lack of a constraint.
272 class WindowSize { 263 class WindowSize {
273 public: 264 public:
274 WindowSize(int size, int min, int max) 265 WindowSize(int size, int min, int max)
275 : size_(size), 266 : size_(size),
276 min_(min), 267 min_(min),
277 max_(max) { 268 max_(max) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return new WorkspaceWindowResizer(window_state, attached_windows); 343 return new WorkspaceWindowResizer(window_state, attached_windows);
353 } 344 }
354 345
355 void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent, 346 void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
356 int event_flags) { 347 int event_flags) {
357 last_mouse_location_ = location_in_parent; 348 last_mouse_location_ = location_in_parent;
358 349
359 int sticky_size; 350 int sticky_size;
360 if (event_flags & ui::EF_CONTROL_DOWN) { 351 if (event_flags & ui::EF_CONTROL_DOWN) {
361 sticky_size = 0; 352 sticky_size = 0;
362 } else if (CommandLine::ForCurrentProcess()->HasSwitch(
363 switches::kAshEnableStickyEdges)) {
364 sticky_size = kStickyDistancePixels;
365 } else if ((details().bounds_change & kBoundsChange_Resizes) && 353 } else if ((details().bounds_change & kBoundsChange_Resizes) &&
366 details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { 354 details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
367 sticky_size = SnapSizer::kScreenEdgeInsetForTouchDrag; 355 sticky_size = SnapSizer::kScreenEdgeInsetForTouchDrag;
368 } else { 356 } else {
369 sticky_size = kScreenEdgeInset; 357 sticky_size = kScreenEdgeInset;
370 } 358 }
371 // |bounds| is in |GetTarget()->parent()|'s coordinates. 359 // |bounds| is in |GetTarget()->parent()|'s coordinates.
372 gfx::Rect bounds = CalculateBoundsForDrag(location_in_parent); 360 gfx::Rect bounds = CalculateBoundsForDrag(location_in_parent);
373 AdjustBoundsForMainWindow(sticky_size, &bounds); 361 AdjustBoundsForMainWindow(sticky_size, &bounds);
374 362
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1032 gfx::Rect snapped_bounds = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1045 GetTarget()); 1033 GetTarget());
1046 if (snapped_type == wm::SHOW_TYPE_RIGHT_SNAPPED) 1034 if (snapped_type == wm::SHOW_TYPE_RIGHT_SNAPPED)
1047 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width()); 1035 snapped_bounds.set_x(snapped_bounds.right() - bounds_in_parent.width());
1048 snapped_bounds.set_width(bounds_in_parent.width()); 1036 snapped_bounds.set_width(bounds_in_parent.width());
1049 return bounds_in_parent == snapped_bounds; 1037 return bounds_in_parent == snapped_bounds;
1050 } 1038 }
1051 1039
1052 } // namespace internal 1040 } // namespace internal
1053 } // namespace ash 1041 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash_switches.cc ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698