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

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

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

Powered by Google App Engine
This is Rietveld 408576698