- add sources.
[platform/framework/web/crosswalk.git] / src / ash / wm / drag_window_resizer.h
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.
4
5 #ifndef ASH_WM_DRAG_WINDOW_RESIZER_H_
6 #define ASH_WM_DRAG_WINDOW_RESIZER_H_
7
8 #include "ash/wm/window_resizer.h"
9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h"
11 #include "base/memory/weak_ptr.h"
12 #include "ui/gfx/point.h"
13
14 namespace ash {
15 namespace internal {
16
17 class DragWindowController;
18 class TrayUser;
19
20 // DragWindowResizer is a decorator of WindowResizer and adds the ability to
21 // drag windows across displays.
22 class ASH_EXPORT DragWindowResizer : public WindowResizer {
23  public:
24   virtual ~DragWindowResizer();
25
26   // Creates a new DragWindowResizer. The caller takes ownership of the
27   // returned object. The ownership of |next_window_resizer| is taken by the
28   // returned object. Returns NULL if not resizable.
29   static DragWindowResizer* Create(WindowResizer* next_window_resizer,
30                                    aura::Window* window,
31                                    const gfx::Point& location,
32                                    int window_component,
33                                    aura::client::WindowMoveSource source);
34
35   // WindowResizer:
36   virtual void Drag(const gfx::Point& location, int event_flags) OVERRIDE;
37   virtual void CompleteDrag(int event_flags) OVERRIDE;
38   virtual void RevertDrag() OVERRIDE;
39   virtual aura::Window* GetTarget() OVERRIDE;
40   virtual const gfx::Point& GetInitialLocation() const OVERRIDE;
41
42  private:
43   FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, DragWindowController);
44
45   // Creates DragWindowResizer that adds the ability of dragging windows across
46   // displays to |next_window_resizer|. This object takes the ownership of
47   // |next_window_resizer|.
48   explicit DragWindowResizer(WindowResizer* next_window_resizer,
49                              const Details& details);
50
51   // Updates the bounds of the phantom window for window dragging. Set true on
52   // |in_original_root| if the pointer is still in |window()->GetRootWindow()|.
53   void UpdateDragWindow(const gfx::Rect& bounds, bool in_original_root);
54
55   // Returns true if we should allow the mouse pointer to warp.
56   bool ShouldAllowMouseWarp();
57
58   // Get the user drop target underneath the given |point_in_screen| or NULL.
59   TrayUser* GetTrayUserItemAtPoint(const gfx::Point& point_in_screen);
60
61   // Check if a completed drag might cause the window to change active desktops.
62   // If the call was causing a "transfer of ownership to another desktop" and it
63   // will return false indicating that no further processing is needed.
64   bool TryDraggingToNewUser();
65
66   scoped_ptr<WindowResizer> next_window_resizer_;
67
68   // Shows a semi-transparent image of the window being dragged.
69   scoped_ptr<DragWindowController> drag_window_controller_;
70
71   const Details details_;
72
73   gfx::Point last_mouse_location_;
74
75   // Current instance for use by the DragWindowResizerTest.
76   static DragWindowResizer* instance_;
77
78   base::WeakPtrFactory<DragWindowResizer> weak_ptr_factory_;
79
80   DISALLOW_COPY_AND_ASSIGN(DragWindowResizer);
81 };
82
83 }  // namespace internal
84 }  // namespace ash
85
86 #endif  // ASH_WM_DRAG_WINDOW_RESIZER_H_