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

Side by Side Diff: components/mus/ws/move_loop.h

Issue 1414943003: Moves move logic into WM instead of WS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 5 years, 1 month 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 | « components/mus/ws/event_dispatcher_unittest.cc ('k') | components/mus/ws/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 COMPONENTS_MUS_WS_MOVE_LOOP_H_
6 #define COMPONENTS_MUS_WS_MOVE_LOOP_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "components/mus/ws/server_window_observer.h"
11 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/mojo/events/input_events.mojom.h"
14
15 namespace mus {
16 namespace ws {
17
18 class ServerWindow;
19
20 // MoveLoop is responsible for moving/resizing windows. EventDispatcher
21 // attempts to create a MoveLoop on every POINTER_DOWN event. Once a MoveLoop
22 // is created it is fed events until an event is received that stops the loop.
23 class MoveLoop : public ServerWindowObserver {
24 public:
25 enum MoveResult {
26 // The move is still ongoing.
27 CONTINUE,
28
29 // The move is done and the MoveLoop should be destroyed.
30 DONE,
31 };
32
33 ~MoveLoop() override;
34
35 // If a move/resize loop should occur for the specified parameters creates
36 // and returns a new MoveLoop. All events should be funneled to the MoveLoop
37 // until done (Move()).
38 static scoped_ptr<MoveLoop> Create(ServerWindow* target,
39 const mojo::Event& event);
40
41 // Processes an event for a move/resize loop.
42 MoveResult Move(const mojo::Event& event);
43
44 private:
45 MoveLoop(ServerWindow* target, const mojo::Event& event);
46
47 // Does the actual move/resize.
48 void MoveImpl(const mojo::Event& event);
49
50 // Cancels the loop. This sets |target_| to null and removes the observer.
51 // After this the MoveLoop is still ongoing and won't stop until the
52 // appropriate event is received.
53 void Cancel();
54
55 void Revert();
56
57 // ServerWindowObserver:
58 void OnWindowHierarchyChanged(ServerWindow* window,
59 ServerWindow* new_parent,
60 ServerWindow* old_parent) override;
61 void OnWindowBoundsChanged(ServerWindow* window,
62 const gfx::Rect& old_bounds,
63 const gfx::Rect& new_bounds) override;
64 void OnWindowVisibilityChanged(ServerWindow* window) override;
65
66 // The window this MoveLoop is acting on. |target_| is set to null if the
67 // window unexpectedly changes while the move is in progress.
68 ServerWindow* target_;
69
70 // The id of the pointer that triggered the move.
71 const int32_t pointer_id_;
72
73 // Location of the event (in screen coordinates) that triggered the move.
74 const gfx::Point initial_event_screen_location_;
75
76 // Original bounds of the window.
77 const gfx::Rect initial_window_bounds_;
78
79 // Set to true when MoveLoop changes the bounds of |target_|. The move is
80 // canceled if the bounds change unexpectedly during the move.
81 bool changing_bounds_;
82
83 DISALLOW_COPY_AND_ASSIGN(MoveLoop);
84 };
85
86 } // namespace ws
87 } // namespace mus
88
89 #endif // COMPONENTS_MUS_WS_MOVE_LOOP_H_
OLDNEW
« no previous file with comments | « components/mus/ws/event_dispatcher_unittest.cc ('k') | components/mus/ws/move_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698