OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 SERVICES_UI_WS_CURRENT_DRAG_OPERATION_H_ | |
6 #define SERVICES_UI_WS_CURRENT_DRAG_OPERATION_H_ | |
7 | |
8 #include <deque> | |
9 | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "services/ui/common/types.h" | |
12 #include "services/ui/ws/ids.h" | |
13 #include "services/ui/ws/server_window_observer.h" | |
14 | |
15 namespace ui { | |
16 namespace ws { | |
17 | |
18 namespace test { | |
19 class CurrentDragOperationTestApi; | |
20 } | |
21 | |
22 class CurrentDragOperationSource; | |
23 | |
24 // Represents all the data around the current ongoing drag operation. | |
25 // | |
26 // There should only be one instance of this class per userid. The | |
27 // WindowManagerState's EventDispatcher creates and owns this instance. | |
28 class CurrentDragOperation : public ServerWindowObserver { | |
sky
2016/09/06 21:11:27
Is 'current' really helpful in this context? Is ju
| |
29 public: | |
30 CurrentDragOperation(CurrentDragOperationSource* source, | |
31 ServerWindow* window, | |
32 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, | |
33 uint32_t drag_operations); | |
34 ~CurrentDragOperation() override; | |
35 | |
36 // Cancels the current drag, ie, due to the user pressing Escape. | |
37 void DispatchCancel(); | |
sky
2016/09/06 21:11:27
I would just call this Cancel().
| |
38 | |
39 // Responds to a pointer move/release event. | |
40 void DispatchLocatedEvent(const ui::LocatedEvent& event, | |
41 ServerWindow* current_target); | |
42 | |
43 private: | |
44 friend class test::CurrentDragOperationTestApi; | |
45 enum DragEventType { TYPE_ENTER, TYPE_OVER, TYPE_LEAVE, TYPE_DROP }; | |
sky
2016/09/06 21:11:27
enum class, and nuke TYPE_?
| |
46 struct Operation; | |
47 | |
48 // Notifies all windows we messaged that the drag is finished, and then tell | |
49 // |source| the result. | |
50 void MessageDragCompleted(bool success); | |
51 | |
52 size_t GetSizeOfQueueForWindow(ServerWindow* window); | |
sky
2016/09/06 21:11:27
Description.
| |
53 | |
54 void QueueEvent(ServerWindow* window, | |
55 DragEventType type, | |
56 uint32_t key_state, | |
57 gfx::Point position); | |
58 void RemoveQueueFront(ServerWindow* window); | |
59 void DispatchFrontOfWindowQueue(ServerWindow* window, | |
60 std::deque<Operation>* queue); | |
61 | |
62 // Callback methods. | |
63 void OnDragStatusCompleted(const WindowId& id, uint32_t bitmask); | |
64 void OnDragDropCompleted(const WindowId& id, uint32_t bitmask); | |
65 | |
66 // ServerWindowObserver: | |
67 void OnWindowDestroying(ServerWindow* window) override; | |
68 | |
69 // Our owner. | |
70 CurrentDragOperationSource* source_ = nullptr; | |
71 | |
72 uint32_t drag_operations_; | |
sky
2016/09/06 21:11:27
const?
| |
73 | |
74 bool waiting_for_final_drop_response_ = false; | |
75 | |
76 ServerWindow* source_window_ = nullptr; | |
77 ServerWindow* current_target_window_ = nullptr; | |
78 | |
79 // A list of the offered mime types. | |
80 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data_; | |
81 | |
82 // Event queues for each window. If a vector is empty, there are no | |
83 // operations going on. If a vector has one operation, we're waiting on a | |
84 // response for that operation from the client. Every operation past the | |
85 // first is queued. | |
86 std::map<ServerWindow*, std::deque<Operation>> current_window_state_; | |
sky
2016/09/06 21:11:27
window_operations_?
| |
87 | |
88 // A set of ServerWindows* which have received the PerformOnDragStart() call. | |
89 std::set<ServerWindow*> called_on_drag_start_; | |
90 | |
91 base::WeakPtrFactory<CurrentDragOperation> weak_factory_; | |
92 | |
93 DISALLOW_COPY_AND_ASSIGN(CurrentDragOperation); | |
94 }; | |
95 | |
96 } // namespace ws | |
97 } // namespace ui | |
98 | |
99 #endif // SERVICES_UI_WS_CURRENT_DRAG_OPERATION_H_ | |
OLD | NEW |