Chromium Code Reviews| Index: ash/wm/workspace/workspace_window_resizer.cc |
| diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc |
| index 731fcb37a92ac3e24bc558ee1c89428d34e25b00..3712e3beaf35ee321e7efd028c8895c8a4e0129d 100644 |
| --- a/ash/wm/workspace/workspace_window_resizer.cc |
| +++ b/ash/wm/workspace/workspace_window_resizer.cc |
| @@ -95,8 +95,7 @@ scoped_ptr<WindowResizer> CreateWindowResizer( |
| window_resizer = PanelWindowResizer::Create( |
| window_resizer, window, point_in_parent, window_component, source); |
| } |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kAshEnableDockedWindows) && |
| + if (switches::UseDockedWindows() && |
| window_resizer && window->parent() && |
| !window->transient_parent() && |
| (window->parent()->id() == internal::kShellWindowId_DefaultContainer || |
| @@ -117,19 +116,6 @@ namespace { |
| // when resizing a window using touchscreen. |
| const int kScreenEdgeInsetForTouchResize = 32; |
| -// Returns true if the window should stick to the edge. |
| -bool ShouldStickToEdge(int distance_from_edge, int sticky_size) { |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kAshEnableStickyEdges) || |
| - CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kAshEnableDockedWindows)) { |
| - return distance_from_edge < 0 && |
| - distance_from_edge > -sticky_size; |
| - } |
| - return distance_from_edge < sticky_size && |
| - distance_from_edge > -sticky_size * 2; |
| -} |
| - |
| // Returns the coordinate along the secondary axis to snap to. |
| int CoordinateAlongSecondaryAxis(SecondaryMagnetismEdge edge, |
| int leading, |
| @@ -273,6 +259,9 @@ const int WorkspaceWindowResizer::kScreenEdgeInset = 8; |
| // static |
| const int WorkspaceWindowResizer::kStickyDistancePixels = 64; |
| +// static |
| +WorkspaceWindowResizer* WorkspaceWindowResizer::instance_ = NULL; |
| + |
| // Represents the width or height of a window with constraints on its minimum |
| // and maximum size. 0 represents a lack of a constraint. |
| class WindowSize { |
| @@ -345,6 +334,8 @@ class WindowSize { |
| WorkspaceWindowResizer::~WorkspaceWindowResizer() { |
| Shell* shell = Shell::GetInstance(); |
| shell->cursor_manager()->UnlockCursor(); |
| + if (instance_ == this) |
| + instance_ = NULL; |
| } |
| // static |
| @@ -367,9 +358,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent, |
| if (event_flags & ui::EF_CONTROL_DOWN) { |
| sticky_size = 0; |
| } else if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kAshEnableStickyEdges) || |
| - CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kAshEnableDockedWindows)) { |
| + switches::kAshEnableStickyEdges) || switches::UseDockedWindows()) { |
| sticky_size = kStickyDistancePixels; |
| } else if ((details_.bounds_change & kBoundsChange_Resizes) && |
| details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { |
| @@ -542,6 +531,7 @@ WorkspaceWindowResizer::WorkspaceWindowResizer( |
| total_initial_size_ += initial_size; |
| total_available += std::max(min_size, initial_size) - min_size; |
| } |
| + instance_ = this; |
| } |
| gfx::Rect WorkspaceWindowResizer::GetFinalBounds( |
| @@ -818,6 +808,22 @@ void WorkspaceWindowResizer::AdjustBoundsForMainWindow( |
| } |
| } |
| +bool WorkspaceWindowResizer::ShouldStickToEdge(int distance_from_edge, |
| + int sticky_size) const { |
| + if (CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kAshEnableStickyEdges) || switches::UseDockedWindows()) { |
|
flackr
2013/11/01 16:52:28
The stick to edges being tied to docking seems unn
varkha
2013/11/05 20:34:23
Done.
|
| + int snapping_distance = 0; |
| + if ((details_.bounds_change & kBoundsChange_Resizes) && |
| + details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { |
| + snapping_distance = sticky_size / 2; |
| + } |
| + return distance_from_edge < snapping_distance && |
| + distance_from_edge > -sticky_size; |
| + } |
| + return distance_from_edge < sticky_size && |
| + distance_from_edge > -sticky_size * 2; |
| +} |
| + |
| bool WorkspaceWindowResizer::StickToWorkAreaOnMove( |
| const gfx::Rect& work_area, |
| int sticky_size, |