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

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

Issue 2030593002: Renames ash/wm/common into ash/common/wm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
(Empty)
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.
4
5 #ifndef ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
6 #define ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
7
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "ash/wm/common/wm_display_observer.h"
12 #include "ash/wm/common/wm_types.h"
13 #include "base/callback.h"
14 #include "base/macros.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/wm/public/window_move_client.h"
17
18 namespace ui {
19 class KeyEvent;
20 class LocatedEvent;
21 class MouseEvent;
22 class GestureEvent;
23 }
24
25 namespace ash {
26
27 class WindowResizer;
28
29 namespace wm {
30
31 class WmGlobals;
32 class WmWindow;
33
34 // WmToplevelWindowEventHandler handles dragging and resizing of top level
35 // windows. WmToplevelWindowEventHandler is forwarded events, such as from an
36 // EventHandler.
37 class ASH_EXPORT WmToplevelWindowEventHandler : public WmDisplayObserver {
38 public:
39 // Describes what triggered ending the drag.
40 enum class DragResult {
41 // The drag successfully completed.
42 SUCCESS,
43
44 REVERT,
45
46 // The underlying window was destroyed while the drag is in process.
47 WINDOW_DESTROYED
48 };
49 using EndClosure = base::Callback<void(DragResult)>;
50
51 explicit WmToplevelWindowEventHandler(WmGlobals* globals);
52 ~WmToplevelWindowEventHandler() override;
53
54 void OnKeyEvent(ui::KeyEvent* event);
55 void OnMouseEvent(ui::MouseEvent* event, WmWindow* target);
56 void OnGestureEvent(ui::GestureEvent* event, WmWindow* target);
57
58 // 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
60 // not run if the drag does not start.
61 bool AttemptToStartDrag(WmWindow* window,
62 const gfx::Point& point_in_parent,
63 int window_component,
64 aura::client::WindowMoveSource source,
65 const EndClosure& end_closure);
66
67 // If there is a drag in progress it is reverted, otherwise does nothing.
68 void RevertDrag();
69
70 // Returns true if there is a drag in progress.
71 bool is_drag_in_progress() const { return window_resizer_.get() != nullptr; }
72
73 private:
74 class ScopedWindowResizer;
75
76 // Completes or reverts the drag if one is in progress. Returns true if a
77 // drag was completed or reverted.
78 bool CompleteDrag(DragResult result);
79
80 void HandleMousePressed(WmWindow* target, ui::MouseEvent* event);
81 void HandleMouseReleased(WmWindow* target, ui::MouseEvent* event);
82
83 // Called during a drag to resize/position the window.
84 void HandleDrag(WmWindow* target, ui::LocatedEvent* event);
85
86 // Called during mouse moves to update window resize shadows.
87 void HandleMouseMoved(WmWindow* target, ui::LocatedEvent* event);
88
89 // Called for mouse exits to hide window resize shadows.
90 void HandleMouseExited(WmWindow* target, ui::LocatedEvent* event);
91
92 // Called when mouse capture is lost.
93 void HandleCaptureLost(ui::LocatedEvent* event);
94
95 // Sets |window|'s state type to |new_state_type|. Called after the drag has
96 // been completed for fling gestures.
97 void SetWindowStateTypeFromGesture(WmWindow* window,
98 wm::WindowStateType new_state_type);
99
100 // Invoked from ScopedWindowResizer if the window is destroyed.
101 void ResizerWindowDestroyed();
102
103 // WmDisplayObserver:
104 void OnDisplayConfigurationChanging() override;
105
106 WmGlobals* globals_;
107
108 // 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
110 int first_finger_hittest_;
111
112 // 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
114 // be set to the bounds of the window when the drag was started.
115 gfx::Rect pre_drag_window_bounds_;
116
117 // Is a window move/resize in progress because of gesture events?
118 bool in_gesture_drag_ = false;
119
120 std::unique_ptr<ScopedWindowResizer> window_resizer_;
121
122 EndClosure end_closure_;
123
124 DISALLOW_COPY_AND_ASSIGN(WmToplevelWindowEventHandler);
125 };
126
127 } // namespace wm
128 } // namespace ash
129
130 #endif // ASH_WM_WM_TOPLEVEL_WINDOW_EVENT_HANDLER_H_
OLDNEW
« no previous file with comments | « ash/wm/common/wm_snap_to_pixel_layout_manager.cc ('k') | ash/wm/common/wm_toplevel_window_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698