OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ | 5 #ifndef ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
6 #define ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ | 6 #define ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/wm/wm_types.h" | 11 #include "ash/wm/wm_types.h" |
12 #include "ash/wm_display_observer.h" | 12 #include "ash/wm_display_observer.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
16 #include "ui/wm/public/window_move_client.h" | 16 #include "ui/wm/public/window_move_client.h" |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 class KeyEvent; | 19 class KeyEvent; |
20 class LocatedEvent; | 20 class LocatedEvent; |
21 class MouseEvent; | 21 class MouseEvent; |
22 class GestureEvent; | 22 class GestureEvent; |
23 } | 23 } |
24 | 24 |
25 namespace ash { | 25 namespace ash { |
26 | 26 |
27 class WmShell; | |
28 class WmWindow; | 27 class WmWindow; |
29 | 28 |
30 namespace wm { | 29 namespace wm { |
31 | 30 |
32 // WmToplevelWindowEventHandler handles dragging and resizing of top level | 31 // WmToplevelWindowEventHandler handles dragging and resizing of top level |
33 // windows. WmToplevelWindowEventHandler is forwarded events, such as from an | 32 // windows. WmToplevelWindowEventHandler is forwarded events, such as from an |
34 // EventHandler. | 33 // EventHandler. |
35 class ASH_EXPORT WmToplevelWindowEventHandler : public WmDisplayObserver { | 34 class ASH_EXPORT WmToplevelWindowEventHandler : public WmDisplayObserver { |
36 public: | 35 public: |
37 // Describes what triggered ending the drag. | 36 // Describes what triggered ending the drag. |
38 enum class DragResult { | 37 enum class DragResult { |
39 // The drag successfully completed. | 38 // The drag successfully completed. |
40 SUCCESS, | 39 SUCCESS, |
41 | 40 |
42 REVERT, | 41 REVERT, |
43 | 42 |
44 // The underlying window was destroyed while the drag is in process. | 43 // The underlying window was destroyed while the drag is in process. |
45 WINDOW_DESTROYED | 44 WINDOW_DESTROYED |
46 }; | 45 }; |
47 using EndClosure = base::Callback<void(DragResult)>; | 46 using EndClosure = base::Callback<void(DragResult)>; |
48 | 47 |
49 explicit WmToplevelWindowEventHandler(WmShell* shell); | 48 WmToplevelWindowEventHandler(); |
50 ~WmToplevelWindowEventHandler() override; | 49 ~WmToplevelWindowEventHandler() override; |
51 | 50 |
52 void OnKeyEvent(ui::KeyEvent* event); | 51 void OnKeyEvent(ui::KeyEvent* event); |
53 void OnMouseEvent(ui::MouseEvent* event, WmWindow* target); | 52 void OnMouseEvent(ui::MouseEvent* event, WmWindow* target); |
54 void OnGestureEvent(ui::GestureEvent* event, WmWindow* target); | 53 void OnGestureEvent(ui::GestureEvent* event, WmWindow* target); |
55 | 54 |
56 // Attempts to start a drag if one is not already in progress. Returns true if | 55 // Attempts to start a drag if one is not already in progress. Returns true if |
57 // successful. |end_closure| is run when the drag completes. |end_closure| is | 56 // successful. |end_closure| is run when the drag completes. |end_closure| is |
58 // not run if the drag does not start. | 57 // not run if the drag does not start. |
59 bool AttemptToStartDrag(WmWindow* window, | 58 bool AttemptToStartDrag(WmWindow* window, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // been completed for fling gestures. | 93 // been completed for fling gestures. |
95 void SetWindowStateTypeFromGesture(WmWindow* window, | 94 void SetWindowStateTypeFromGesture(WmWindow* window, |
96 wm::WindowStateType new_state_type); | 95 wm::WindowStateType new_state_type); |
97 | 96 |
98 // Invoked from ScopedWindowResizer if the window is destroyed. | 97 // Invoked from ScopedWindowResizer if the window is destroyed. |
99 void ResizerWindowDestroyed(); | 98 void ResizerWindowDestroyed(); |
100 | 99 |
101 // WmDisplayObserver: | 100 // WmDisplayObserver: |
102 void OnDisplayConfigurationChanging() override; | 101 void OnDisplayConfigurationChanging() override; |
103 | 102 |
104 WmShell* shell_; | |
105 | |
106 // The hittest result for the first finger at the time that it initially | 103 // The hittest result for the first finger at the time that it initially |
107 // touched the screen. |first_finger_hittest_| is one of ui/base/hit_test.h | 104 // touched the screen. |first_finger_hittest_| is one of ui/base/hit_test.h |
108 int first_finger_hittest_; | 105 int first_finger_hittest_; |
109 | 106 |
110 // The window bounds when the drag was started. When a window is minimized, | 107 // The window bounds when the drag was started. When a window is minimized, |
111 // maximized or snapped via a swipe/fling gesture, the restore bounds should | 108 // maximized or snapped via a swipe/fling gesture, the restore bounds should |
112 // be set to the bounds of the window when the drag was started. | 109 // be set to the bounds of the window when the drag was started. |
113 gfx::Rect pre_drag_window_bounds_; | 110 gfx::Rect pre_drag_window_bounds_; |
114 | 111 |
115 // Is a window move/resize in progress because of gesture events? | 112 // Is a window move/resize in progress because of gesture events? |
116 bool in_gesture_drag_ = false; | 113 bool in_gesture_drag_ = false; |
117 | 114 |
118 std::unique_ptr<ScopedWindowResizer> window_resizer_; | 115 std::unique_ptr<ScopedWindowResizer> window_resizer_; |
119 | 116 |
120 EndClosure end_closure_; | 117 EndClosure end_closure_; |
121 | 118 |
122 DISALLOW_COPY_AND_ASSIGN(WmToplevelWindowEventHandler); | 119 DISALLOW_COPY_AND_ASSIGN(WmToplevelWindowEventHandler); |
123 }; | 120 }; |
124 | 121 |
125 } // namespace wm | 122 } // namespace wm |
126 } // namespace ash | 123 } // namespace ash |
127 | 124 |
128 #endif // ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ | 125 #endif // ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ |
OLD | NEW |