summaryrefslogtreecommitdiffstats
path: root/ash/wm
diff options
context:
space:
mode:
authorvarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 21:41:26 +0000
committervarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 21:41:26 +0000
commitc35e7ec8e0b3d525f27f5a52864c61768698954f (patch)
tree3a39891959a74851ad3a889267ba60a6ebf68585 /ash/wm
parent863f0ef77be6de51154a5b490577440f4795befd (diff)
downloadchromium_src-c35e7ec8e0b3d525f27f5a52864c61768698954f.zip
chromium_src-c35e7ec8e0b3d525f27f5a52864c61768698954f.tar.gz
chromium_src-c35e7ec8e0b3d525f27f5a52864c61768698954f.tar.bz2
Removes individual instances of Details structure in WindowResizer subclasses and adds DragDetails to WindowState. It is possible to access the current WindowResizer during the drag via window_state->drag_details()->window_resizer.
Simplifies construction of WindowResizer chain by creating DragDetails once at a point where creation of the resizer chain is imminent (after all checks that would return empty WindowResizer object are made). Keeps track of whether currently dragged window is a panel attached to the shelf and if so prevents it from indicating that it can be docked (and from getting docked). BUG=310931 Review URL: https://codereview.chromium.org/121153003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm')
-rw-r--r--ash/wm/default_window_resizer.cc39
-rw-r--r--ash/wm/default_window_resizer.h18
-rw-r--r--ash/wm/dock/docked_window_layout_manager.cc10
-rw-r--r--ash/wm/dock/docked_window_resizer.cc56
-rw-r--r--ash/wm/dock/docked_window_resizer.h11
-rw-r--r--ash/wm/drag_details.cc74
-rw-r--r--ash/wm/drag_details.h72
-rw-r--r--ash/wm/drag_window_resizer.cc51
-rw-r--r--ash/wm/drag_window_resizer.h11
-rw-r--r--ash/wm/panels/panel_window_resizer.cc51
-rw-r--r--ash/wm/panels/panel_window_resizer.h14
-rw-r--r--ash/wm/window_resizer.cc282
-rw-r--r--ash/wm/window_resizer.h99
-rw-r--r--ash/wm/window_state.cc17
-rw-r--r--ash/wm/window_state.h39
-rw-r--r--ash/wm/workspace/multi_window_resize_controller.cc14
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc202
-rw-r--r--ash/wm/workspace/workspace_window_resizer.h15
-rw-r--r--ash/wm/workspace/workspace_window_resizer_unittest.cc49
19 files changed, 545 insertions, 579 deletions
diff --git a/ash/wm/default_window_resizer.cc b/ash/wm/default_window_resizer.cc
index 97dbbe7..ac0042d 100644
--- a/ash/wm/default_window_resizer.cc
+++ b/ash/wm/default_window_resizer.cc
@@ -22,21 +22,17 @@ DefaultWindowResizer::~DefaultWindowResizer() {
// static
DefaultWindowResizer*
-DefaultWindowResizer::Create(aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source) {
- Details details(window, location, window_component, source);
- return details.is_resizable ? new DefaultWindowResizer(details) : NULL;
+DefaultWindowResizer::Create(wm::WindowState* window_state) {
+ return new DefaultWindowResizer(window_state);
}
void DefaultWindowResizer::Drag(const gfx::Point& location, int event_flags) {
- gfx::Rect bounds(CalculateBoundsForDrag(details_, location));
- if (bounds != details_.window->bounds()) {
- if (!did_move_or_resize_ && !details_.restore_bounds.IsEmpty())
- wm::GetWindowState(details_.window)->ClearRestoreBounds();
+ gfx::Rect bounds(CalculateBoundsForDrag(location));
+ if (bounds != GetTarget()->bounds()) {
+ if (!did_move_or_resize_ && !details().restore_bounds.IsEmpty())
+ window_state_->ClearRestoreBounds();
did_move_or_resize_ = true;
- details_.window->SetBounds(bounds);
+ GetTarget()->SetBounds(bounds);
}
}
@@ -47,25 +43,16 @@ void DefaultWindowResizer::RevertDrag() {
if (!did_move_or_resize_)
return;
- details_.window->SetBounds(details_.initial_bounds_in_parent);
+ GetTarget()->SetBounds(details().initial_bounds_in_parent);
- if (!details_.restore_bounds.IsEmpty())
- wm::GetWindowState(details_.window)->SetRestoreBoundsInScreen(
- details_.restore_bounds);
+ if (!details().restore_bounds.IsEmpty())
+ window_state_->SetRestoreBoundsInScreen(details().restore_bounds);
}
-aura::Window* DefaultWindowResizer::GetTarget() {
- return details_.window;
-}
-
-const gfx::Point& DefaultWindowResizer::GetInitialLocation() const {
- return details_.initial_location_in_parent;
-}
-
-DefaultWindowResizer::DefaultWindowResizer(const Details& details)
- : details_(details),
+DefaultWindowResizer::DefaultWindowResizer(wm::WindowState* window_state)
+ : WindowResizer(window_state),
did_move_or_resize_(false) {
- DCHECK(details_.is_resizable);
+ DCHECK(details().is_resizable);
ash::Shell::GetInstance()->cursor_manager()->LockCursor();
}
diff --git a/ash/wm/default_window_resizer.h b/ash/wm/default_window_resizer.h
index f459d52..40d2355 100644
--- a/ash/wm/default_window_resizer.h
+++ b/ash/wm/default_window_resizer.h
@@ -18,31 +18,23 @@ class ASH_EXPORT DefaultWindowResizer : public WindowResizer {
virtual ~DefaultWindowResizer();
// Creates a new DefaultWindowResizer. The caller takes ownership of the
- // returned object. Returns NULL if not resizable.
- static DefaultWindowResizer* Create(aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source);
+ // returned object.
+ static DefaultWindowResizer* Create(wm::WindowState* window_state);
// Returns true if the drag will result in changing the window in anyway.
- bool is_resizable() const { return details_.is_resizable; }
+ bool is_resizable() const { return details().is_resizable; }
bool changed_size() const {
- return !(details_.bounds_change & kBoundsChange_Repositions);
+ return !(details().bounds_change & kBoundsChange_Repositions);
}
- aura::Window* target_window() const { return details_.window; }
// WindowResizer:
virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE;
virtual void CompleteDrag() OVERRIDE;
virtual void RevertDrag() OVERRIDE;
- virtual aura::Window* GetTarget() OVERRIDE;
- virtual const gfx::Point& GetInitialLocation() const OVERRIDE;
private:
- explicit DefaultWindowResizer(const Details& details);
-
- const Details details_;
+ explicit DefaultWindowResizer(wm::WindowState* window_state);
// Set to true once Drag() is invoked and the bounds of the window change.
bool did_move_or_resize_;
diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc
index 5d16a24..baee303 100644
--- a/ash/wm/dock/docked_window_layout_manager.cc
+++ b/ash/wm/dock/docked_window_layout_manager.cc
@@ -532,8 +532,12 @@ bool DockedWindowLayoutManager::CanDockWindow(aura::Window* window,
if (!switches::UseDockedWindows())
return false;
// Don't allow interactive docking of windows with transient parents such as
- // modal browser dialogs.
- if (IsPopupOrTransient(window))
+ // modal browser dialogs. Prevent docking of panels attached to shelf during
+ // the drag.
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ bool should_attach_to_shelf = window_state->drag_details() &&
+ window_state->drag_details()->should_attach_to_shelf;
+ if (IsPopupOrTransient(window) || should_attach_to_shelf)
return false;
// If a window is wide and cannot be resized down to maximum width allowed
// then it cannot be docked.
@@ -541,7 +545,7 @@ bool DockedWindowLayoutManager::CanDockWindow(aura::Window* window,
// they are docked. The size will take effect only once a window is undocked.
// See http://crbug.com/307792.
if (window->bounds().width() > kMaxDockWidth &&
- (!wm::GetWindowState(window)->CanResize() ||
+ (!window_state->CanResize() ||
(window->delegate() &&
window->delegate()->GetMinimumSize().width() != 0 &&
window->delegate()->GetMinimumSize().width() > kMaxDockWidth))) {
diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc
index 8c67b55..3ee18de 100644
--- a/ash/wm/dock/docked_window_resizer.cc
+++ b/ash/wm/dock/docked_window_resizer.cc
@@ -57,13 +57,8 @@ DockedWindowResizer::~DockedWindowResizer() {
// static
DockedWindowResizer*
DockedWindowResizer::Create(WindowResizer* next_window_resizer,
- aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source) {
- Details details(window, location, window_component, source);
- return details.is_resizable ?
- new DockedWindowResizer(next_window_resizer, details) : NULL;
+ wm::WindowState* window_state) {
+ return new DockedWindowResizer(next_window_resizer, window_state);
}
void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) {
@@ -74,7 +69,7 @@ void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) {
StartedDragging();
}
gfx::Point offset;
- gfx::Rect bounds(CalculateBoundsForDrag(details_, location));
+ gfx::Rect bounds(CalculateBoundsForDrag(location));
MaybeSnapToEdge(bounds, &offset);
gfx::Point modified_location(location);
modified_location.Offset(offset.x(), offset.y());
@@ -98,7 +93,7 @@ void DockedWindowResizer::Drag(const gfx::Point& location, int event_flags) {
if (dock_layout_ != initial_dock_layout_)
dock_layout_->FinishDragging(
DOCKED_ACTION_NONE,
- details_.source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ?
+ details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ?
DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH);
is_docked_ = false;
dock_layout_ = new_dock_layout;
@@ -134,34 +129,25 @@ void DockedWindowResizer::RevertDrag() {
FinishedDragging();
}
-aura::Window* DockedWindowResizer::GetTarget() {
- return next_window_resizer_->GetTarget();
-}
-
-const gfx::Point& DockedWindowResizer::GetInitialLocation() const {
- return details_.initial_location_in_parent;
-}
-
DockedWindowResizer::DockedWindowResizer(WindowResizer* next_window_resizer,
- const Details& details)
- : details_(details),
+ wm::WindowState* window_state)
+ : WindowResizer(window_state),
next_window_resizer_(next_window_resizer),
dock_layout_(NULL),
initial_dock_layout_(NULL),
did_move_or_resize_(false),
was_docked_(false),
is_docked_(false),
- was_bounds_changed_by_user_(
- wm::GetWindowState(details.window)->bounds_changed_by_user()),
+ was_bounds_changed_by_user_(window_state->bounds_changed_by_user()),
weak_ptr_factory_(this) {
- DCHECK(details_.is_resizable);
+ DCHECK(details().is_resizable);
aura::Window* dock_container = Shell::GetContainer(
- details.window->GetRootWindow(),
+ GetTarget()->GetRootWindow(),
kShellWindowId_DockedContainer);
dock_layout_ = static_cast<DockedWindowLayoutManager*>(
dock_container->layout_manager());
initial_dock_layout_ = dock_layout_;
- was_docked_ = details.window->parent() == dock_container;
+ was_docked_ = GetTarget()->parent() == dock_container;
is_docked_ = was_docked_;
}
@@ -197,10 +183,9 @@ void DockedWindowResizer::MaybeSnapToEdge(const gfx::Rect& bounds,
void DockedWindowResizer::StartedDragging() {
// During resizing the window width is preserved by DockedwindowLayoutManager.
- wm::WindowState* window_state = wm::GetWindowState(GetTarget());
if (is_docked_ &&
- (details_.bounds_change & WindowResizer::kBoundsChange_Resizes)) {
- window_state->set_bounds_changed_by_user(true);
+ (details().bounds_change & WindowResizer::kBoundsChange_Resizes)) {
+ window_state_->set_bounds_changed_by_user(true);
}
// Tell the dock layout manager that we are dragging this window.
@@ -213,7 +198,7 @@ void DockedWindowResizer::StartedDragging() {
if (GetTarget()->type() != ui::wm::WINDOW_TYPE_PANEL &&
GetTarget()->parent()->id() == kShellWindowId_DefaultContainer) {
// The window is going to be reparented - avoid completing the drag.
- window_state->set_continue_drag_after_reparent(true);
+ window_state_->set_continue_drag_after_reparent(true);
// Reparent the window into the docked windows container in order to get it
// on top of other docked windows.
@@ -233,11 +218,10 @@ void DockedWindowResizer::FinishedDragging() {
return;
did_move_or_resize_ = false;
aura::Window* window = GetTarget();
- wm::WindowState* window_state = wm::GetWindowState(window);
const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL &&
- window_state->panel_attached();
+ window_state_->panel_attached();
const bool is_resized =
- (details_.bounds_change & WindowResizer::kBoundsChange_Resizes) != 0;
+ (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0;
// When drag is completed the dragged docked window is resized to the bounds
// calculated by the layout manager that conform to other docked windows.
@@ -250,11 +234,11 @@ void DockedWindowResizer::FinishedDragging() {
}
// If a window has restore bounds, update the restore origin and width but not
// the height (since the height is auto-calculated for the docked windows).
- if (is_resized && is_docked_ && window_state->HasRestoreBounds()) {
+ if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) {
gfx::Rect restore_bounds = window->GetBoundsInScreen();
restore_bounds.set_height(
- window_state->GetRestoreBoundsInScreen().height());
- window_state->SetRestoreBoundsInScreen(restore_bounds);
+ window_state_->GetRestoreBoundsInScreen().height());
+ window_state_->SetRestoreBoundsInScreen(restore_bounds);
}
// Check if the window needs to be docked or returned to workspace.
@@ -262,7 +246,7 @@ void DockedWindowResizer::FinishedDragging() {
is_attached_panel);
dock_layout_->FinishDragging(
action,
- details_.source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ?
+ details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ?
DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH);
// If we started the drag in one root window and moved into another root
@@ -271,7 +255,7 @@ void DockedWindowResizer::FinishedDragging() {
if (initial_dock_layout_ != dock_layout_)
initial_dock_layout_->FinishDragging(
DOCKED_ACTION_NONE,
- details_.source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ?
+ details().source == aura::client::WINDOW_MOVE_SOURCE_MOUSE ?
DOCKED_ACTION_SOURCE_MOUSE : DOCKED_ACTION_SOURCE_TOUCH);
is_docked_ = false;
}
diff --git a/ash/wm/dock/docked_window_resizer.h b/ash/wm/dock/docked_window_resizer.h
index 75c6071..6614e2d 100644
--- a/ash/wm/dock/docked_window_resizer.h
+++ b/ash/wm/dock/docked_window_resizer.h
@@ -35,24 +35,19 @@ class ASH_EXPORT DockedWindowResizer : public WindowResizer {
// returned object. The ownership of |next_window_resizer| is taken by the
// returned object. Returns NULL if not resizable.
static DockedWindowResizer* Create(WindowResizer* next_window_resizer,
- aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source);
+ wm::WindowState* window_state);
// WindowResizer:
virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE;
virtual void CompleteDrag() OVERRIDE;
virtual void RevertDrag() OVERRIDE;
- virtual aura::Window* GetTarget() OVERRIDE;
- virtual const gfx::Point& GetInitialLocation() const OVERRIDE;
private:
// Creates DockWindowResizer that adds the ability to attach / detach
// windows to / from the dock. This object takes ownership of
// |next_window_resizer|.
DockedWindowResizer(WindowResizer* next_window_resizer,
- const Details& details);
+ wm::WindowState* window_state);
// If the provided window bounds should snap to the side of a screen,
// returns the offset that gives the necessary adjustment to snap.
@@ -75,8 +70,6 @@ class ASH_EXPORT DockedWindowResizer : public WindowResizer {
DockedAction MaybeReparentWindowOnDragCompletion(bool is_resized,
bool is_attached_panel);
- const Details details_;
-
gfx::Point last_location_;
// Wraps a window resizer and adds detaching / reattaching during drags.
diff --git a/ash/wm/drag_details.cc b/ash/wm/drag_details.cc
new file mode 100644
index 0000000..5fa6d0a
--- /dev/null
+++ b/ash/wm/drag_details.cc
@@ -0,0 +1,74 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/drag_details.h"
+
+#include "ash/wm/window_resizer.h"
+#include "ui/aura/window.h"
+#include "ui/base/hit_test.h"
+
+namespace ash {
+
+namespace {
+
+int GetSizeChangeDirectionForWindowComponent(int window_component) {
+ int size_change_direction = WindowResizer::kBoundsChangeDirection_None;
+ switch (window_component) {
+ case HTTOPLEFT:
+ case HTTOPRIGHT:
+ case HTBOTTOMLEFT:
+ case HTBOTTOMRIGHT:
+ case HTGROWBOX:
+ case HTCAPTION:
+ size_change_direction |=
+ WindowResizer::kBoundsChangeDirection_Horizontal |
+ WindowResizer::kBoundsChangeDirection_Vertical;
+ break;
+ case HTTOP:
+ case HTBOTTOM:
+ size_change_direction |= WindowResizer::kBoundsChangeDirection_Vertical;
+ break;
+ case HTRIGHT:
+ case HTLEFT:
+ size_change_direction |= WindowResizer::kBoundsChangeDirection_Horizontal;
+ break;
+ default:
+ break;
+ }
+ return size_change_direction;
+}
+
+} // namespace
+
+DragDetails::DragDetails(aura::Window* window,
+ const gfx::Point& location,
+ int window_component,
+ aura::client::WindowMoveSource source)
+ : initial_bounds_in_parent(window->bounds()),
+ initial_location_in_parent(location),
+ initial_opacity(window->layer()->opacity()),
+ window_component(window_component),
+ bounds_change(
+ WindowResizer::GetBoundsChangeForWindowComponent(window_component)),
+ position_change_direction(
+ WindowResizer::GetPositionChangeDirectionForWindowComponent(
+ window_component)),
+ size_change_direction(
+ GetSizeChangeDirectionForWindowComponent(window_component)),
+ is_resizable(bounds_change != WindowResizer::kBoundsChangeDirection_None),
+ source(source),
+ should_attach_to_shelf(window->type() == ui::wm::WINDOW_TYPE_PANEL &&
+ wm::GetWindowState(window)->panel_attached()),
+ window_resizer(NULL) {
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ if (window_state->IsNormalShowState() &&
+ window_state->HasRestoreBounds() &&
+ window_component == HTCAPTION)
+ restore_bounds = window_state->GetRestoreBoundsInScreen();
+}
+
+DragDetails::~DragDetails() {
+}
+
+} // namespace ash
diff --git a/ash/wm/drag_details.h b/ash/wm/drag_details.h
new file mode 100644
index 0000000..9b8cc38
--- /dev/null
+++ b/ash/wm/drag_details.h
@@ -0,0 +1,72 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_WM_DRAG_DETAILS_H_
+#define ASH_WM_DRAG_DETAILS_H_
+
+#include "ash/ash_export.h"
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/aura/client/window_move_client.h"
+#include "ui/gfx/rect.h"
+
+namespace aura {
+class Window;
+}
+
+namespace ash {
+class WindowResizer;
+
+namespace wm {
+class WindowState;
+}
+
+struct ASH_EXPORT DragDetails {
+ DragDetails(aura::Window* window,
+ const gfx::Point& location,
+ int window_component,
+ aura::client::WindowMoveSource source);
+ ~DragDetails();
+
+ // Initial bounds of the window in parent coordinates.
+ const gfx::Rect initial_bounds_in_parent;
+
+ // Restore bounds (in screen coordinates) of the window before the drag
+ // started. Only set if the window is normal and is being dragged.
+ gfx::Rect restore_bounds;
+
+ // Location passed to the constructor, in |window->parent()|'s coordinates.
+ const gfx::Point initial_location_in_parent;
+
+ // Initial opacity of the window.
+ const float initial_opacity;
+
+ // The component the user pressed on.
+ const int window_component;
+
+ // Bitmask of the |kBoundsChange_| constants.
+ const int bounds_change;
+
+ // Bitmask of the |kBoundsChangeDirection_| constants.
+ const int position_change_direction;
+
+ // Bitmask of the |kBoundsChangeDirection_| constants.
+ const int size_change_direction;
+
+ // Will the drag actually modify the window?
+ const bool is_resizable;
+
+ // Source of the event initiating the drag.
+ const aura::client::WindowMoveSource source;
+
+ // True if the window should attach to the shelf after releasing.
+ bool should_attach_to_shelf;
+
+ // WindowResizer that is controlling the drag.
+ WindowResizer* window_resizer;
+};
+
+} // namespace ash
+
+#endif // ASH_WM_DRAG_DETAILS_H_
diff --git a/ash/wm/drag_window_resizer.cc b/ash/wm/drag_window_resizer.cc
index 835b204..c678d16 100644
--- a/ash/wm/drag_window_resizer.cc
+++ b/ash/wm/drag_window_resizer.cc
@@ -59,8 +59,8 @@ aura::Window* GetAnotherRootWindow(aura::Window* root_window) {
DragWindowResizer* DragWindowResizer::instance_ = NULL;
DragWindowResizer::~DragWindowResizer() {
- if (GetTarget())
- wm::GetWindowState(GetTarget())->set_window_resizer_(NULL);
+ if (window_state_)
+ window_state_->DeleteDragDetails();
Shell* shell = Shell::GetInstance();
shell->mouse_cursor_filter()->set_mouse_warp_mode(
MouseCursorEventFilter::WARP_ALWAYS);
@@ -72,13 +72,8 @@ DragWindowResizer::~DragWindowResizer() {
// static
DragWindowResizer* DragWindowResizer::Create(
WindowResizer* next_window_resizer,
- aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source) {
- Details details(window, location, window_component, source);
- return details.is_resizable ?
- new DragWindowResizer(next_window_resizer, details) : NULL;
+ wm::WindowState* window_state) {
+ return new DragWindowResizer(next_window_resizer, window_state);
}
void DragWindowResizer::Drag(const gfx::Point& location, int event_flags) {
@@ -88,7 +83,7 @@ void DragWindowResizer::Drag(const gfx::Point& location, int event_flags) {
// temporarily back to where it was initially and make it semi-transparent.
GetTarget()->layer()->SetOpacity(
GetTrayUserItemAtPoint(location) ? kOpacityWhenDraggedOverUserIcon :
- details_.initial_opacity);
+ details().initial_opacity);
next_window_resizer_->Drag(location, event_flags);
@@ -114,7 +109,7 @@ void DragWindowResizer::CompleteDrag() {
next_window_resizer_->CompleteDrag();
- GetTarget()->layer()->SetOpacity(details_.initial_opacity);
+ GetTarget()->layer()->SetOpacity(details().initial_opacity);
drag_window_controller_.reset();
// Check if the destination is another display.
@@ -161,21 +156,13 @@ void DragWindowResizer::RevertDrag() {
next_window_resizer_->RevertDrag();
drag_window_controller_.reset();
- GetTarget()->layer()->SetOpacity(details_.initial_opacity);
-}
-
-aura::Window* DragWindowResizer::GetTarget() {
- return next_window_resizer_->GetTarget();
-}
-
-const gfx::Point& DragWindowResizer::GetInitialLocation() const {
- return details_.initial_location_in_parent;
+ GetTarget()->layer()->SetOpacity(details().initial_opacity);
}
DragWindowResizer::DragWindowResizer(WindowResizer* next_window_resizer,
- const Details& details)
- : next_window_resizer_(next_window_resizer),
- details_(details),
+ wm::WindowState* window_state)
+ : WindowResizer(window_state),
+ next_window_resizer_(next_window_resizer),
weak_ptr_factory_(this) {
// The pointer should be confined in one display during resizing a window
// because the window cannot span two displays at the same time anyway. The
@@ -187,16 +174,14 @@ DragWindowResizer::DragWindowResizer(WindowResizer* next_window_resizer,
mouse_cursor_filter->set_mouse_warp_mode(
ShouldAllowMouseWarp() ?
MouseCursorEventFilter::WARP_DRAG : MouseCursorEventFilter::WARP_NONE);
- if (ShouldAllowMouseWarp()) {
- mouse_cursor_filter->ShowSharedEdgeIndicator(
- details.window->GetRootWindow());
- }
+ if (ShouldAllowMouseWarp())
+ mouse_cursor_filter->ShowSharedEdgeIndicator(GetTarget()->GetRootWindow());
instance_ = this;
}
void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds,
bool in_original_root) {
- if (details_.window_component != HTCAPTION || !ShouldAllowMouseWarp())
+ if (details().window_component != HTCAPTION || !ShouldAllowMouseWarp())
return;
// It's available. Show a phantom window on the display if needed.
@@ -236,7 +221,7 @@ void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds,
}
bool DragWindowResizer::ShouldAllowMouseWarp() {
- return (details_.window_component == HTCAPTION) &&
+ return (details().window_component == HTCAPTION) &&
!views::corewm::GetTransientParent(GetTarget()) &&
(GetTarget()->type() == ui::wm::WINDOW_TYPE_NORMAL ||
GetTarget()->type() == ui::wm::WINDOW_TYPE_PANEL);
@@ -249,7 +234,7 @@ TrayUser* DragWindowResizer::GetTrayUserItemAtPoint(
return NULL;
// Check that this is a drag move operation from a suitable window.
- if (details_.window_component != HTCAPTION ||
+ if (details().window_component != HTCAPTION ||
views::corewm::GetTransientParent(GetTarget()) ||
(GetTarget()->type() != ui::wm::WINDOW_TYPE_NORMAL &&
GetTarget()->type() != ui::wm::WINDOW_TYPE_PANEL &&
@@ -258,7 +243,7 @@ TrayUser* DragWindowResizer::GetTrayUserItemAtPoint(
// We only allow to drag the window onto a tray of it's own RootWindow.
SystemTray* tray = internal::GetRootWindowController(
- details_.window->GetRootWindow())->GetSystemTray();
+ GetTarget()->GetRootWindow())->GetSystemTray();
// Again - unit tests might not have a tray.
if (!tray)
@@ -289,8 +274,8 @@ bool DragWindowResizer::TryDraggingToNewUser() {
// it's thing and return the transparency to its original value.
int old_opacity = GetTarget()->layer()->opacity();
GetTarget()->layer()->SetOpacity(0);
- GetTarget()->SetBounds(details_.initial_bounds_in_parent);
- if (!tray_user->TransferWindowToUser(details_.window)) {
+ GetTarget()->SetBounds(details().initial_bounds_in_parent);
+ if (!tray_user->TransferWindowToUser(GetTarget())) {
GetTarget()->layer()->SetOpacity(old_opacity);
return false;
}
diff --git a/ash/wm/drag_window_resizer.h b/ash/wm/drag_window_resizer.h
index 108bfed..2cb6ecc 100644
--- a/ash/wm/drag_window_resizer.h
+++ b/ash/wm/drag_window_resizer.h
@@ -27,17 +27,12 @@ class ASH_EXPORT DragWindowResizer : public WindowResizer {
// returned object. The ownership of |next_window_resizer| is taken by the
// returned object. Returns NULL if not resizable.
static DragWindowResizer* Create(WindowResizer* next_window_resizer,
- aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source);
+ wm::WindowState* window_state);
// WindowResizer:
virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE;
virtual void CompleteDrag() OVERRIDE;
virtual void RevertDrag() OVERRIDE;
- virtual aura::Window* GetTarget() OVERRIDE;
- virtual const gfx::Point& GetInitialLocation() const OVERRIDE;
private:
FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, DragWindowController);
@@ -46,7 +41,7 @@ class ASH_EXPORT DragWindowResizer : public WindowResizer {
// displays to |next_window_resizer|. This object takes the ownership of
// |next_window_resizer|.
explicit DragWindowResizer(WindowResizer* next_window_resizer,
- const Details& details);
+ wm::WindowState* window_state);
// Updates the bounds of the phantom window for window dragging. Set true on
// |in_original_root| if the pointer is still in |window()->GetRootWindow()|.
@@ -68,8 +63,6 @@ class ASH_EXPORT DragWindowResizer : public WindowResizer {
// Shows a semi-transparent image of the window being dragged.
scoped_ptr<DragWindowController> drag_window_controller_;
- const Details details_;
-
gfx::Point last_mouse_location_;
// Current instance for use by the DragWindowResizerTest.
diff --git a/ash/wm/panels/panel_window_resizer.cc b/ash/wm/panels/panel_window_resizer.cc
index cc5a315..8e4311a 100644
--- a/ash/wm/panels/panel_window_resizer.cc
+++ b/ash/wm/panels/panel_window_resizer.cc
@@ -47,13 +47,8 @@ PanelWindowResizer::~PanelWindowResizer() {
// static
PanelWindowResizer*
PanelWindowResizer::Create(WindowResizer* next_window_resizer,
- aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source) {
- Details details(window, location, window_component, source);
- return details.is_resizable ?
- new PanelWindowResizer(next_window_resizer, details) : NULL;
+ wm::WindowState* window_state) {
+ return new PanelWindowResizer(next_window_resizer, window_state);
}
void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
@@ -88,8 +83,11 @@ void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget());
}
gfx::Point offset;
- gfx::Rect bounds(CalculateBoundsForDrag(details_, location));
- should_attach_ = AttachToLauncher(bounds, &offset);
+ gfx::Rect bounds(CalculateBoundsForDrag(location));
+ if (!(details().bounds_change & WindowResizer::kBoundsChange_Resizes)) {
+ window_state_->drag_details()->should_attach_to_shelf =
+ AttachToLauncher(bounds, &offset);
+ }
gfx::Point modified_location(location.x() + offset.x(),
location.y() + offset.y());
@@ -98,8 +96,8 @@ void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) {
if (!resizer)
return;
- if (should_attach_ &&
- !(details_.bounds_change & WindowResizer::kBoundsChange_Resizes)) {
+ if (details().should_attach_to_shelf &&
+ !(details().bounds_change & WindowResizer::kBoundsChange_Resizes)) {
UpdateLauncherPosition();
}
}
@@ -112,31 +110,22 @@ void PanelWindowResizer::CompleteDrag() {
void PanelWindowResizer::RevertDrag() {
next_window_resizer_->RevertDrag();
- should_attach_ = was_attached_;
+ window_state_->drag_details()->should_attach_to_shelf = was_attached_;
FinishDragging();
}
-aura::Window* PanelWindowResizer::GetTarget() {
- return next_window_resizer_->GetTarget();
-}
-
-const gfx::Point& PanelWindowResizer::GetInitialLocation() const {
- return details_.initial_location_in_parent;
-}
-
PanelWindowResizer::PanelWindowResizer(WindowResizer* next_window_resizer,
- const Details& details)
- : details_(details),
+ wm::WindowState* window_state)
+ : WindowResizer(window_state),
next_window_resizer_(next_window_resizer),
panel_container_(NULL),
initial_panel_container_(NULL),
did_move_or_resize_(false),
- was_attached_(wm::GetWindowState(GetTarget())->panel_attached()),
- should_attach_(was_attached_),
+ was_attached_(window_state->panel_attached()),
weak_ptr_factory_(this) {
- DCHECK(details_.is_resizable);
+ DCHECK(details().is_resizable);
panel_container_ = Shell::GetContainer(
- details.window->GetRootWindow(),
+ GetTarget()->GetRootWindow(),
internal::kShellWindowId_PanelContainer);
initial_panel_container_ = panel_container_;
}
@@ -192,8 +181,8 @@ void PanelWindowResizer::StartedDragging() {
GetPanelLayoutManager(panel_container_)->StartDragging(GetTarget());
if (!was_attached_) {
// Attach the panel while dragging placing it in front of other panels.
- wm::GetWindowState(GetTarget())->set_continue_drag_after_reparent(true);
- wm::GetWindowState(GetTarget())->set_panel_attached(true);
+ window_state_->set_continue_drag_after_reparent(true);
+ window_state_->set_panel_attached(true);
// We use root window coordinates to ensure that during the drag the panel
// is reparented to a container in the root window that has that window.
aura::Window* target = GetTarget();
@@ -208,10 +197,8 @@ void PanelWindowResizer::StartedDragging() {
void PanelWindowResizer::FinishDragging() {
if (!did_move_or_resize_)
return;
- if (details_.bounds_change & WindowResizer::kBoundsChange_Resizes)
- should_attach_ = was_attached_;
- if (wm::GetWindowState(GetTarget())->panel_attached() != should_attach_) {
- wm::GetWindowState(GetTarget())->set_panel_attached(should_attach_);
+ if (window_state_->panel_attached() != details().should_attach_to_shelf) {
+ window_state_->set_panel_attached(details().should_attach_to_shelf);
// We use last known location to ensure that after the drag the panel
// is reparented to a container in the root window that has that location.
aura::Window* target = GetTarget();
diff --git a/ash/wm/panels/panel_window_resizer.h b/ash/wm/panels/panel_window_resizer.h
index 9a1b69c..4f087b8 100644
--- a/ash/wm/panels/panel_window_resizer.h
+++ b/ash/wm/panels/panel_window_resizer.h
@@ -27,17 +27,12 @@ class ASH_EXPORT PanelWindowResizer : public WindowResizer {
// returned object. The ownership of |next_window_resizer| is taken by the
// returned object. Returns NULL if not resizable.
static PanelWindowResizer* Create(WindowResizer* next_window_resizer,
- aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source);
+ wm::WindowState* window_state);
// WindowResizer:
virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE;
virtual void CompleteDrag() OVERRIDE;
virtual void RevertDrag() OVERRIDE;
- virtual aura::Window* GetTarget() OVERRIDE;
- virtual const gfx::Point& GetInitialLocation() const OVERRIDE;
private:
// Creates PanelWindowResizer that adds the ability to attach / detach panel
@@ -45,7 +40,7 @@ class ASH_EXPORT PanelWindowResizer : public WindowResizer {
// |next_window_resizer|. This object takes ownership of
// |next_window_resizer|.
PanelWindowResizer(WindowResizer* next_window_resizer,
- const Details& details);
+ wm::WindowState* window_state);
// Checks if the provided window bounds should attach to the launcher. If true
// the offset gives the necessary adjustment to snap to the launcher.
@@ -62,8 +57,6 @@ class ASH_EXPORT PanelWindowResizer : public WindowResizer {
// Updates the dragged panel's index in the launcher.
void UpdateLauncherPosition();
- const Details details_;
-
// Last pointer location in screen coordinates.
gfx::Point last_location_;
@@ -81,9 +74,6 @@ class ASH_EXPORT PanelWindowResizer : public WindowResizer {
// True if the window started attached to the launcher.
const bool was_attached_;
- // True if the window should attach to the launcher after releasing.
- bool should_attach_;
-
base::WeakPtrFactory<PanelWindowResizer> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PanelWindowResizer);
diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc
index 372ce48..2631cc6 100644
--- a/ash/wm/window_resizer.cc
+++ b/ash/wm/window_resizer.cc
@@ -25,60 +25,6 @@ namespace ash {
namespace {
-int GetPositionChangeDirectionForWindowComponent(int window_component) {
- int pos_change_direction = WindowResizer::kBoundsChangeDirection_None;
- switch (window_component) {
- case HTTOPLEFT:
- case HTBOTTOMRIGHT:
- case HTGROWBOX:
- case HTCAPTION:
- pos_change_direction |=
- WindowResizer::kBoundsChangeDirection_Horizontal |
- WindowResizer::kBoundsChangeDirection_Vertical;
- break;
- case HTTOP:
- case HTTOPRIGHT:
- case HTBOTTOM:
- pos_change_direction |= WindowResizer::kBoundsChangeDirection_Vertical;
- break;
- case HTBOTTOMLEFT:
- case HTRIGHT:
- case HTLEFT:
- pos_change_direction |= WindowResizer::kBoundsChangeDirection_Horizontal;
- break;
- default:
- break;
- }
- return pos_change_direction;
-}
-
-int GetSizeChangeDirectionForWindowComponent(int window_component) {
- int size_change_direction = WindowResizer::kBoundsChangeDirection_None;
- switch (window_component) {
- case HTTOPLEFT:
- case HTTOPRIGHT:
- case HTBOTTOMLEFT:
- case HTBOTTOMRIGHT:
- case HTGROWBOX:
- case HTCAPTION:
- size_change_direction |=
- WindowResizer::kBoundsChangeDirection_Horizontal |
- WindowResizer::kBoundsChangeDirection_Vertical;
- break;
- case HTTOP:
- case HTBOTTOM:
- size_change_direction |= WindowResizer::kBoundsChangeDirection_Vertical;
- break;
- case HTRIGHT:
- case HTLEFT:
- size_change_direction |= WindowResizer::kBoundsChangeDirection_Horizontal;
- break;
- default:
- break;
- }
- return size_change_direction;
-}
-
// Returns true for resize components along the right edge, where a drag in
// positive x will make the window larger.
bool IsRightEdge(int window_component) {
@@ -104,45 +50,12 @@ const int WindowResizer::kBoundsChangeDirection_Horizontal = 1;
// static
const int WindowResizer::kBoundsChangeDirection_Vertical = 2;
-WindowResizer::Details::Details()
- : window(NULL),
- window_state(NULL),
- window_component(HTNOWHERE),
- bounds_change(0),
- position_change_direction(0),
- size_change_direction(0),
- is_resizable(false),
- source(aura::client::WINDOW_MOVE_SOURCE_MOUSE) {
-}
-
-WindowResizer::Details::Details(aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source)
- : window(window),
- window_state(wm::GetWindowState(window)),
- initial_bounds_in_parent(window->bounds()),
- restore_bounds(gfx::Rect()),
- initial_location_in_parent(location),
- initial_opacity(window->layer()->opacity()),
- window_component(window_component),
- bounds_change(GetBoundsChangeForWindowComponent(window_component)),
- position_change_direction(
- GetPositionChangeDirectionForWindowComponent(window_component)),
- size_change_direction(
- GetSizeChangeDirectionForWindowComponent(window_component)),
- is_resizable(bounds_change != kBoundsChangeDirection_None),
- source(source) {
- if (window_state->IsNormalShowState() &&
- window_state->HasRestoreBounds() &&
- window_component == HTCAPTION)
- restore_bounds = window_state->GetRestoreBoundsInScreen();
+WindowResizer::WindowResizer() {
}
-WindowResizer::Details::~Details() {
-}
-
-WindowResizer::WindowResizer() {
+WindowResizer::WindowResizer(wm::WindowState* window_state)
+ : window_state_(window_state) {
+ DCHECK(window_state_->drag_details());
}
WindowResizer::~WindowResizer() {
@@ -175,44 +88,71 @@ int WindowResizer::GetBoundsChangeForWindowComponent(int component) {
return bounds_change;
}
-// static
+//static
+int WindowResizer::GetPositionChangeDirectionForWindowComponent(
+ int window_component) {
+ int pos_change_direction = WindowResizer::kBoundsChangeDirection_None;
+ switch (window_component) {
+ case HTTOPLEFT:
+ case HTBOTTOMRIGHT:
+ case HTGROWBOX:
+ case HTCAPTION:
+ pos_change_direction |=
+ WindowResizer::kBoundsChangeDirection_Horizontal |
+ WindowResizer::kBoundsChangeDirection_Vertical;
+ break;
+ case HTTOP:
+ case HTTOPRIGHT:
+ case HTBOTTOM:
+ pos_change_direction |= WindowResizer::kBoundsChangeDirection_Vertical;
+ break;
+ case HTBOTTOMLEFT:
+ case HTRIGHT:
+ case HTLEFT:
+ pos_change_direction |= WindowResizer::kBoundsChangeDirection_Horizontal;
+ break;
+ default:
+ break;
+ }
+ return pos_change_direction;
+}
+
gfx::Rect WindowResizer::CalculateBoundsForDrag(
- const Details& details,
const gfx::Point& passed_location) {
- if (!details.is_resizable)
- return details.initial_bounds_in_parent;
+ if (!details().is_resizable)
+ return details().initial_bounds_in_parent;
gfx::Point location = passed_location;
- int delta_x = location.x() - details.initial_location_in_parent.x();
- int delta_y = location.y() - details.initial_location_in_parent.y();
+ int delta_x = location.x() - details().initial_location_in_parent.x();
+ int delta_y = location.y() - details().initial_location_in_parent.y();
- AdjustDeltaForTouchResize(details, &delta_x, &delta_y);
+ AdjustDeltaForTouchResize(&delta_x, &delta_y);
// The minimize size constraint may limit how much we change the window
// position. For example, dragging the left edge to the right should stop
// repositioning the window when the minimize size is reached.
- gfx::Size size = GetSizeForDrag(details, &delta_x, &delta_y);
- gfx::Point origin = GetOriginForDrag(details, delta_x, delta_y);
+ gfx::Size size = GetSizeForDrag(&delta_x, &delta_y);
+ gfx::Point origin = GetOriginForDrag(delta_x, delta_y);
gfx::Rect new_bounds(origin, size);
// Sizing has to keep the result on the screen. Note that this correction
// has to come first since it might have an impact on the origin as well as
// on the size.
- if (details.bounds_change & kBoundsChange_Resizes) {
+ if (details().bounds_change & kBoundsChange_Resizes) {
gfx::Rect work_area =
- Shell::GetScreen()->GetDisplayNearestWindow(details.window).work_area();
+ Shell::GetScreen()->GetDisplayNearestWindow(GetTarget()).work_area();
aura::Window* dock_container = Shell::GetContainer(
- details.window->GetRootWindow(),
+ GetTarget()->GetRootWindow(),
internal::kShellWindowId_DockedContainer);
internal::DockedWindowLayoutManager* dock_layout =
static_cast<internal::DockedWindowLayoutManager*>(
dock_container->layout_manager());
work_area.Union(dock_layout->docked_bounds());
- work_area = ScreenAsh::ConvertRectFromScreen(details.window->parent(),
+ work_area = ScreenAsh::ConvertRectFromScreen(GetTarget()->parent(),
work_area);
- if (details.size_change_direction & kBoundsChangeDirection_Horizontal) {
- if (IsRightEdge(details.window_component) &&
+ if (details().size_change_direction & kBoundsChangeDirection_Horizontal) {
+ if (IsRightEdge(details().window_component) &&
new_bounds.right() < work_area.x() + kMinimumOnScreenArea) {
int delta = work_area.x() + kMinimumOnScreenArea - new_bounds.right();
new_bounds.set_width(new_bounds.width() + delta);
@@ -223,16 +163,16 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag(
new_bounds.set_width(width);
}
}
- if (details.size_change_direction & kBoundsChangeDirection_Vertical) {
- if (!IsBottomEdge(details.window_component) &&
+ if (details().size_change_direction & kBoundsChangeDirection_Vertical) {
+ if (!IsBottomEdge(details().window_component) &&
new_bounds.y() > work_area.bottom() - kMinimumOnScreenArea) {
int height = new_bounds.bottom() - work_area.bottom() +
kMinimumOnScreenArea;
new_bounds.set_y(work_area.bottom() - kMinimumOnScreenArea);
new_bounds.set_height(height);
- } else if (details.window_component == HTBOTTOM ||
- details.window_component == HTBOTTOMRIGHT ||
- details.window_component == HTBOTTOMLEFT) {
+ } else if (details().window_component == HTBOTTOM ||
+ details().window_component == HTBOTTOMRIGHT ||
+ details().window_component == HTBOTTOMLEFT) {
// Update bottom edge to stay in the work area when we are resizing
// by dragging the bottom edge or corners.
if (new_bounds.bottom() > work_area.bottom())
@@ -240,7 +180,7 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag(
new_bounds.bottom() - work_area.bottom());
}
}
- if (details.bounds_change & kBoundsChange_Repositions &&
+ if (details().bounds_change & kBoundsChange_Repositions &&
new_bounds.y() < 0) {
int delta = new_bounds.y();
new_bounds.set_y(0);
@@ -248,21 +188,22 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag(
}
}
- if (details.bounds_change & kBoundsChange_Repositions) {
+ if (details().bounds_change & kBoundsChange_Repositions) {
// When we might want to reposition a window which is also restored to its
// previous size, to keep the cursor within the dragged window.
- if (!details.restore_bounds.IsEmpty()) {
+ if (!details().restore_bounds.IsEmpty()) {
// However - it is not desirable to change the origin if the window would
// be still hit by the cursor.
- if (details.initial_location_in_parent.x() >
- details.initial_bounds_in_parent.x() + details.restore_bounds.width())
- new_bounds.set_x(location.x() - details.restore_bounds.width() / 2);
+ if (details().initial_location_in_parent.x() >
+ details().initial_bounds_in_parent.x() +
+ details().restore_bounds.width())
+ new_bounds.set_x(location.x() - details().restore_bounds.width() / 2);
}
// Make sure that |new_bounds| doesn't leave any of the displays. Note that
// the |work_area| above isn't good for this check since it is the work area
// for the current display but the window can move to a different one.
- aura::Window* parent = details.window->parent();
+ aura::Window* parent = GetTarget()->parent();
gfx::Point passed_location_in_screen(passed_location);
wm::ConvertPointToScreen(parent, &passed_location_in_screen);
gfx::Rect near_passed_location(passed_location_in_screen, gfx::Size());
@@ -304,42 +245,36 @@ bool WindowResizer::IsBottomEdge(int window_component) {
window_component == HTGROWBOX;
}
-// static
-void WindowResizer::AdjustDeltaForTouchResize(const Details& details,
- int* delta_x,
- int* delta_y) {
- if (details.source != aura::client::WINDOW_MOVE_SOURCE_TOUCH ||
- !(details.bounds_change & kBoundsChange_Resizes))
+void WindowResizer::AdjustDeltaForTouchResize(int* delta_x, int* delta_y) {
+ if (details().source != aura::client::WINDOW_MOVE_SOURCE_TOUCH ||
+ !(details().bounds_change & kBoundsChange_Resizes))
return;
- if (details.size_change_direction & kBoundsChangeDirection_Horizontal) {
- if (IsRightEdge(details.window_component)) {
- *delta_x += details.initial_location_in_parent.x() -
- details.initial_bounds_in_parent.right();
+ if (details().size_change_direction & kBoundsChangeDirection_Horizontal) {
+ if (IsRightEdge(details().window_component)) {
+ *delta_x += details().initial_location_in_parent.x() -
+ details().initial_bounds_in_parent.right();
} else {
- *delta_x += details.initial_location_in_parent.x() -
- details.initial_bounds_in_parent.x();
+ *delta_x += details().initial_location_in_parent.x() -
+ details().initial_bounds_in_parent.x();
}
}
- if (details.size_change_direction & kBoundsChangeDirection_Vertical) {
- if (IsBottomEdge(details.window_component)) {
- *delta_y += details.initial_location_in_parent.y() -
- details.initial_bounds_in_parent.bottom();
+ if (details().size_change_direction & kBoundsChangeDirection_Vertical) {
+ if (IsBottomEdge(details().window_component)) {
+ *delta_y += details().initial_location_in_parent.y() -
+ details().initial_bounds_in_parent.bottom();
} else {
- *delta_y += details.initial_location_in_parent.y() -
- details.initial_bounds_in_parent.y();
+ *delta_y += details().initial_location_in_parent.y() -
+ details().initial_bounds_in_parent.y();
}
}
}
-// static
-gfx::Point WindowResizer::GetOriginForDrag(const Details& details,
- int delta_x,
- int delta_y) {
- gfx::Point origin = details.initial_bounds_in_parent.origin();
- if (details.bounds_change & kBoundsChange_Repositions) {
- int pos_change_direction =
- GetPositionChangeDirectionForWindowComponent(details.window_component);
+gfx::Point WindowResizer::GetOriginForDrag(int delta_x, int delta_y) {
+ gfx::Point origin = details().initial_bounds_in_parent.origin();
+ if (details().bounds_change & kBoundsChange_Repositions) {
+ int pos_change_direction = GetPositionChangeDirectionForWindowComponent(
+ details().window_component);
if (pos_change_direction & kBoundsChangeDirection_Horizontal)
origin.Offset(delta_x, 0);
if (pos_change_direction & kBoundsChangeDirection_Vertical)
@@ -348,85 +283,76 @@ gfx::Point WindowResizer::GetOriginForDrag(const Details& details,
return origin;
}
-// static
-gfx::Size WindowResizer::GetSizeForDrag(const Details& details,
- int* delta_x,
- int* delta_y) {
- gfx::Size size = details.initial_bounds_in_parent.size();
- if (details.bounds_change & kBoundsChange_Resizes) {
- gfx::Size min_size = details.window->delegate()->GetMinimumSize();
- size.SetSize(GetWidthForDrag(details, min_size.width(), delta_x),
- GetHeightForDrag(details, min_size.height(), delta_y));
- } else if (!details.restore_bounds.IsEmpty()) {
- size = details.restore_bounds.size();
+gfx::Size WindowResizer::GetSizeForDrag(int* delta_x, int* delta_y) {
+ gfx::Size size = details().initial_bounds_in_parent.size();
+ if (details().bounds_change & kBoundsChange_Resizes) {
+ gfx::Size min_size = GetTarget()->delegate()->GetMinimumSize();
+ size.SetSize(GetWidthForDrag(min_size.width(), delta_x),
+ GetHeightForDrag(min_size.height(), delta_y));
+ } else if (!details().restore_bounds.IsEmpty()) {
+ size = details().restore_bounds.size();
}
return size;
}
-// static
-int WindowResizer::GetWidthForDrag(const Details& details,
- int min_width,
- int* delta_x) {
- int width = details.initial_bounds_in_parent.width();
- if (details.size_change_direction & kBoundsChangeDirection_Horizontal) {
+int WindowResizer::GetWidthForDrag(int min_width, int* delta_x) {
+ int width = details().initial_bounds_in_parent.width();
+ if (details().size_change_direction & kBoundsChangeDirection_Horizontal) {
// Along the right edge, positive delta_x increases the window size.
- int x_multiplier = IsRightEdge(details.window_component) ? 1 : -1;
+ int x_multiplier = IsRightEdge(details().window_component) ? 1 : -1;
width += x_multiplier * (*delta_x);
// Ensure we don't shrink past the minimum width and clamp delta_x
// for the window origin computation.
if (width < min_width) {
width = min_width;
- *delta_x = -x_multiplier * (details.initial_bounds_in_parent.width() -
+ *delta_x = -x_multiplier * (details().initial_bounds_in_parent.width() -
min_width);
}
// And don't let the window go bigger than the display.
int max_width = Shell::GetScreen()->GetDisplayNearestWindow(
- details.window).bounds().width();
- gfx::Size max_size = details.window->delegate()->GetMaximumSize();
+ GetTarget()).bounds().width();
+ gfx::Size max_size = GetTarget()->delegate()->GetMaximumSize();
if (max_size.width() != 0)
max_width = std::min(max_width, max_size.width());
if (width > max_width) {
width = max_width;
- *delta_x = -x_multiplier * (details.initial_bounds_in_parent.width() -
+ *delta_x = -x_multiplier * (details().initial_bounds_in_parent.width() -
max_width);
}
}
return width;
}
-// static
-int WindowResizer::GetHeightForDrag(const Details& details,
- int min_height,
- int* delta_y) {
- int height = details.initial_bounds_in_parent.height();
- if (details.size_change_direction & kBoundsChangeDirection_Vertical) {
+int WindowResizer::GetHeightForDrag(int min_height, int* delta_y) {
+ int height = details().initial_bounds_in_parent.height();
+ if (details().size_change_direction & kBoundsChangeDirection_Vertical) {
// Along the bottom edge, positive delta_y increases the window size.
- int y_multiplier = IsBottomEdge(details.window_component) ? 1 : -1;
+ int y_multiplier = IsBottomEdge(details().window_component) ? 1 : -1;
height += y_multiplier * (*delta_y);
// Ensure we don't shrink past the minimum height and clamp delta_y
// for the window origin computation.
if (height < min_height) {
height = min_height;
- *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() -
+ *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() -
min_height);
}
// And don't let the window go bigger than the display.
int max_height = Shell::GetScreen()->GetDisplayNearestWindow(
- details.window).bounds().height();
- gfx::Size max_size = details.window->delegate()->GetMaximumSize();
+ GetTarget()).bounds().height();
+ gfx::Size max_size = GetTarget()->delegate()->GetMaximumSize();
if (max_size.height() != 0)
max_height = std::min(max_height, max_size.height());
if (height > max_height) {
height = max_height;
- *delta_y = -y_multiplier * (details.initial_bounds_in_parent.height() -
+ *delta_y = -y_multiplier * (details().initial_bounds_in_parent.height() -
max_height);
}
}
return height;
}
-} // namespace aura
+} // namespace ash
diff --git a/ash/wm/window_resizer.h b/ash/wm/window_resizer.h
index 09f8ea2..278d199 100644
--- a/ash/wm/window_resizer.h
+++ b/ash/wm/window_resizer.h
@@ -6,6 +6,8 @@
#define ASH_WM_WINDOW_RESIZER_H_
#include "ash/ash_export.h"
+#include "ash/wm/drag_details.h"
+#include "ash/wm/window_state.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/client/window_move_client.h"
@@ -16,9 +18,6 @@ class Window;
}
namespace ash {
-namespace wm {
-class WindowState;
-}
// WindowResizer is used by ToplevelWindowEventFilter to handle dragging, moving
// or resizing a window. All coordinates passed to this are in the parent
@@ -36,11 +35,15 @@ class ASH_EXPORT WindowResizer {
static const int kBoundsChangeDirection_Vertical;
WindowResizer();
+ WindowResizer(wm::WindowState* window_state);
virtual ~WindowResizer();
// Returns a bitmask of the kBoundsChange_ values.
static int GetBoundsChangeForWindowComponent(int component);
+ // Returns a bitmask of the kBoundsChange_ values.
+ static int GetPositionChangeDirectionForWindowComponent(int window_component);
+
// Invoked to drag/move/resize the window. |location| is in the coordinates
// of the window supplied to the constructor. |event_flags| is the event
// flags from the event.
@@ -53,95 +56,43 @@ class ASH_EXPORT WindowResizer {
virtual void RevertDrag() = 0;
// Returns the target window the resizer was created for.
- virtual aura::Window* GetTarget() = 0;
-
- // See comment for |Details::initial_location_in_parent|.
- virtual const gfx::Point& GetInitialLocation() const = 0;
-
- protected:
- struct Details {
- Details();
- Details(aura::Window* window,
- const gfx::Point& location,
- int window_component,
- aura::client::WindowMoveSource source);
- ~Details();
-
- // The window we're resizing.
- // TODO(oshima): replace this with accessor method to
- // |window_state->window()|.
- aura::Window* window;
-
- // The ash window state for the |window| above.
- wm::WindowState* window_state;
-
- // Initial bounds of the window in parent coordinates.
- gfx::Rect initial_bounds_in_parent;
-
- // Restore bounds (in screen coordinates) of the window before the drag
- // started. Only set if the window is normal and is being dragged.
- gfx::Rect restore_bounds;
+ aura::Window* GetTarget() const {
+ return window_state_ ? window_state_->window() : NULL;
+ }
- // Location passed to the constructor, in |window->parent()|'s coordinates.
- gfx::Point initial_location_in_parent;
+ // See comment for |DragDetails::initial_location_in_parent|.
+ const gfx::Point& GetInitialLocation() const {
+ return window_state_->drag_details()->initial_location_in_parent;
+ }
- // Initial opacity of the window.
- float initial_opacity;
+ // Drag parameters established when drag starts.
+ const DragDetails& details() const { return *window_state_->drag_details(); }
- // The component the user pressed on.
- int window_component;
-
- // Bitmask of the |kBoundsChange_| constants.
- int bounds_change;
-
- // Bitmask of the |kBoundsChangeDirection_| constants.
- int position_change_direction;
-
- // Bitmask of the |kBoundsChangeDirection_| constants.
- int size_change_direction;
-
- // Will the drag actually modify the window?
- bool is_resizable;
-
- // Source of the event initiating the drag.
- aura::client::WindowMoveSource source;
- };
-
- static gfx::Rect CalculateBoundsForDrag(const Details& details,
- const gfx::Point& location);
-
- static gfx::Rect AdjustBoundsToGrid(const gfx::Rect& bounds,
- int grid_size);
+ protected:
+ gfx::Rect CalculateBoundsForDrag(const gfx::Point& location);
static bool IsBottomEdge(int component);
+ // WindowState of the drag target.
+ wm::WindowState* window_state_;
+
private:
// In case of touch resizing, adjusts deltas so that the border is positioned
// just under the touch point.
- static void AdjustDeltaForTouchResize(const Details& details,
- int* delta_x,
- int* delta_y);
+ void AdjustDeltaForTouchResize(int* delta_x, int* delta_y);
// Returns the new origin of the window. The arguments are the difference
// between the current location and the initial location.
- static gfx::Point GetOriginForDrag(const Details& details,
- int delta_x,
- int delta_y);
+ gfx::Point GetOriginForDrag(int delta_x, int delta_y);
// Returns the size of the window for the drag.
- static gfx::Size GetSizeForDrag(const Details& details,
- int* delta_x,
- int* delta_y);
+ gfx::Size GetSizeForDrag(int* delta_x, int* delta_y);
// Returns the width of the window.
- static int GetWidthForDrag(const Details& details,
- int min_width,
- int* delta_x);
+ int GetWidthForDrag(int min_width, int* delta_x);
// Returns the height of the drag.
- static int GetHeightForDrag(const Details& details,
- int min_height,
- int* delta_y);
+ int GetHeightForDrag(int min_height, int* delta_y);
};
// Creates a WindowResizer for |window|. This can return a scoped_ptr
diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc
index 0c86e28..185372e 100644
--- a/ash/wm/window_state.cc
+++ b/ash/wm/window_state.cc
@@ -33,7 +33,6 @@ WindowState::WindowState(aura::Window* window)
ignored_by_shelf_(false),
can_consume_system_keys_(false),
top_row_keys_are_function_keys_(false),
- window_resizer_(NULL),
always_restores_to_restore_bounds_(false),
hide_shelf_when_fullscreen_(true),
animate_to_fullscreen_(true),
@@ -252,6 +251,22 @@ void WindowState::RemoveObserver(WindowStateObserver* observer) {
observer_list_.RemoveObserver(observer);
}
+bool WindowState::CreateDragDetails(aura::Window* window,
+ const gfx::Point& point_in_parent,
+ int window_component,
+ aura::client::WindowMoveSource source) {
+ scoped_ptr<DragDetails> details(new DragDetails(
+ window, point_in_parent, window_component, source));
+ if (!details->is_resizable)
+ return false;
+ drag_details_ = details.Pass();
+ return true;
+}
+
+void WindowState::DeleteDragDetails() {
+ drag_details_.reset();
+}
+
void WindowState::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
diff --git a/ash/wm/window_state.h b/ash/wm/window_state.h
index 33987d0..42a9ef6 100644
--- a/ash/wm/window_state.h
+++ b/ash/wm/window_state.h
@@ -6,6 +6,7 @@
#define ASH_WM_WINDOW_STATE_H_
#include "ash/ash_export.h"
+#include "ash/wm/drag_details.h"
#include "ash/wm/wm_types.h"
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
@@ -173,7 +174,9 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
void RemoveObserver(WindowStateObserver* observer);
// Whether the window is being dragged.
- bool is_dragged() const { return !!window_resizer_; }
+ bool is_dragged() const {
+ return drag_details_ && drag_details_->window_resizer;
+ }
// Whether or not the window's position can be managed by the
// auto management logic.
@@ -229,17 +232,27 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
top_row_keys_are_function_keys_ = value;
}
- // Returns or sets a pointer to WindowResizer when resizing is active.
- // The pointer to a WindowResizer that is returned is set when a resizer gets
- // created and cleared when it gets destroyed. WindowState does not own the
- // |window_resizer_| instance and the resizer's lifetime is controlled
- // externally. It can be used to avoid creating multiple instances of a
- // WindowResizer for the same window.
- WindowResizer* window_resizer() const {
- return window_resizer_;
- }
- void set_window_resizer_(WindowResizer* window_resizer) {
- window_resizer_ = window_resizer;
+ // Creates and takes ownership of a pointer to DragDetails when resizing is
+ // active. This should be done before a resizer gets created. Returns true
+ // if |window| is resizable based on |window_component|, false otherwise.
+ bool CreateDragDetails(aura::Window* window,
+ const gfx::Point& point_in_parent,
+ int window_component,
+ aura::client::WindowMoveSource source);
+
+ // Deletes and clears a pointer to DragDetails. This should be done when the
+ // resizer gets destroyed.
+ void DeleteDragDetails();
+
+ // Returns a pointer to DragDetails during drag operations.
+ const DragDetails* drag_details() const { return drag_details_.get(); }
+ DragDetails* drag_details() { return drag_details_.get(); }
+
+ // Returns a pointer to WindowResizer when resizing is active.
+ // It can be used to avoid creating multiple instances of a WindowResizer for
+ // the same window.
+ WindowResizer* window_resizer() {
+ return drag_details_ ? drag_details_->window_resizer : NULL;
}
// aura::WindowObserver overrides:
@@ -266,7 +279,7 @@ class ASH_EXPORT WindowState : public aura::WindowObserver {
bool ignored_by_shelf_;
bool can_consume_system_keys_;
bool top_row_keys_are_function_keys_;
- WindowResizer* window_resizer_;
+ scoped_ptr<DragDetails> drag_details_;
bool always_restores_to_restore_bounds_;
bool hide_shelf_when_fullscreen_;
diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc
index 573824e..6b5a006 100644
--- a/ash/wm/workspace/multi_window_resize_controller.cc
+++ b/ash/wm/workspace/multi_window_resize_controller.cc
@@ -433,12 +433,12 @@ void MultiWindowResizeController::StartResize(
windows.push_back(windows_.other_windows[i]);
}
int component = windows_.direction == LEFT_RIGHT ? HTRIGHT : HTBOTTOM;
- window_resizer_.reset(WorkspaceWindowResizer::Create(
- windows_.window1,
- location_in_parent,
- component,
- aura::client::WINDOW_MOVE_SOURCE_MOUSE,
- windows));
+ wm::WindowState* window_state = wm::GetWindowState(windows_.window1);
+ window_state->CreateDragDetails(windows_.window1,
+ location_in_parent,
+ component,
+ aura::client::WINDOW_MOVE_SOURCE_MOUSE);
+ window_resizer_.reset(WorkspaceWindowResizer::Create(window_state, windows));
}
void MultiWindowResizeController::Resize(const gfx::Point& location_in_screen,
@@ -460,6 +460,7 @@ void MultiWindowResizeController::Resize(const gfx::Point& location_in_screen,
void MultiWindowResizeController::CompleteResize() {
window_resizer_->CompleteDrag();
+ wm::GetWindowState(window_resizer_->GetTarget())->DeleteDragDetails();
window_resizer_.reset();
// Mouse may still be over resizer, if not hide.
@@ -480,6 +481,7 @@ void MultiWindowResizeController::CancelResize() {
if (!window_resizer_)
return; // Happens if window was destroyed and we nuked the WindowResizer.
window_resizer_->RevertDrag();
+ wm::GetWindowState(window_resizer_->GetTarget())->DeleteDragDetails();
window_resizer_.reset();
Hide();
}
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index eea0811..ecae294 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -67,45 +67,50 @@ scoped_ptr<WindowResizer> CreateWindowResizer(
// drag has started or stopped.
// It may be possible to refactor and eliminate chaining.
WindowResizer* window_resizer = NULL;
+
+ if (!window_state->IsNormalShowState()) {
+ if (window->parent() &&
+ (window->parent()->id() == internal::kShellWindowId_DefaultContainer ||
+ window->parent()->id() == internal::kShellWindowId_DockedContainer ||
+ window->parent()->id() == internal::kShellWindowId_PanelContainer)) {
+ // Allow dragging maximized windows only when dragged by a tab.
+ if (window_component != HTCAPTION || !window_state->is_dragged())
+ return scoped_ptr<WindowResizer>();
+ } else {
+ return scoped_ptr<WindowResizer>();
+ }
+ }
+
+ if (!window_state->CreateDragDetails(
+ window, point_in_parent, window_component, source)) {
+ return scoped_ptr<WindowResizer>();
+ }
if (window->parent() &&
(window->parent()->id() == internal::kShellWindowId_DefaultContainer ||
window->parent()->id() == internal::kShellWindowId_DockedContainer ||
window->parent()->id() == internal::kShellWindowId_PanelContainer)) {
- // Allow dragging maximized windows if it's not tracked by workspace. This
- // is set by tab dragging code.
- if (!window_state->IsNormalShowState() &&
- (window_component != HTCAPTION ||
- !window_state->is_dragged())) {
- return scoped_ptr<WindowResizer>();
- }
window_resizer = internal::WorkspaceWindowResizer::Create(
- window,
- point_in_parent,
- window_component,
- source,
+ window_state,
std::vector<aura::Window*>());
- } else if (window_state->IsNormalShowState()) {
- window_resizer = DefaultWindowResizer::Create(
- window, point_in_parent, window_component, source);
+ } else {
+ window_resizer = DefaultWindowResizer::Create(window_state);
}
if (window_resizer) {
- window_resizer = internal::DragWindowResizer::Create(
- window_resizer, window, point_in_parent, window_component, source);
- }
- if (window_resizer && window->type() == ui::wm::WINDOW_TYPE_PANEL) {
- window_resizer = PanelWindowResizer::Create(
- window_resizer, window, point_in_parent, window_component, source);
+ window_resizer = internal::DragWindowResizer::Create(window_resizer,
+ window_state);
}
+ if (window_resizer && window->type() == ui::wm::WINDOW_TYPE_PANEL)
+ window_resizer = PanelWindowResizer::Create(window_resizer, window_state);
if (switches::UseDockedWindows() &&
window_resizer && window->parent() &&
!views::corewm::GetTransientParent(window) &&
(window->parent()->id() == internal::kShellWindowId_DefaultContainer ||
window->parent()->id() == internal::kShellWindowId_DockedContainer ||
window->parent()->id() == internal::kShellWindowId_PanelContainer)) {
- window_resizer = internal::DockedWindowResizer::Create(
- window_resizer, window, point_in_parent, window_component, source);
+ window_resizer = internal::DockedWindowResizer::Create(window_resizer,
+ window_state);
}
- window_state->set_window_resizer_(window_resizer);
+ window_state->drag_details()->window_resizer = window_resizer;
return make_scoped_ptr<WindowResizer>(window_resizer);
}
@@ -355,14 +360,9 @@ WorkspaceWindowResizer::~WorkspaceWindowResizer() {
// static
WorkspaceWindowResizer* WorkspaceWindowResizer::Create(
- aura::Window* window,
- const gfx::Point& location_in_parent,
- int window_component,
- aura::client::WindowMoveSource source,
+ wm::WindowState* window_state,
const std::vector<aura::Window*>& attached_windows) {
- Details details(window, location_in_parent, window_component, source);
- return details.is_resizable ?
- new WorkspaceWindowResizer(details, attached_windows) : NULL;
+ return new WorkspaceWindowResizer(window_state, attached_windows);
}
void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
@@ -375,20 +375,20 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
} else if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshEnableStickyEdges)) {
sticky_size = kStickyDistancePixels;
- } else if ((details_.bounds_change & kBoundsChange_Resizes) &&
- details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
+ } else if ((details().bounds_change & kBoundsChange_Resizes) &&
+ details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
sticky_size = kScreenEdgeInsetForTouchResize;
} else {
sticky_size = kScreenEdgeInset;
}
- // |bounds| is in |window()->parent()|'s coordinates.
- gfx::Rect bounds = CalculateBoundsForDrag(details_, location_in_parent);
+ // |bounds| is in |GetTarget()->parent()|'s coordinates.
+ gfx::Rect bounds = CalculateBoundsForDrag(location_in_parent);
if (window_state()->IsNormalShowState())
AdjustBoundsForMainWindow(sticky_size, &bounds);
- if (bounds != window()->bounds()) {
+ if (bounds != GetTarget()->bounds()) {
if (!did_move_or_resize_) {
- if (!details_.restore_bounds.IsEmpty())
+ if (!details().restore_bounds.IsEmpty())
window_state()->ClearRestoreBounds();
RestackWindows();
}
@@ -396,7 +396,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
}
gfx::Point location_in_screen = location_in_parent;
- wm::ConvertPointToScreen(window()->parent(), &location_in_screen);
+ wm::ConvertPointToScreen(GetTarget()->parent(), &location_in_screen);
aura::Window* root = NULL;
gfx::Display display =
@@ -409,17 +409,17 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
}
if (!attached_windows_.empty())
LayoutAttachedWindows(&bounds);
- if (bounds != window()->bounds()) {
+ if (bounds != GetTarget()->bounds()) {
// SetBounds needs to be called to update the layout which affects where the
// phantom window is drawn. Keep track if the window was destroyed during
// the drag and quit early if so.
base::WeakPtr<WorkspaceWindowResizer> resizer(
weak_ptr_factory_.GetWeakPtr());
- window()->SetBounds(bounds);
+ GetTarget()->SetBounds(bounds);
if (!resizer)
return;
}
- const bool in_original_root = !root || root == window()->GetRootWindow();
+ const bool in_original_root = !root || root == GetTarget()->GetRootWindow();
// Hide a phantom window for snapping if the cursor is in another root window.
if (in_original_root) {
UpdateSnapPhantomWindow(location_in_parent, bounds);
@@ -434,7 +434,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent,
void WorkspaceWindowResizer::CompleteDrag() {
window_state()->set_bounds_changed_by_user(true);
snap_phantom_window_controller_.reset();
- if (!did_move_or_resize_ || details_.window_component != HTCAPTION)
+ if (!did_move_or_resize_ || details().window_component != HTCAPTION)
return;
bool snapped = false;
@@ -444,17 +444,17 @@ void WorkspaceWindowResizer::CompleteDrag() {
// out of a maximized window, it's already in the normal show state when this
// is called, so it does not matter.
if (window_state()->IsNormalShowState() &&
- (window()->type() != ui::wm::WINDOW_TYPE_PANEL ||
+ (GetTarget()->type() != ui::wm::WINDOW_TYPE_PANEL ||
!window_state()->panel_attached() ||
dock_layout_->is_dragged_window_docked()) &&
(snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) {
if (!window_state()->HasRestoreBounds()) {
gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen(
- window()->parent(), details_.initial_bounds_in_parent);
+ GetTarget()->parent(), details().initial_bounds_in_parent);
window_state()->SetRestoreBoundsInScreen(
- details_.restore_bounds.IsEmpty() ?
+ details().restore_bounds.IsEmpty() ?
initial_bounds :
- details_.restore_bounds);
+ details().restore_bounds);
}
DCHECK(snap_sizer_);
if (window_state()->CanResize() &&
@@ -474,13 +474,13 @@ void WorkspaceWindowResizer::RevertDrag() {
if (!did_move_or_resize_)
return;
- window()->SetBounds(details_.initial_bounds_in_parent);
- if (!details_.restore_bounds.IsEmpty()) {
- window_state()->SetRestoreBoundsInScreen(details_.restore_bounds);
+ GetTarget()->SetBounds(details().initial_bounds_in_parent);
+ if (!details().restore_bounds.IsEmpty()) {
+ window_state()->SetRestoreBoundsInScreen(details().restore_bounds);
}
- if (details_.window_component == HTRIGHT) {
- int last_x = details_.initial_bounds_in_parent.right();
+ if (details().window_component == HTRIGHT) {
+ int last_x = details().initial_bounds_in_parent.right();
for (size_t i = 0; i < attached_windows_.size(); ++i) {
gfx::Rect bounds(attached_windows_[i]->bounds());
bounds.set_x(last_x);
@@ -489,7 +489,7 @@ void WorkspaceWindowResizer::RevertDrag() {
last_x = attached_windows_[i]->bounds().right();
}
} else {
- int last_y = details_.initial_bounds_in_parent.bottom();
+ int last_y = details().initial_bounds_in_parent.bottom();
for (size_t i = 0; i < attached_windows_.size(); ++i) {
gfx::Rect bounds(attached_windows_[i]->bounds());
bounds.set_y(last_y);
@@ -500,48 +500,39 @@ void WorkspaceWindowResizer::RevertDrag() {
}
}
-aura::Window* WorkspaceWindowResizer::GetTarget() {
- return details_.window;
-}
-
-const gfx::Point& WorkspaceWindowResizer::GetInitialLocation() const {
- return details_.initial_location_in_parent;
-}
-
WorkspaceWindowResizer::WorkspaceWindowResizer(
- const Details& details,
+ wm::WindowState* window_state,
const std::vector<aura::Window*>& attached_windows)
- : details_(details),
+ : WindowResizer(window_state),
attached_windows_(attached_windows),
did_lock_cursor_(false),
did_move_or_resize_(false),
- initial_bounds_changed_by_user_(
- details.window_state->bounds_changed_by_user()),
+ initial_bounds_changed_by_user_(window_state_->bounds_changed_by_user()),
total_min_(0),
total_initial_size_(0),
snap_type_(SNAP_NONE),
num_mouse_moves_since_bounds_change_(0),
magnetism_window_(NULL),
weak_ptr_factory_(this) {
- DCHECK(details_.is_resizable);
+ DCHECK(details().is_resizable);
// A mousemove should still show the cursor even if the window is
// being moved or resized with touch, so do not lock the cursor.
- if (details.source != aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
+ if (details().source != aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
Shell* shell = Shell::GetInstance();
shell->cursor_manager()->LockCursor();
did_lock_cursor_ = true;
}
aura::Window* dock_container = Shell::GetContainer(
- window()->GetRootWindow(), kShellWindowId_DockedContainer);
+ GetTarget()->GetRootWindow(), kShellWindowId_DockedContainer);
dock_layout_ = static_cast<DockedWindowLayoutManager*>(
dock_container->layout_manager());
// Only support attaching to the right/bottom.
DCHECK(attached_windows_.empty() ||
- (details.window_component == HTRIGHT ||
- details.window_component == HTBOTTOM));
+ (details().window_component == HTRIGHT ||
+ details().window_component == HTBOTTOM));
// TODO: figure out how to deal with window going off the edge.
@@ -573,8 +564,8 @@ gfx::Rect WorkspaceWindowResizer::GetFinalBounds(
void WorkspaceWindowResizer::LayoutAttachedWindows(
gfx::Rect* bounds) {
- gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window()));
- int initial_size = PrimaryAxisSize(details_.initial_bounds_in_parent.size());
+ gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(GetTarget()));
+ int initial_size = PrimaryAxisSize(details().initial_bounds_in_parent.size());
int current_size = PrimaryAxisSize(bounds->size());
int start = PrimaryAxisCoordinate(bounds->right(), bounds->bottom());
int end = PrimaryAxisCoordinate(work_area.right(), work_area.bottom());
@@ -594,7 +585,7 @@ void WorkspaceWindowResizer::LayoutAttachedWindows(
// attached windows can grow without exceeding their max size constraints.
// Adding the pixels back to the main window effectively prevents the main
// window from resizing too far.
- if (details_.window_component == HTRIGHT)
+ if (details().window_component == HTRIGHT)
bounds->set_width(bounds->width() + leftovers);
else
bounds->set_height(bounds->height() + leftovers);
@@ -603,7 +594,7 @@ void WorkspaceWindowResizer::LayoutAttachedWindows(
int last = PrimaryAxisCoordinate(bounds->right(), bounds->bottom());
for (size_t i = 0; i < attached_windows_.size(); ++i) {
gfx::Rect attached_bounds(attached_windows_[i]->bounds());
- if (details_.window_component == HTRIGHT) {
+ if (details().window_component == HTRIGHT) {
attached_bounds.set_x(last);
attached_bounds.set_width(sizes[i]);
} else {
@@ -713,23 +704,24 @@ void WorkspaceWindowResizer::CreateBucketsForAttached(
void WorkspaceWindowResizer::MagneticallySnapToOtherWindows(gfx::Rect* bounds) {
if (UpdateMagnetismWindow(*bounds, kAllMagnetismEdges)) {
gfx::Point point = OriginForMagneticAttach(
- ScreenAsh::ConvertRectToScreen(window()->parent(), *bounds),
+ ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), *bounds),
magnetism_window_->GetBoundsInScreen(),
magnetism_edge_);
- aura::client::GetScreenPositionClient(window()->GetRootWindow())->
- ConvertPointFromScreen(window()->parent(), &point);
+ aura::client::GetScreenPositionClient(GetTarget()->GetRootWindow())->
+ ConvertPointFromScreen(GetTarget()->parent(), &point);
bounds->set_origin(point);
}
}
void WorkspaceWindowResizer::MagneticallySnapResizeToOtherWindows(
gfx::Rect* bounds) {
- const uint32 edges = WindowComponentToMagneticEdge(details_.window_component);
+ const uint32 edges = WindowComponentToMagneticEdge(
+ details().window_component);
if (UpdateMagnetismWindow(*bounds, edges)) {
*bounds = ScreenAsh::ConvertRectFromScreen(
- window()->parent(),
+ GetTarget()->parent(),
BoundsForMagneticResizeAttach(
- ScreenAsh::ConvertRectToScreen(window()->parent(), *bounds),
+ ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), *bounds),
magnetism_window_->GetBoundsInScreen(),
magnetism_edge_));
}
@@ -739,7 +731,7 @@ bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds,
uint32 edges) {
// |bounds| are in coordinates of original window's parent.
gfx::Rect bounds_in_screen =
- ScreenAsh::ConvertRectToScreen(window()->parent(), bounds);
+ ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds);
MagnetismMatcher matcher(bounds_in_screen, edges);
// If we snapped to a window then check it first. That way we don't bounce
@@ -769,7 +761,7 @@ bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds,
for (aura::Window::Windows::const_reverse_iterator i = children.rbegin();
i != children.rend() && !matcher.AreEdgesObscured(); ++i) {
wm::WindowState* other_state = wm::GetWindowState(*i);
- if (other_state->window() == window() ||
+ if (other_state->window() == GetTarget() ||
!other_state->window()->IsVisible() ||
!other_state->IsNormalShowState() ||
!other_state->CanResize()) {
@@ -790,12 +782,14 @@ void WorkspaceWindowResizer::AdjustBoundsForMainWindow(
int sticky_size,
gfx::Rect* bounds) {
gfx::Point last_mouse_location_in_screen = last_mouse_location_;
- wm::ConvertPointToScreen(window()->parent(), &last_mouse_location_in_screen);
+ wm::ConvertPointToScreen(GetTarget()->parent(),
+ &last_mouse_location_in_screen);
gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(
last_mouse_location_in_screen);
gfx::Rect work_area =
- ScreenAsh::ConvertRectFromScreen(window()->parent(), display.work_area());
- if (details_.window_component == HTCAPTION) {
+ ScreenAsh::ConvertRectFromScreen(GetTarget()->parent(),
+ display.work_area());
+ if (details().window_component == HTCAPTION) {
// Adjust the bounds to the work area where the mouse cursor is located.
// Always keep kMinOnscreenHeight or the window height (whichever is less)
// on the bottom.
@@ -826,11 +820,11 @@ void WorkspaceWindowResizer::AdjustBoundsForMainWindow(
if (attached_windows_.empty())
return;
- if (details_.window_component == HTRIGHT) {
+ if (details().window_component == HTRIGHT) {
bounds->set_width(std::min(bounds->width(),
work_area.right() - total_min_ - bounds->x()));
} else {
- DCHECK_EQ(HTBOTTOM, details_.window_component);
+ DCHECK_EQ(HTBOTTOM, details().window_component);
bounds->set_height(std::min(bounds->height(),
work_area.bottom() - total_min_ - bounds->y()));
}
@@ -870,7 +864,8 @@ void WorkspaceWindowResizer::StickToWorkAreaOnResize(
const gfx::Rect& work_area,
int sticky_size,
gfx::Rect* bounds) const {
- const uint32 edges = WindowComponentToMagneticEdge(details_.window_component);
+ const uint32 edges = WindowComponentToMagneticEdge(
+ details().window_component);
const int left_edge = work_area.x();
const int right_edge = work_area.right();
const int top_edge = work_area.y();
@@ -900,7 +895,7 @@ int WorkspaceWindowResizer::PrimaryAxisSize(const gfx::Size& size) const {
}
int WorkspaceWindowResizer::PrimaryAxisCoordinate(int x, int y) const {
- switch (details_.window_component) {
+ switch (details().window_component) {
case HTRIGHT:
return x;
case HTBOTTOM:
@@ -913,7 +908,7 @@ int WorkspaceWindowResizer::PrimaryAxisCoordinate(int x, int y) const {
void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
const gfx::Rect& bounds) {
- if (!did_move_or_resize_ || details_.window_component != HTCAPTION)
+ if (!did_move_or_resize_ || details().window_component != HTCAPTION)
return;
SnapType last_type = snap_type_;
@@ -926,7 +921,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
return;
}
}
- const bool can_dock = dock_layout_->CanDockWindow(window(), snap_type_);
+ const bool can_dock = dock_layout_->CanDockWindow(GetTarget(), snap_type_);
const bool can_snap = window_state()->CanSnap();
if (!can_snap && !can_dock) {
snap_type_ = SNAP_NONE;
@@ -950,10 +945,10 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
// Windows that cannot be snapped or are less wide than kMaxDockWidth can get
// docked without going through a snapping sequence.
gfx::Rect phantom_bounds;
- if (can_snap &&
- (!can_dock ||
- window()->bounds().width() > DockedWindowLayoutManager::kMaxDockWidth))
+ if (can_snap && (!can_dock || GetTarget()->bounds().width() >
+ DockedWindowLayoutManager::kMaxDockWidth)) {
phantom_bounds = snap_sizer_->target_bounds();
+ }
const bool should_dock = can_dock &&
(phantom_bounds.IsEmpty() ||
snap_sizer_->end_of_sequence() ||
@@ -962,7 +957,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
snap_type_ = GetSnapType(location);
if (dock_layout_->is_dragged_window_docked()) {
phantom_bounds = ScreenAsh::ConvertRectFromScreen(
- window()->parent(), dock_layout_->dragged_bounds());
+ GetTarget()->parent(), dock_layout_->dragged_bounds());
}
if (phantom_bounds.IsEmpty()) {
@@ -972,10 +967,10 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location,
if (!snap_phantom_window_controller_) {
snap_phantom_window_controller_.reset(
- new PhantomWindowController(window()));
+ new PhantomWindowController(GetTarget()));
}
snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen(
- window()->parent(), phantom_bounds));
+ GetTarget()->parent(), phantom_bounds));
}
void WorkspaceWindowResizer::RestackWindows() {
@@ -985,10 +980,10 @@ void WorkspaceWindowResizer::RestackWindows() {
// window with a different parent.
typedef std::map<size_t, aura::Window*> IndexToWindowMap;
IndexToWindowMap map;
- aura::Window* parent = window()->parent();
+ aura::Window* parent = GetTarget()->parent();
const aura::Window::Windows& windows(parent->children());
- map[std::find(windows.begin(), windows.end(), window()) -
- windows.begin()] = window();
+ map[std::find(windows.begin(), windows.end(), GetTarget()) -
+ windows.begin()] = GetTarget();
for (std::vector<aura::Window*>::const_iterator i =
attached_windows_.begin(); i != attached_windows_.end(); ++i) {
if ((*i)->parent() != parent)
@@ -1013,11 +1008,11 @@ SnapType WorkspaceWindowResizer::GetSnapType(
const gfx::Point& location) const {
// TODO: this likely only wants total display area, not the area of a single
// display.
- gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window()));
- if (details_.source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
+ gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(GetTarget()));
+ if (details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) {
// Increase tolerance for touch-snapping near the screen edges. This is only
// necessary when the work area left or right edge is same as screen edge.
- gfx::Rect display_bounds(ScreenAsh::GetDisplayBoundsInParent(window()));
+ gfx::Rect display_bounds(ScreenAsh::GetDisplayBoundsInParent(GetTarget()));
int inset_left = 0;
if (area.x() == display_bounds.x())
inset_left = kScreenEdgeInsetForTouchResize;
@@ -1035,10 +1030,11 @@ SnapType WorkspaceWindowResizer::GetSnapType(
void WorkspaceWindowResizer::SetDraggedWindowDocked(bool should_dock) {
if (should_dock &&
- dock_layout_->GetAlignmentOfWindow(window()) != DOCKED_ALIGNMENT_NONE) {
+ dock_layout_->GetAlignmentOfWindow(GetTarget()) !=
+ DOCKED_ALIGNMENT_NONE) {
if (!dock_layout_->is_dragged_window_docked()) {
window_state()->set_bounds_changed_by_user(false);
- dock_layout_->DockDraggedWindow(window());
+ dock_layout_->DockDraggedWindow(GetTarget());
}
} else {
if (dock_layout_->is_dragged_window_docked()) {
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index c0b654e..90ce846 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -55,10 +55,7 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
virtual ~WorkspaceWindowResizer();
static WorkspaceWindowResizer* Create(
- aura::Window* window,
- const gfx::Point& location_in_parent,
- int window_component,
- aura::client::WindowMoveSource source,
+ wm::WindowState* window_state,
const std::vector<aura::Window*>& attached_windows);
// WindowResizer:
@@ -66,11 +63,9 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
int event_flags) OVERRIDE;
virtual void CompleteDrag() OVERRIDE;
virtual void RevertDrag() OVERRIDE;
- virtual aura::Window* GetTarget() OVERRIDE;
- virtual const gfx::Point& GetInitialLocation() const OVERRIDE;
private:
- WorkspaceWindowResizer(const Details& details,
+ WorkspaceWindowResizer(wm::WindowState* window_state,
const std::vector<aura::Window*>& attached_windows);
private:
@@ -163,11 +158,7 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
// Undocks the window if |should_dock| is false.
void SetDraggedWindowDocked(bool should_dock);
- aura::Window* window() const { return details_.window; }
-
- wm::WindowState* window_state() { return details_.window_state; }
-
- const Details details_;
+ wm::WindowState* window_state() { return window_state_; }
const std::vector<aura::Window*> attached_windows_;
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index ae469d4..afcb0b1 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -182,6 +182,17 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
workspace_resizer_ = WorkspaceWindowResizer::instance_;
return resizer;
}
+ WorkspaceWindowResizer* CreateWorkspaceResizerForTest(
+ aura::Window* window,
+ const gfx::Point& point_in_parent,
+ int window_component,
+ aura::client::WindowMoveSource source,
+ const std::vector<aura::Window*>& attached_windows) {
+ wm::WindowState* window_state = wm::GetWindowState(window);
+ window_state->CreateDragDetails(
+ window, point_in_parent, window_component, source);
+ return WorkspaceWindowResizer::Create(window_state, attached_windows);
+ }
PhantomWindowController* snap_phantom_window_controller() const {
return workspace_resizer_->snap_phantom_window_controller_.get();
@@ -265,7 +276,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -299,7 +310,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -337,7 +348,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
windows.push_back(window3_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -378,7 +389,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
windows.push_back(window3_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -408,7 +419,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTBOTTOM,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -442,7 +453,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTBOTTOM,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -492,7 +503,7 @@ TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
windows.push_back(window3_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTBOTTOM,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -533,7 +544,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
windows.push_back(window3_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTBOTTOM,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -570,7 +581,7 @@ TEST_F(WorkspaceWindowResizerTest, MouseMoveWithTouchDrag) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_TOUCH, windows));
ASSERT_TRUE(resizer.get());
@@ -726,7 +737,7 @@ TEST_F(WorkspaceWindowResizerTest, RestackAttached) {
{
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -740,7 +751,7 @@ TEST_F(WorkspaceWindowResizerTest, RestackAttached) {
{
std::vector<aura::Window*> windows;
windows.push_back(window3_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window2_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1546,7 +1557,7 @@ TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) {
windows.push_back(window2_.get());
windows.push_back(window3_.get());
windows.push_back(window4_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1578,7 +1589,7 @@ TEST_F(WorkspaceWindowResizerTest, DontExceedMaxWidth) {
windows.push_back(window2_.get());
windows.push_back(window3_.get());
windows.push_back(window4_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1607,7 +1618,7 @@ TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) {
windows.push_back(window2_.get());
windows.push_back(window3_.get());
windows.push_back(window4_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTBOTTOM,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1643,7 +1654,7 @@ TEST_F(WorkspaceWindowResizerTest, MAYBE_DontExceedMinHeight) {
windows.push_back(window2_.get());
windows.push_back(window3_.get());
windows.push_back(window4_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTBOTTOM,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1670,7 +1681,7 @@ TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) {
windows.push_back(window2_.get());
windows.push_back(window3_.get());
windows.push_back(window4_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1697,7 +1708,7 @@ TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) {
windows.push_back(window2_.get());
windows.push_back(window3_.get());
windows.push_back(window4_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1730,7 +1741,7 @@ TEST_F(WorkspaceWindowResizerTest, MAYBE_MainWindowHonoursMaxWidth) {
windows.push_back(window2_.get());
windows.push_back(window3_.get());
windows.push_back(window4_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());
@@ -1756,7 +1767,7 @@ TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) {
std::vector<aura::Window*> windows;
windows.push_back(window2_.get());
windows.push_back(window3_.get());
- scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
window_.get(), gfx::Point(), HTRIGHT,
aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
ASSERT_TRUE(resizer.get());