OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_UI_WS_DRAG_CONTROLLER_H_ | 5 #ifndef SERVICES_UI_WS_DRAG_CONTROLLER_H_ |
6 #define SERVICES_UI_WS_DRAG_CONTROLLER_H_ | 6 #define SERVICES_UI_WS_DRAG_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // A bitmask of ui::mojom::kDropEffect operations. | 31 // A bitmask of ui::mojom::kDropEffect operations. |
32 using DropEffectBitmask = uint32_t; | 32 using DropEffectBitmask = uint32_t; |
33 | 33 |
34 // Represents all the data around the current ongoing drag operation. | 34 // Represents all the data around the current ongoing drag operation. |
35 // | 35 // |
36 // There should only be one instance of this class per userid. The | 36 // There should only be one instance of this class per userid. The |
37 // WindowManagerState's EventDispatcher creates and owns this instance. | 37 // WindowManagerState's EventDispatcher creates and owns this instance. |
38 class DragController : public ServerWindowObserver { | 38 class DragController : public ServerWindowObserver { |
39 public: | 39 public: |
40 DragController(DragCursorUpdater* cursor_updater, | 40 DragController( |
41 DragSource* source, | 41 DragCursorUpdater* cursor_updater, |
42 ServerWindow* source_window, | 42 DragSource* source, |
43 DragTargetConnection* source_connection, | 43 ServerWindow* source_window, |
44 int32_t drag_pointer, | 44 DragTargetConnection* source_connection, |
45 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data, | 45 int32_t drag_pointer, |
46 DropEffectBitmask drag_operations); | 46 const std::unordered_map<std::string, std::vector<uint8_t>>& mime_data, |
| 47 DropEffectBitmask drag_operations); |
47 ~DragController() override; | 48 ~DragController() override; |
48 | 49 |
49 ui::mojom::Cursor current_cursor() const { return current_cursor_; } | 50 ui::mojom::Cursor current_cursor() const { return current_cursor_; } |
50 | 51 |
51 // Cancels the current drag, ie, due to the user pressing Escape. | 52 // Cancels the current drag, ie, due to the user pressing Escape. |
52 void Cancel(); | 53 void Cancel(); |
53 | 54 |
54 // Responds to a pointer move/release event. Returns true if the event was | 55 // Responds to a pointer move/release event. Returns true if the event was |
55 // handled by the drag. | 56 // handled by the drag. |
56 bool DispatchPointerEvent(const ui::PointerEvent& event, | 57 bool DispatchPointerEvent(const ui::PointerEvent& event, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // we have to continue to exist, but not process any more pointer events. | 124 // we have to continue to exist, but not process any more pointer events. |
124 bool waiting_for_final_drop_response_ = false; | 125 bool waiting_for_final_drop_response_ = false; |
125 | 126 |
126 ServerWindow* source_window_; | 127 ServerWindow* source_window_; |
127 ServerWindow* current_target_window_ = nullptr; | 128 ServerWindow* current_target_window_ = nullptr; |
128 | 129 |
129 // The target connection that |source_window_| is part of. | 130 // The target connection that |source_window_| is part of. |
130 DragTargetConnection* source_connection_; | 131 DragTargetConnection* source_connection_; |
131 | 132 |
132 // A list of the offered mime types. | 133 // A list of the offered mime types. |
133 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data_; | 134 std::unordered_map<std::string, std::vector<uint8_t>> mime_data_; |
134 | 135 |
135 // We need to keep track of state on a per window basis. A window being in | 136 // We need to keep track of state on a per window basis. A window being in |
136 // this map means that we're observing it. WindowState also keeps track of | 137 // this map means that we're observing it. WindowState also keeps track of |
137 // what type of operation we're waiting for a response from the window's | 138 // what type of operation we're waiting for a response from the window's |
138 // client, along with a queued operation to send when we get a reply. | 139 // client, along with a queued operation to send when we get a reply. |
139 std::map<ServerWindow*, WindowState> window_state_; | 140 std::map<ServerWindow*, WindowState> window_state_; |
140 | 141 |
141 // A set of DragTargetConnections* which have received the | 142 // A set of DragTargetConnections* which have received the |
142 // PerformOnDragMimeTypes() call. | 143 // PerformOnDragMimeTypes() call. |
143 std::set<DragTargetConnection*> called_on_drag_mime_types_; | 144 std::set<DragTargetConnection*> called_on_drag_mime_types_; |
144 | 145 |
145 base::WeakPtrFactory<DragController> weak_factory_; | 146 base::WeakPtrFactory<DragController> weak_factory_; |
146 | 147 |
147 DISALLOW_COPY_AND_ASSIGN(DragController); | 148 DISALLOW_COPY_AND_ASSIGN(DragController); |
148 }; | 149 }; |
149 | 150 |
150 } // namespace ws | 151 } // namespace ws |
151 } // namespace ui | 152 } // namespace ui |
152 | 153 |
153 #endif // SERVICES_UI_WS_DRAG_CONTROLLER_H_ | 154 #endif // SERVICES_UI_WS_DRAG_CONTROLLER_H_ |
OLD | NEW |