1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_WM_DRAG_WINDOW_RESIZER_H_
6 #define ASH_WM_DRAG_WINDOW_RESIZER_H_
8 #include "ash/wm/window_resizer.h"
9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ui/gfx/geometry/point.h"
17 class DragWindowController
;
19 // DragWindowResizer is a decorator of WindowResizer and adds the ability to
20 // drag windows across displays.
21 class ASH_EXPORT DragWindowResizer
: public WindowResizer
{
23 ~DragWindowResizer() override
;
25 // Creates a new DragWindowResizer. The caller takes ownership of the
26 // returned object. The ownership of |next_window_resizer| is taken by the
27 // returned object. Returns NULL if not resizable.
28 static DragWindowResizer
* Create(WindowResizer
* next_window_resizer
,
29 wm::WindowState
* window_state
);
32 void Drag(const gfx::Point
& location
, int event_flags
) override
;
33 void CompleteDrag() override
;
34 void RevertDrag() override
;
37 FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest
, DragWindowController
);
39 // Creates DragWindowResizer that adds the ability of dragging windows across
40 // displays to |next_window_resizer|. This object takes the ownership of
41 // |next_window_resizer|.
42 explicit DragWindowResizer(WindowResizer
* next_window_resizer
,
43 wm::WindowState
* window_state
);
45 // Updates the bounds of the phantom window for window dragging. Set true on
46 // |in_original_root| if the pointer is still in |window()->GetRootWindow()|.
47 void UpdateDragWindow(const gfx::Rect
& bounds
, bool in_original_root
);
49 // Returns true if we should allow the mouse pointer to warp.
50 bool ShouldAllowMouseWarp();
52 scoped_ptr
<WindowResizer
> next_window_resizer_
;
54 // Shows a semi-transparent image of the window being dragged.
55 ScopedVector
<DragWindowController
> drag_window_controllers_
;
57 gfx::Point last_mouse_location_
;
59 // Current instance for use by the DragWindowResizerTest.
60 static DragWindowResizer
* instance_
;
62 base::WeakPtrFactory
<DragWindowResizer
> weak_ptr_factory_
;
64 DISALLOW_COPY_AND_ASSIGN(DragWindowResizer
);
69 #endif // ASH_WM_DRAG_WINDOW_RESIZER_H_