| 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_MOVE_EVENT_HANDLER_H_ | 5 #ifndef ASH_MUS_MOVE_EVENT_HANDLER_H_ |
| 6 #define ASH_MUS_MOVE_EVENT_HANDLER_H_ | 6 #define ASH_MUS_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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
| 13 #include "ui/events/event_handler.h" | 13 #include "ui/events/event_handler.h" |
| 14 | 14 |
| 15 namespace aura { | 15 namespace aura { |
| 16 class Window; | 16 class Window; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 class CancelModeEvent; | 20 class CancelModeEvent; |
| 21 class Window; | 21 class Window; |
| 22 class WindowManagerClient; | 22 class WindowManagerClient; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace ash { | 25 namespace ash { |
| 26 namespace mus { | 26 namespace mus { |
| 27 | 27 |
| 28 class WmWindowMus; | 28 class WmWindowMus; |
| 29 class WorkspaceEventHandlerMus; |
| 29 | 30 |
| 30 // EventHandler attached to windows that may be dragged and/or resized. This | 31 // EventHandler attached to windows that may be dragged and/or resized. This |
| 31 // forwards to WmToplevelWindowEventHandler to handle the actual drag/resize. | 32 // forwards to WmToplevelWindowEventHandler to handle the actual drag/resize. |
| 33 // |
| 34 // TODO(sky): rename this class to better reflect that it handles redirecting |
| 35 // events in addition to drag. |
| 32 class MoveEventHandler : public ui::EventHandler, public aura::WindowObserver { | 36 class MoveEventHandler : public ui::EventHandler, public aura::WindowObserver { |
| 33 public: | 37 public: |
| 34 MoveEventHandler(ui::Window* mus_window, | 38 MoveEventHandler(ui::Window* mus_window, |
| 35 ui::WindowManagerClient* window_manager_client, | 39 ui::WindowManagerClient* window_manager_client, |
| 36 aura::Window* aura_window); | 40 aura::Window* aura_window); |
| 37 ~MoveEventHandler() override; | 41 ~MoveEventHandler() override; |
| 38 | 42 |
| 39 // Retrieves the MoveEventHandler for an existing WmWindow. | 43 // Retrieves the MoveEventHandler for an existing WmWindow. |
| 40 static MoveEventHandler* GetForWindow(WmWindow* wm_window); | 44 static MoveEventHandler* GetForWindow(WmWindow* wm_window); |
| 41 | 45 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 // Returns whether we're in a drag. | 56 // Returns whether we're in a drag. |
| 53 bool IsDragInProgress(); | 57 bool IsDragInProgress(); |
| 54 | 58 |
| 55 // Reverts a manually started drag started with AttemptToStartDrag(). | 59 // Reverts a manually started drag started with AttemptToStartDrag(). |
| 56 void RevertDrag(); | 60 void RevertDrag(); |
| 57 | 61 |
| 58 private: | 62 private: |
| 59 // Removes observer and EventHandler installed on |root_window_|. | 63 // Removes observer and EventHandler installed on |root_window_|. |
| 60 void Detach(); | 64 void Detach(); |
| 61 | 65 |
| 66 // Returns the WorkspaceEventHandlerMus, or null if the window is not in a |
| 67 // workspace. |
| 68 WorkspaceEventHandlerMus* GetWorkspaceEventHandlerMus(); |
| 69 |
| 62 // Overridden from ui::EventHandler: | 70 // Overridden from ui::EventHandler: |
| 63 void OnMouseEvent(ui::MouseEvent* event) override; | 71 void OnMouseEvent(ui::MouseEvent* event) override; |
| 64 void OnGestureEvent(ui::GestureEvent* event) override; | 72 void OnGestureEvent(ui::GestureEvent* event) override; |
| 65 void OnCancelMode(ui::CancelModeEvent* event) override; | 73 void OnCancelMode(ui::CancelModeEvent* event) override; |
| 66 | 74 |
| 67 // Overridden from aura::WindowObserver: | 75 // Overridden from aura::WindowObserver: |
| 68 void OnWindowDestroying(aura::Window* window) override; | 76 void OnWindowDestroying(aura::Window* window) override; |
| 69 | 77 |
| 70 WmWindowMus* wm_window_; | 78 WmWindowMus* wm_window_; |
| 71 ui::WindowManagerClient* window_manager_client_; | 79 ui::WindowManagerClient* window_manager_client_; |
| 72 // The root window of the aura::Window supplied to the constructor. | 80 // The root window of the aura::Window supplied to the constructor. |
| 73 // MoveEventHandler is added as a pre-target handler (and observer) of this. | 81 // MoveEventHandler is added as a pre-target handler (and observer) of this. |
| 74 aura::Window* root_window_; | 82 aura::Window* root_window_; |
| 75 wm::WmToplevelWindowEventHandler toplevel_window_event_handler_; | 83 wm::WmToplevelWindowEventHandler toplevel_window_event_handler_; |
| 76 | 84 |
| 77 DISALLOW_COPY_AND_ASSIGN(MoveEventHandler); | 85 DISALLOW_COPY_AND_ASSIGN(MoveEventHandler); |
| 78 }; | 86 }; |
| 79 | 87 |
| 80 } // namespace mus | 88 } // namespace mus |
| 81 } // namespace ash | 89 } // namespace ash |
| 82 | 90 |
| 83 #endif // ASH_MUS_MOVE_EVENT_HANDLER_H_ | 91 #endif // ASH_MUS_MOVE_EVENT_HANDLER_H_ |
| OLD | NEW |