OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MUS_FRAME_MOVE_EVENT_HANDLER_H_ | 5 #ifndef ASH_MUS_FRAME_MOVE_EVENT_HANDLER_H_ |
6 #define ASH_MUS_FRAME_MOVE_EVENT_HANDLER_H_ | 6 #define ASH_MUS_FRAME_MOVE_EVENT_HANDLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/common/wm/wm_toplevel_window_event_handler.h" | 10 #include "ash/common/wm/wm_toplevel_window_event_handler.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 // EventHandler attached to windows that may be dragged and/or resized. This | 33 // EventHandler attached to windows that may be dragged and/or resized. This |
34 // forwards to WmToplevelWindowEventHandler to handle the actual drag/resize. | 34 // forwards to WmToplevelWindowEventHandler to handle the actual drag/resize. |
35 class MoveEventHandler : public ui::EventHandler, public aura::WindowObserver { | 35 class MoveEventHandler : public ui::EventHandler, public aura::WindowObserver { |
36 public: | 36 public: |
37 MoveEventHandler(::mus::Window* mus_window, | 37 MoveEventHandler(::mus::Window* mus_window, |
38 ::mus::WindowManagerClient* window_manager_client, | 38 ::mus::WindowManagerClient* window_manager_client, |
39 aura::Window* aura_window); | 39 aura::Window* aura_window); |
40 ~MoveEventHandler() override; | 40 ~MoveEventHandler() override; |
41 | 41 |
| 42 // Retrieves the MoveEventHandler for an existing WmWindow. |
| 43 static MoveEventHandler* GetForWindow(WmWindow* wm_window); |
| 44 |
| 45 // Attempts to start a drag if one is not already in progress. This passes |
| 46 // the call to the underlying WmToplevelWindowEventHandler. After the drag |
| 47 // completes, |end_closure| will be called to return whether the drag was |
| 48 // successfully completed. |
| 49 void AttemptToStartDrag( |
| 50 const gfx::Point& point_in_parent, |
| 51 int window_component, |
| 52 aura::client::WindowMoveSource source, |
| 53 const base::Callback<void(bool success)>& end_closure); |
| 54 |
| 55 // Returns whether we're in a drag. |
| 56 bool IsDragInProgress(); |
| 57 |
| 58 // Reverts a manually started drag started with AttemptToStartDrag(). |
| 59 void RevertDrag(); |
| 60 |
42 private: | 61 private: |
43 // Removes observer and EventHandler installed on |root_window_|. | 62 // Removes observer and EventHandler installed on |root_window_|. |
44 void Detach(); | 63 void Detach(); |
45 | 64 |
46 // Overridden from ui::EventHandler: | 65 // Overridden from ui::EventHandler: |
47 void OnMouseEvent(ui::MouseEvent* event) override; | 66 void OnMouseEvent(ui::MouseEvent* event) override; |
48 void OnGestureEvent(ui::GestureEvent* event) override; | 67 void OnGestureEvent(ui::GestureEvent* event) override; |
49 void OnCancelMode(ui::CancelModeEvent* event) override; | 68 void OnCancelMode(ui::CancelModeEvent* event) override; |
50 | 69 |
51 // Overridden from aura::WindowObserver: | 70 // Overridden from aura::WindowObserver: |
52 void OnWindowDestroying(aura::Window* window) override; | 71 void OnWindowDestroying(aura::Window* window) override; |
53 | 72 |
54 WmWindowMus* wm_window_; | 73 WmWindowMus* wm_window_; |
55 ::mus::WindowManagerClient* window_manager_client_; | 74 ::mus::WindowManagerClient* window_manager_client_; |
56 // The root window of the aura::Window supplied to the constructor. | 75 // The root window of the aura::Window supplied to the constructor. |
57 // MoveEventHandler is added as a pre-target handler (and observer) of this. | 76 // MoveEventHandler is added as a pre-target handler (and observer) of this. |
58 aura::Window* root_window_; | 77 aura::Window* root_window_; |
59 wm::WmToplevelWindowEventHandler toplevel_window_event_handler_; | 78 wm::WmToplevelWindowEventHandler toplevel_window_event_handler_; |
60 | 79 |
61 DISALLOW_COPY_AND_ASSIGN(MoveEventHandler); | 80 DISALLOW_COPY_AND_ASSIGN(MoveEventHandler); |
62 }; | 81 }; |
63 | 82 |
64 } // namespace mus | 83 } // namespace mus |
65 } // namespace ash | 84 } // namespace ash |
66 | 85 |
67 #endif // ASH_MUS_FRAME_MOVE_EVENT_HANDLER_H_ | 86 #endif // ASH_MUS_FRAME_MOVE_EVENT_HANDLER_H_ |
OLD | NEW |