Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(653)

Side by Side Diff: ash/wm/wm_toplevel_window_event_handler.h

Issue 2905893002: chromeos: convert more ash/wm code to aura::Window (Closed)
Patch Set: moar cleanup Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 aura {
19 class Window;
20 }
21
18 namespace ui { 22 namespace ui {
19 class KeyEvent; 23 class KeyEvent;
20 class LocatedEvent; 24 class LocatedEvent;
21 class MouseEvent; 25 class MouseEvent;
22 class GestureEvent; 26 class GestureEvent;
23 } 27 }
24 28
25 namespace ash { 29 namespace ash {
26
27 class WmWindow;
28
29 namespace wm { 30 namespace wm {
30 31
31 // WmToplevelWindowEventHandler handles dragging and resizing of top level 32 // WmToplevelWindowEventHandler handles dragging and resizing of top level
32 // windows. WmToplevelWindowEventHandler is forwarded events, such as from an 33 // windows. WmToplevelWindowEventHandler is forwarded events, such as from an
33 // EventHandler. 34 // EventHandler.
34 class ASH_EXPORT WmToplevelWindowEventHandler : public WmDisplayObserver { 35 class ASH_EXPORT WmToplevelWindowEventHandler : public WmDisplayObserver {
35 public: 36 public:
36 // Describes what triggered ending the drag. 37 // Describes what triggered ending the drag.
37 enum class DragResult { 38 enum class DragResult {
38 // The drag successfully completed. 39 // The drag successfully completed.
39 SUCCESS, 40 SUCCESS,
40 41
41 REVERT, 42 REVERT,
42 43
43 // The underlying window was destroyed while the drag is in process. 44 // The underlying window was destroyed while the drag is in process.
44 WINDOW_DESTROYED 45 WINDOW_DESTROYED
45 }; 46 };
46 using EndClosure = base::Callback<void(DragResult)>; 47 using EndClosure = base::Callback<void(DragResult)>;
47 48
48 WmToplevelWindowEventHandler(); 49 WmToplevelWindowEventHandler();
49 ~WmToplevelWindowEventHandler() override; 50 ~WmToplevelWindowEventHandler() override;
50 51
51 void OnKeyEvent(ui::KeyEvent* event); 52 void OnKeyEvent(ui::KeyEvent* event);
52 void OnMouseEvent(ui::MouseEvent* event, WmWindow* target); 53 void OnMouseEvent(ui::MouseEvent* event, aura::Window* target);
53 void OnGestureEvent(ui::GestureEvent* event, WmWindow* target); 54 void OnGestureEvent(ui::GestureEvent* event, aura::Window* target);
54 55
55 // Attempts to start a drag if one is not already in progress. Returns true if 56 // Attempts to start a drag if one is not already in progress. Returns true if
56 // successful. |end_closure| is run when the drag completes. |end_closure| is 57 // successful. |end_closure| is run when the drag completes. |end_closure| is
57 // not run if the drag does not start. 58 // not run if the drag does not start.
58 bool AttemptToStartDrag(WmWindow* window, 59 bool AttemptToStartDrag(aura::Window* window,
59 const gfx::Point& point_in_parent, 60 const gfx::Point& point_in_parent,
60 int window_component, 61 int window_component,
61 aura::client::WindowMoveSource source, 62 aura::client::WindowMoveSource source,
62 const EndClosure& end_closure); 63 const EndClosure& end_closure);
63 64
64 // If there is a drag in progress it is reverted, otherwise does nothing. 65 // If there is a drag in progress it is reverted, otherwise does nothing.
65 void RevertDrag(); 66 void RevertDrag();
66 67
67 // Returns true if there is a drag in progress. 68 // Returns true if there is a drag in progress.
68 bool is_drag_in_progress() const { return window_resizer_.get() != nullptr; } 69 bool is_drag_in_progress() const { return window_resizer_.get() != nullptr; }
69 70
70 private: 71 private:
71 class ScopedWindowResizer; 72 class ScopedWindowResizer;
72 73
73 // Completes or reverts the drag if one is in progress. Returns true if a 74 // Completes or reverts the drag if one is in progress. Returns true if a
74 // drag was completed or reverted. 75 // drag was completed or reverted.
75 bool CompleteDrag(DragResult result); 76 bool CompleteDrag(DragResult result);
76 77
77 void HandleMousePressed(WmWindow* target, ui::MouseEvent* event); 78 void HandleMousePressed(aura::Window* target, ui::MouseEvent* event);
78 void HandleMouseReleased(WmWindow* target, ui::MouseEvent* event); 79 void HandleMouseReleased(aura::Window* target, ui::MouseEvent* event);
79 80
80 // Called during a drag to resize/position the window. 81 // Called during a drag to resize/position the window.
81 void HandleDrag(WmWindow* target, ui::LocatedEvent* event); 82 void HandleDrag(aura::Window* target, ui::LocatedEvent* event);
82 83
83 // Called during mouse moves to update window resize shadows. 84 // Called during mouse moves to update window resize shadows.
84 void HandleMouseMoved(WmWindow* target, ui::LocatedEvent* event); 85 void HandleMouseMoved(aura::Window* target, ui::LocatedEvent* event);
85 86
86 // Called for mouse exits to hide window resize shadows. 87 // Called for mouse exits to hide window resize shadows.
87 void HandleMouseExited(WmWindow* target, ui::LocatedEvent* event); 88 void HandleMouseExited(aura::Window* target, ui::LocatedEvent* event);
88 89
89 // Called when mouse capture is lost. 90 // Called when mouse capture is lost.
90 void HandleCaptureLost(ui::LocatedEvent* event); 91 void HandleCaptureLost(ui::LocatedEvent* event);
91 92
92 // Sets |window|'s state type to |new_state_type|. Called after the drag has 93 // Sets |window|'s state type to |new_state_type|. Called after the drag has
93 // been completed for fling gestures. 94 // been completed for fling gestures.
94 void SetWindowStateTypeFromGesture(WmWindow* window, 95 void SetWindowStateTypeFromGesture(aura::Window* window,
95 wm::WindowStateType new_state_type); 96 wm::WindowStateType new_state_type);
96 97
97 // Invoked from ScopedWindowResizer if the window is destroyed. 98 // Invoked from ScopedWindowResizer if the window is destroyed.
98 void ResizerWindowDestroyed(); 99 void ResizerWindowDestroyed();
99 100
100 // WmDisplayObserver: 101 // WmDisplayObserver:
101 void OnDisplayConfigurationChanging() override; 102 void OnDisplayConfigurationChanging() override;
102 103
103 // The hittest result for the first finger at the time that it initially 104 // 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 // touched the screen. |first_finger_hittest_| is one of ui/base/hit_test.h
(...skipping 11 matching lines...) Expand all
116 117
117 EndClosure end_closure_; 118 EndClosure end_closure_;
118 119
119 DISALLOW_COPY_AND_ASSIGN(WmToplevelWindowEventHandler); 120 DISALLOW_COPY_AND_ASSIGN(WmToplevelWindowEventHandler);
120 }; 121 };
121 122
122 } // namespace wm 123 } // namespace wm
123 } // namespace ash 124 } // namespace ash
124 125
125 #endif // ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_ 126 #endif // ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698