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

Side by Side Diff: mash/wm/frame/move_loop.h

Issue 2002243002: Gets mash to use WmToplevelWindowEventHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 7 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
« no previous file with comments | « mash/wm/frame/move_event_handler.cc ('k') | mash/wm/frame/move_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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 MASH_WM_FRAME_MOVE_LOOP_H_
6 #define MASH_WM_FRAME_MOVE_LOOP_H_
7
8 #include <stdint.h>
9
10 #include <memory>
11
12 #include "base/macros.h"
13 #include "components/mus/public/cpp/window_observer.h"
14 #include "components/mus/public/interfaces/input_events.mojom.h"
15 #include "ui/gfx/geometry/point.h"
16 #include "ui/gfx/geometry/rect.h"
17
18 namespace ui {
19 class PointerEvent;
20 }
21
22 namespace mash {
23 namespace wm {
24
25 // MoveLoop is responsible for moving/resizing windows.
26 class MoveLoop : public mus::WindowObserver {
27 public:
28 enum MoveResult {
29 // The move is still ongoing.
30 CONTINUE,
31
32 // The move is done and the MoveLoop should be destroyed.
33 DONE,
34 };
35
36 enum class HorizontalLocation {
37 LEFT,
38 RIGHT,
39 OTHER,
40 };
41
42 enum class VerticalLocation {
43 TOP,
44 BOTTOM,
45 OTHER,
46 };
47
48 ~MoveLoop() override;
49
50 // If a move/resize loop should occur for the specified parameters creates
51 // and returns a new MoveLoop. All events should be funneled to the MoveLoop
52 // until done (Move()). |ht_location| is one of the constants defined by
53 // HitTestCompat.
54 static std::unique_ptr<MoveLoop> Create(mus::Window* target,
55 int ht_location,
56 const ui::PointerEvent& event);
57
58 // Processes an event for a move/resize loop.
59 MoveResult Move(const ui::PointerEvent& event);
60
61 // If possible reverts any changes made during the move loop.
62 void Revert();
63
64 private:
65 enum class Type {
66 MOVE,
67 RESIZE,
68 };
69
70 MoveLoop(mus::Window* target,
71 const ui::PointerEvent& event,
72 Type type,
73 HorizontalLocation h_loc,
74 VerticalLocation v_loc);
75
76 // Determines the type of move from the specified HitTestCompat value.
77 // Returns true if a move/resize should occur.
78 static bool DetermineType(int ht_location,
79 Type* type,
80 HorizontalLocation* h_loc,
81 VerticalLocation* v_loc);
82
83 // Does the actual move/resize.
84 void MoveImpl(const ui::PointerEvent& event);
85
86 // Cancels the loop. This sets |target_| to null and removes the observer.
87 // After this the MoveLoop is still ongoing and won't stop until the
88 // appropriate event is received.
89 void Cancel();
90
91 gfx::Rect DetermineBoundsFromDelta(const gfx::Vector2d& delta);
92
93 // mus::WindowObserver:
94 void OnTreeChanged(const TreeChangeParams& params) override;
95 void OnWindowBoundsChanged(mus::Window* window,
96 const gfx::Rect& old_bounds,
97 const gfx::Rect& new_bounds) override;
98 void OnWindowVisibilityChanged(mus::Window* window) override;
99
100 // The window this MoveLoop is acting on. |target_| is set to null if the
101 // window unexpectedly changes while the move is in progress.
102 mus::Window* target_;
103
104 const Type type_;
105 const HorizontalLocation h_loc_;
106 const VerticalLocation v_loc_;
107
108 // The id of the pointer that triggered the move.
109 const int32_t pointer_id_;
110
111 // Location of the event (in screen coordinates) that triggered the move.
112 const gfx::Point initial_event_screen_location_;
113
114 // Original bounds of the window.
115 const gfx::Rect initial_window_bounds_;
116
117 const gfx::Rect initial_user_set_bounds_;
118
119 // Set to true when MoveLoop changes the bounds of |target_|. The move is
120 // canceled if the bounds change unexpectedly during the move.
121 bool changing_bounds_;
122
123 DISALLOW_COPY_AND_ASSIGN(MoveLoop);
124 };
125
126 } // namespace wm
127 } // namespace mash
128
129 #endif // MASH_WM_FRAME_MOVE_LOOP_H_
OLDNEW
« no previous file with comments | « mash/wm/frame/move_event_handler.cc ('k') | mash/wm/frame/move_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698