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