19d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// Use of this source code is governed by a BSD-style license that can be
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com// found in the LICENSE file.
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#ifndef ASH_WM_WORKSPACE_WINDOW_RESIZER_H_
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com#define ASH_WM_WORKSPACE_WINDOW_RESIZER_H_
79d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
89d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org#include <vector>
9ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
109d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org#include "ash/wm/window_resizer.h"
119d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org#include "ash/wm/workspace/magnetism_matcher.h"
1269cc6ad20ed03f35f9d3c8119a2c32187669a22bbsalomon@google.com#include "base/compiler_specific.h"
139d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org#include "base/gtest_prod_util.h"
14181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.com#include "base/memory/scoped_ptr.h"
15383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com#include "base/memory/weak_ptr.h"
16383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com#include "ui/aura/window_tracker.h"
17181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.com
18181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.comnamespace ash {
19181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.comclass DockedWindowLayoutManager;
20181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.comclass PhantomWindowController;
21181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.comclass TwoStepEdgeCycler;
22181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.comclass WindowSize;
23383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com
24383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.comnamespace wm {
25383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.comclass WindowState;
26383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com}
27383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com
28383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com// WindowResizer implementation for workspaces. This enforces that windows are
29383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com// not allowed to vertically move or resize outside of the work area. As windows
30383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com// are moved outside the work area they are shrunk. We remember the height of
31383963280ddd13030331765fe88d2aefa3e32130bsalomon@google.com// the window before it was moved so that if the window is again moved up we
32181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.com// attempt to restore the old height.
33181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.comclass ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
34181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.com public:
35181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.com  // When dragging an attached window this is the min size we'll make sure is
36181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.com  // visible. In the vertical direction we take the max of this and that from
37b5b3168a645802f66233234a06dd5a3764f18018bsalomon@google.com  // the delegate.
38181e9bd9484ece4132e0cc5cfcff602134e5489dbsalomon@google.com  static const int kMinOnscreenSize;
399d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
409d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Min height we'll force on screen when dragging the caption.
41c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // TODO: this should come from a property on the window.
42c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  static const int kMinOnscreenHeight;
43afec7ba75962517b17293799d3fc70d39fa7dbf2tomhudson@google.com
44c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // Snap region when dragging close to the edges. That is, as the window gets
45c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // this close to an edge of the screen it snaps to the edge.
46c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  static const int kScreenEdgeInset;
479d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
48c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // Distance in pixels that the cursor must move past an edge for a window
499d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // to move or resize beyond that edge.
509d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  static const int kStickyDistancePixels;
519d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
529d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  virtual ~WorkspaceWindowResizer();
539d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
549d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  static WorkspaceWindowResizer* Create(
552047f00e4698f83499ab91911999a65c21a951c9epoger@google.com      wm::WindowState* window_state,
5661f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com      const std::vector<aura::Window*>& attached_windows);
5761f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com
5861f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  // WindowResizer:
5961f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  virtual void Drag(const gfx::Point& location_in_parent,
6061f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com                    int event_flags) OVERRIDE;
6161f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  virtual void CompleteDrag() OVERRIDE;
6261f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  virtual void RevertDrag() OVERRIDE;
6361f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com
649d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org private:
659d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  WorkspaceWindowResizer(wm::WindowState* window_state,
669d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org                         const std::vector<aura::Window*>& attached_windows);
679d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
68c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com private:
69c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  friend class WorkspaceWindowResizerTest;
70c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com
71c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // The edge to which the window should be snapped at the end of the drag.
72c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  enum SnapType {
739d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org    SNAP_LEFT,
749d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org    SNAP_RIGHT,
759d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org    SNAP_NONE
769d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  };
779d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
789d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Lays out the attached windows. |bounds| is the bounds of the main window.
799d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  void LayoutAttachedWindows(gfx::Rect* bounds);
809d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
817744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com  // Calculates the new sizes of the attached windows, given that the main
827744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com  // window has been resized (along the primary axis) by |delta|.
839d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // |available_size| is the maximum length of the space that the attached
847744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com  // windows are allowed to occupy (ie: the distance between the right/bottom
859d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // edge of the primary window and the right/bottom of the desktop area).
869d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Populates |sizes| with the desired sizes of the attached windows, and
879d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // returns the number of pixels that couldn't be allocated to the attached
889d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // windows (due to min/max size constraints).
899d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Note the return value can be positive or negative, a negative value
909d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // indicating that that many pixels couldn't be removed from the attached
919d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // windows.
929d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  int CalculateAttachedSizes(
939d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org      int delta,
94c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com      int available_size,
95afec7ba75962517b17293799d3fc70d39fa7dbf2tomhudson@google.com      std::vector<int>* sizes) const;
96c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com
97c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // Divides |amount| evenly between |sizes|. If |amount| is negative it
98c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // indicates how many pixels |sizes| should be shrunk by.
99c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // Returns how many pixels failed to be allocated/removed from |sizes|.
100c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  int GrowFairly(int amount, std::vector<WindowSize>& sizes) const;
101c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com
1022047f00e4698f83499ab91911999a65c21a951c9epoger@google.com  // Calculate the ratio of pixels that each WindowSize in |sizes| should
103c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // receive when growing or shrinking.
1049d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  void CalculateGrowthRatios(const std::vector<WindowSize*>& sizes,
1059d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org                             std::vector<float>* out_ratios) const;
1062047f00e4698f83499ab91911999a65c21a951c9epoger@google.com
10761f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  // Adds a WindowSize to |sizes| for each attached window.
10861f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  void CreateBucketsForAttached(std::vector<WindowSize>* sizes) const;
10961f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com
11061f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  // If possible snaps the window to a neary window. Updates |bounds| if there
11161f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  // was a close enough window.
11261f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  void MagneticallySnapToOtherWindows(gfx::Rect* bounds);
11361f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com
11461f3bde1ba114e7b39b53411f4aa31ed0875d159bsalomon@google.com  // If possible snaps the resize to a neary window. Updates |bounds| if there
1159d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // was a close enough window.
1169d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  void MagneticallySnapResizeToOtherWindows(gfx::Rect* bounds);
1179d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1189d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Finds the neareset window to magentically snap to. Updates
119c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // |magnetism_window_| and |magnetism_edge_| appropriately. |edges| is a
120c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // bitmask of the MagnetismEdges to match again. Returns true if a match is
121c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // found.
122c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  bool UpdateMagnetismWindow(const gfx::Rect& bounds, uint32 edges);
123c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com
124c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // Adjusts the bounds of the window: magnetically snapping, ensuring the
1259d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // window has enough on screen... |snap_size| is the distance from an edge of
1269d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // the work area before the window is snapped. A value of 0 results in no
1279d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // snapping.
1289d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  void AdjustBoundsForMainWindow(int snap_size, gfx::Rect* bounds);
1299d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1309d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Stick the window bounds to the work area during a move.
1319d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  bool StickToWorkAreaOnMove(const gfx::Rect& work_area,
1329d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org                             int sticky_size,
1337744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com                             gfx::Rect* bounds) const;
1347744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com
1357744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com  // Stick the window bounds to the work area during a resize.
1369d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  void StickToWorkAreaOnResize(const gfx::Rect& work_area,
1379d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org                               int sticky_size,
1387744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com                               gfx::Rect* bounds) const;
1397744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com
1409d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Returns a coordinate along the primary axis. Used to share code for
1417744c205f20b5617e83d4af8f97b5771bfa8d671reed@google.com  // left/right multi window resize and top/bottom resize.
1429d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  int PrimaryAxisSize(const gfx::Size& size) const;
1439d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  int PrimaryAxisCoordinate(int x, int y) const;
1449d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1459d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Updates the bounds of the phantom window for window snapping.
1469d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  void UpdateSnapPhantomWindow(const gfx::Point& location,
1479d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org                               const gfx::Rect& bounds);
1488d033a1b125886c62906d975b5cc28a382064526bsalomon@google.com
14907f3ee10d34f09342abb93d758b5e151ff78f7a5reed@google.com  // Restacks the windows z-order position so that one of the windows is at the
150c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // top of the z-order, and the rest directly underneath it.
151afec7ba75962517b17293799d3fc70d39fa7dbf2tomhudson@google.com  void RestackWindows();
152c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com
153c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // Returns the edge to which the window should be snapped to if the user does
154c10a88825d119054a9f4e7b7af7a3f887e30ab6btomhudson@google.com  // no more dragging. SNAP_NONE is returned if the window should not be
1559d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // snapped.
1569d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  SnapType GetSnapType(const gfx::Point& location) const;
1579d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1589d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Returns true if |bounds_in_parent| are valid bounds for snapped state type
1599d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // |snapped_type|.
160129b8e3237b80b9d258a8f48e8f54c0073cafbdcsenorblanco@chromium.org  bool AreBoundsValidSnappedBounds(wm::WindowStateType snapped_type,
1619d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org                                   const gfx::Rect& bounds_in_parent) const;
1629d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1639d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Docks or undocks the dragged window.
16407f3ee10d34f09342abb93d758b5e151ff78f7a5reed@google.com  void SetDraggedWindowDocked(bool should_dock);
1659d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1669d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  wm::WindowState* window_state() { return window_state_; }
1679d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1689d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  const std::vector<aura::Window*> attached_windows_;
1699d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1709d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Returns the currently used instance for test.
1719d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  static WorkspaceWindowResizer* GetInstanceForTest();
1729d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1739d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  bool did_lock_cursor_;
1749d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1759d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Set to true once Drag() is invoked and the bounds of the window change.
1769d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  bool did_move_or_resize_;
1779d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1789d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // True if the window initially had |bounds_changed_by_user_| set in state.
1799d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  bool initial_bounds_changed_by_user_;
1809d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1819d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // The initial size of each of the windows in |attached_windows_| along the
1829d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // primary axis.
1839d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  std::vector<int> initial_size_;
1849d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1859d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Sum of the minimum sizes of the attached windows.
1869d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  int total_min_;
1879d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org
1889d18b7873ce9b44f130a41e0cbd0a3df76ab9adfsenorblanco@chromium.org  // Sum of the sizes in |initial_size_|.
18969cc6ad20ed03f35f9d3c8119a2c32187669a22bbsalomon@google.com  int total_initial_size_;
1901971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com
19169cc6ad20ed03f35f9d3c8119a2c32187669a22bbsalomon@google.com  // Gives a previews of where the the window will end up. Only used if there
19269cc6ad20ed03f35f9d3c8119a2c32187669a22bbsalomon@google.com  // is a grid and the caption is being dragged.
1935e9bf82814aa5d1503c39dd14c420d6db30055dcbsalomon@google.com  scoped_ptr<PhantomWindowController> snap_phantom_window_controller_;
1945e9bf82814aa5d1503c39dd14c420d6db30055dcbsalomon@google.com
1955e9bf82814aa5d1503c39dd14c420d6db30055dcbsalomon@google.com  // Used to determine whether the window should be snapped or docked when
1961971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com  // the user drags a window to the edge of the screen.
197dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  scoped_ptr<TwoStepEdgeCycler> edge_cycler_;
198dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
199dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // The edge to which the window should be snapped to at the end of the drag.
200dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  SnapType snap_type_;
201dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
20269cc6ad20ed03f35f9d3c8119a2c32187669a22bbsalomon@google.com  // Number of mouse moves since the last bounds change. Only used for phantom
20369cc6ad20ed03f35f9d3c8119a2c32187669a22bbsalomon@google.com  // placement to track when the mouse is moved while pushed against the edge of
20469cc6ad20ed03f35f9d3c8119a2c32187669a22bbsalomon@google.com  // the screen.
2051971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com  int num_mouse_moves_since_bounds_change_;
2061971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com
2071971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com  // The mouse location passed to Drag().
2081971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com  gfx::Point last_mouse_location_;
209dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
210dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // Window the drag has magnetically attached to.
211dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  aura::Window* magnetism_window_;
212dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
213dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // Used to verify |magnetism_window_| is still valid.
214dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  aura::WindowTracker window_tracker_;
215dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
216dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // If |magnetism_window_| is non-NULL this indicates how the two windows
217dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // should attach.
218dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  MatchedEdge magnetism_edge_;
219dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
220dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // Dock container window layout manager.
221dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  DockedWindowLayoutManager* dock_layout_;
222dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
223dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // Used to determine if this has been deleted during a drag such as when a tab
224dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  // gets dragged into another browser window.
225dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com  base::WeakPtrFactory<WorkspaceWindowResizer> weak_ptr_factory_;
22620e542e00eccaf7b9e81964692a47086e6aaf568bsalomon@google.com
22720e542e00eccaf7b9e81964692a47086e6aaf568bsalomon@google.com  DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizer);
22820e542e00eccaf7b9e81964692a47086e6aaf568bsalomon@google.com};
22920e542e00eccaf7b9e81964692a47086e6aaf568bsalomon@google.com
23020e542e00eccaf7b9e81964692a47086e6aaf568bsalomon@google.com}  // namespace ash
231dc3c78076ea279d4f6d502b3b42471e9b2bba48ebsalomon@google.com
2321971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com#endif  // ASH_WM_WORKSPACE_WINDOW_RESIZER_H_
2331971317bb43580330a9e7e9a1c09c5025fe84aacbsalomon@google.com