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