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