Chromium Code Reviews| Index: ash/wm/toplevel_window_event_handler.h |
| diff --git a/ash/wm/toplevel_window_event_handler.h b/ash/wm/toplevel_window_event_handler.h |
| index bd04902e6dc39c714d221e4dd1c026590b3c98cd..7187330d6e9487d4531479af21af59bd3fb1e294 100644 |
| --- a/ash/wm/toplevel_window_event_handler.h |
| +++ b/ash/wm/toplevel_window_event_handler.h |
| @@ -5,38 +5,32 @@ |
| #ifndef ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
| #define ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
| -#include <memory> |
| -#include <set> |
| - |
| #include "ash/ash_export.h" |
| -#include "ash/display/window_tree_host_manager.h" |
| +#include "ash/wm/common/wm_toplevel_window_event_handler.h" |
| #include "ash/wm/common/wm_types.h" |
| -#include "base/callback.h" |
| -#include "base/compiler_specific.h" |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "ui/events/event_handler.h" |
| -#include "ui/gfx/geometry/point.h" |
| -#include "ui/gfx/geometry/rect.h" |
| #include "ui/wm/public/window_move_client.h" |
| namespace aura { |
| class Window; |
| } |
| -namespace ui { |
| -class LocatedEvent; |
| +namespace base { |
| +class RunLoop; |
| } |
| namespace ash { |
| - |
| -class WindowResizer; |
| +namespace wm { |
| +class WmGloblals; |
| +} |
| class ASH_EXPORT ToplevelWindowEventHandler |
| : public ui::EventHandler, |
| - public aura::client::WindowMoveClient, |
| - public WindowTreeHostManager::Observer { |
| + public aura::client::WindowMoveClient { |
| public: |
| - ToplevelWindowEventHandler(); |
| + explicit ToplevelWindowEventHandler(wm::WmGlobals* globals); |
| ~ToplevelWindowEventHandler() override; |
| // Overridden from ui::EventHandler: |
| @@ -51,85 +45,23 @@ class ASH_EXPORT ToplevelWindowEventHandler |
| aura::client::WindowMoveSource move_source) override; |
| void EndMoveLoop() override; |
| - // Overridden form ash::WindowTreeHostManager::Observer: |
| - void OnDisplayConfigurationChanging() override; |
| - |
| private: |
| - class ScopedWindowResizer; |
| - |
| - enum DragCompletionStatus { |
| - DRAG_COMPLETE, |
| - DRAG_REVERT, |
| - |
| - // To be used when WindowResizer::GetTarget() is destroyed. Neither |
| - // completes nor reverts the drag because both access the WindowResizer's |
| - // window. |
| - DRAG_RESIZER_WINDOW_DESTROYED |
| - }; |
| - |
| - // Attempts to start a drag if one is not already in progress. Returns true if |
| - // successful. |
| - bool AttemptToStartDrag(aura::Window* window, |
| - const gfx::Point& point_in_parent, |
| - int window_component, |
| - aura::client::WindowMoveSource source); |
| - |
| - // Completes or reverts the drag if one is in progress. Returns true if a |
| - // drag was completed or reverted. |
| - bool CompleteDrag(DragCompletionStatus status); |
| - |
| - void HandleMousePressed(aura::Window* target, ui::MouseEvent* event); |
| - void HandleMouseReleased(aura::Window* target, ui::MouseEvent* event); |
| - |
| - // Called during a drag to resize/position the window. |
| - void HandleDrag(aura::Window* target, ui::LocatedEvent* event); |
| + // Callback from WmToplevelWindowEventHandler once the drag completes. |
| + void OnDragCompleted( |
| + wm::WmToplevelWindowEventHandler::EndReason* end_reason_result, |
| + base::RunLoop* run_loop, |
| + wm::WmToplevelWindowEventHandler::EndReason end_reason); |
| - // Called during mouse moves to update window resize shadows. |
| - void HandleMouseMoved(aura::Window* target, ui::LocatedEvent* event); |
| - |
| - // Called for mouse exits to hide window resize shadows. |
| - void HandleMouseExited(aura::Window* target, ui::LocatedEvent* event); |
| - |
| - // Called when mouse capture is lost. |
| - void HandleCaptureLost(ui::LocatedEvent* event); |
| - |
| - // Sets |window|'s state type to |new_state_type|. Called after the drag has |
| - // been completed for fling gestures. |
| - void SetWindowStateTypeFromGesture(aura::Window* window, |
| - wm::WindowStateType new_state_type); |
| - |
| - // Invoked from ScopedWindowResizer if the window is destroyed. |
| - void ResizerWindowDestroyed(); |
| - |
| - // The hittest result for the first finger at the time that it initially |
| - // touched the screen. |first_finger_hittest_| is one of ui/base/hit_test.h |
| - int first_finger_hittest_; |
| - |
| - // The window bounds when the drag was started. When a window is minimized, |
| - // maximized or snapped via a swipe/fling gesture, the restore bounds should |
| - // be set to the bounds of the window when the drag was started. |
| - gfx::Rect pre_drag_window_bounds_; |
| + wm::WmToplevelWindowEventHandler wm_toplevel_window_event_handler_; |
| // Are we running a nested message loop from RunMoveLoop(). |
| - bool in_move_loop_; |
| - |
| - // Is a window move/resize in progress because of gesture events? |
| - bool in_gesture_drag_; |
| - |
| - // Whether the drag was reverted. Set by CompleteDrag(). |
| - bool drag_reverted_; |
| - |
| - std::unique_ptr<ScopedWindowResizer> window_resizer_; |
| - |
| - base::Closure quit_closure_; |
| + bool in_move_loop_ = false; |
| - // Used to track if this object is deleted while running a nested message |
| - // loop. If non-null the destructor sets this to true. |
| - bool* destroyed_; |
| + base::WeakPtrFactory<ToplevelWindowEventHandler> weak_factory_; |
|
James Cook
2016/05/21 18:28:21
Just for my edification: We need the weak pointers
sky
2016/05/23 15:48:52
Yes, and in particular a nested message loop for d
|
| DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandler); |
| }; |
| -} // namespace aura |
| +} // namespace ash |
| #endif // ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |