Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / ash / wm / toplevel_window_event_handler.h
blob80ce0f803c0046263732f5be657a1bbe3ff455d0
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.
5 #ifndef ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
6 #define ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
8 #include <set>
10 #include "ash/ash_export.h"
11 #include "ash/display/window_tree_host_manager.h"
12 #include "ash/wm/wm_types.h"
13 #include "base/callback.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "ui/events/event_handler.h"
17 #include "ui/gfx/geometry/point.h"
18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/wm/public/window_move_client.h"
21 namespace aura {
22 class Window;
25 namespace ui {
26 class LocatedEvent;
29 namespace ash {
31 class WindowResizer;
33 class ASH_EXPORT ToplevelWindowEventHandler
34 : public ui::EventHandler,
35 public aura::client::WindowMoveClient,
36 public WindowTreeHostManager::Observer {
37 public:
38 ToplevelWindowEventHandler();
39 ~ToplevelWindowEventHandler() override;
41 // Overridden from ui::EventHandler:
42 void OnKeyEvent(ui::KeyEvent* event) override;
43 void OnMouseEvent(ui::MouseEvent* event) override;
44 void OnGestureEvent(ui::GestureEvent* event) override;
46 // Overridden form aura::client::WindowMoveClient:
47 aura::client::WindowMoveResult RunMoveLoop(
48 aura::Window* source,
49 const gfx::Vector2d& drag_offset,
50 aura::client::WindowMoveSource move_source) override;
51 void EndMoveLoop() override;
53 // Overridden form ash::WindowTreeHostManager::Observer:
54 void OnDisplayConfigurationChanging() override;
56 private:
57 class ScopedWindowResizer;
59 enum DragCompletionStatus {
60 DRAG_COMPLETE,
61 DRAG_REVERT,
63 // To be used when WindowResizer::GetTarget() is destroyed. Neither
64 // completes nor reverts the drag because both access the WindowResizer's
65 // window.
66 DRAG_RESIZER_WINDOW_DESTROYED
69 // Attempts to start a drag if one is not already in progress. Returns true if
70 // successful.
71 bool AttemptToStartDrag(aura::Window* window,
72 const gfx::Point& point_in_parent,
73 int window_component,
74 aura::client::WindowMoveSource source);
76 // Completes or reverts the drag if one is in progress. Returns true if a
77 // drag was completed or reverted.
78 bool CompleteDrag(DragCompletionStatus status);
80 void HandleMousePressed(aura::Window* target, ui::MouseEvent* event);
81 void HandleMouseReleased(aura::Window* target, ui::MouseEvent* event);
83 // Called during a drag to resize/position the window.
84 void HandleDrag(aura::Window* target, ui::LocatedEvent* event);
86 // Called during mouse moves to update window resize shadows.
87 void HandleMouseMoved(aura::Window* target, ui::LocatedEvent* event);
89 // Called for mouse exits to hide window resize shadows.
90 void HandleMouseExited(aura::Window* target, ui::LocatedEvent* event);
92 // Called when mouse capture is lost.
93 void HandleCaptureLost(ui::LocatedEvent* event);
95 // Sets |window|'s state type to |new_state_type|. Called after the drag has
96 // been completed for fling gestures.
97 void SetWindowStateTypeFromGesture(aura::Window* window,
98 wm::WindowStateType new_state_type);
100 // Invoked from ScopedWindowResizer if the window is destroyed.
101 void ResizerWindowDestroyed();
103 // The hittest result for the first finger at the time that it initially
104 // touched the screen. |first_finger_hittest_| is one of ui/base/hit_test.h
105 int first_finger_hittest_;
107 // The window bounds when the drag was started. When a window is minimized,
108 // maximized or snapped via a swipe/fling gesture, the restore bounds should
109 // be set to the bounds of the window when the drag was started.
110 gfx::Rect pre_drag_window_bounds_;
112 // Are we running a nested message loop from RunMoveLoop().
113 bool in_move_loop_;
115 // Is a window move/resize in progress because of gesture events?
116 bool in_gesture_drag_;
118 // Whether the drag was reverted. Set by CompleteDrag().
119 bool drag_reverted_;
121 scoped_ptr<ScopedWindowResizer> window_resizer_;
123 base::Closure quit_closure_;
125 // Used to track if this object is deleted while running a nested message
126 // loop. If non-null the destructor sets this to true.
127 bool* destroyed_;
129 DISALLOW_COPY_AND_ASSIGN(ToplevelWindowEventHandler);
132 } // namespace aura
134 #endif // ASH_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_