OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ |
6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const gfx::Rect& bounds); | 101 const gfx::Rect& bounds); |
102 void SetCapture(Window* window); | 102 void SetCapture(Window* window); |
103 void ReleaseCapture(Window* window); | 103 void ReleaseCapture(Window* window); |
104 void SetClientArea(Id window_id, | 104 void SetClientArea(Id window_id, |
105 const gfx::Insets& client_area, | 105 const gfx::Insets& client_area, |
106 const std::vector<gfx::Rect>& additional_client_areas); | 106 const std::vector<gfx::Rect>& additional_client_areas); |
107 void SetHitTestMask(Id window_id, const gfx::Rect& mask); | 107 void SetHitTestMask(Id window_id, const gfx::Rect& mask); |
108 void ClearHitTestMask(Id window_id); | 108 void ClearHitTestMask(Id window_id); |
109 void SetFocus(Window* window); | 109 void SetFocus(Window* window); |
110 void SetCanFocus(Id window_id, bool can_focus); | 110 void SetCanFocus(Id window_id, bool can_focus); |
| 111 void SetCanAcceptDrops(Id window_id, bool can_accept_drops); |
111 void SetCanAcceptEvents(Id window_id, bool can_accept_events); | 112 void SetCanAcceptEvents(Id window_id, bool can_accept_events); |
112 void SetPredefinedCursor(Id window_id, ui::mojom::Cursor cursor_id); | 113 void SetPredefinedCursor(Id window_id, ui::mojom::Cursor cursor_id); |
113 void SetVisible(Window* window, bool visible); | 114 void SetVisible(Window* window, bool visible); |
114 void SetOpacity(Window* window, float opacity); | 115 void SetOpacity(Window* window, float opacity); |
115 void SetProperty(Window* window, | 116 void SetProperty(Window* window, |
116 const std::string& name, | 117 const std::string& name, |
117 mojo::Array<uint8_t> data); | 118 mojo::Array<uint8_t> data); |
118 void SetWindowTextInputState(Id window_id, mojo::TextInputStatePtr state); | 119 void SetWindowTextInputState(Id window_id, mojo::TextInputStatePtr state); |
119 void SetImeVisibility(Id window_id, | 120 void SetImeVisibility(Id window_id, |
120 bool visible, | 121 bool visible, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Returns the current location of the mouse on screen. Note: this method may | 169 // Returns the current location of the mouse on screen. Note: this method may |
169 // race the asynchronous initialization; but in that case we return (0, 0). | 170 // race the asynchronous initialization; but in that case we return (0, 0). |
170 gfx::Point GetCursorScreenPoint(); | 171 gfx::Point GetCursorScreenPoint(); |
171 | 172 |
172 // See description in window_tree.mojom. When an existing pointer watcher is | 173 // See description in window_tree.mojom. When an existing pointer watcher is |
173 // updated or cleared then any future events from the server for that watcher | 174 // updated or cleared then any future events from the server for that watcher |
174 // will be ignored. | 175 // will be ignored. |
175 void StartPointerWatcher(bool want_moves); | 176 void StartPointerWatcher(bool want_moves); |
176 void StopPointerWatcher(); | 177 void StopPointerWatcher(); |
177 | 178 |
| 179 void PerformDragDrop( |
| 180 Window* window, |
| 181 int drag_pointer, |
| 182 const std::map<std::string, std::vector<uint8_t>>& drag_data, |
| 183 int drag_operation, |
| 184 const gfx::Point& cursor_location, |
| 185 const SkBitmap& bitmap, |
| 186 const base::Callback<void(bool)>& callback); |
| 187 |
178 // Performs a window move. |callback| will be asynchronously called with the | 188 // Performs a window move. |callback| will be asynchronously called with the |
179 // whether the move loop completed successfully. | 189 // whether the move loop completed successfully. |
180 void PerformWindowMove(Window* window, | 190 void PerformWindowMove(Window* window, |
181 ui::mojom::MoveLoopSource source, | 191 ui::mojom::MoveLoopSource source, |
182 const gfx::Point& cursor_location, | 192 const gfx::Point& cursor_location, |
183 const base::Callback<void(bool)>& callback); | 193 const base::Callback<void(bool)>& callback); |
184 | 194 |
185 // Cancels a in progress window move. (If no window is currently being moved, | 195 // Cancels a in progress window move. (If no window is currently being moved, |
186 // does nothing.) | 196 // does nothing.) |
187 void CancelWindowMove(Window* window); | 197 void CancelWindowMove(Window* window); |
(...skipping 12 matching lines...) Expand all Loading... |
200 #if !defined(NDEBUG) | 210 #if !defined(NDEBUG) |
201 std::string GetDebugWindowHierarchy() const; | 211 std::string GetDebugWindowHierarchy() const; |
202 void BuildDebugInfo(const std::string& depth, | 212 void BuildDebugInfo(const std::string& depth, |
203 Window* window, | 213 Window* window, |
204 std::string* result) const; | 214 std::string* result) const; |
205 #endif | 215 #endif |
206 | 216 |
207 private: | 217 private: |
208 friend class WindowTreeClientPrivate; | 218 friend class WindowTreeClientPrivate; |
209 | 219 |
| 220 struct CurrentDragState; |
| 221 |
210 enum class NewWindowType { | 222 enum class NewWindowType { |
211 CHILD, | 223 CHILD, |
212 TOP_LEVEL, | 224 TOP_LEVEL, |
213 }; | 225 }; |
214 | 226 |
215 using IdToWindowMap = std::map<Id, Window*>; | 227 using IdToWindowMap = std::map<Id, Window*>; |
216 | 228 |
217 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. | 229 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. |
218 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; | 230 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; |
219 | 231 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 mojo::Array<uint8_t> new_data) override; | 313 mojo::Array<uint8_t> new_data) override; |
302 void OnWindowInputEvent(uint32_t event_id, | 314 void OnWindowInputEvent(uint32_t event_id, |
303 Id window_id, | 315 Id window_id, |
304 std::unique_ptr<ui::Event> event, | 316 std::unique_ptr<ui::Event> event, |
305 bool matches_pointer_watcher) override; | 317 bool matches_pointer_watcher) override; |
306 void OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 318 void OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
307 uint32_t window_id) override; | 319 uint32_t window_id) override; |
308 void OnWindowFocused(Id focused_window_id) override; | 320 void OnWindowFocused(Id focused_window_id) override; |
309 void OnWindowPredefinedCursorChanged(Id window_id, | 321 void OnWindowPredefinedCursorChanged(Id window_id, |
310 mojom::Cursor cursor) override; | 322 mojom::Cursor cursor) override; |
| 323 void OnDragDropStart( |
| 324 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) override; |
| 325 void OnDragEnter(Id window_id, |
| 326 uint32_t event_flags, |
| 327 const gfx::Point& position, |
| 328 uint32_t effect_bitmask, |
| 329 const OnDragEnterCallback& callback) override; |
| 330 void OnDragOver(Id window_id, |
| 331 uint32_t event_flags, |
| 332 const gfx::Point& position, |
| 333 uint32_t effect_bitmask, |
| 334 const OnDragOverCallback& callback) override; |
| 335 void OnDragLeave(Id window_id) override; |
| 336 void OnCompleteDrop(Id window_id, |
| 337 uint32_t event_flags, |
| 338 const gfx::Point& position, |
| 339 uint32_t effect_bitmask, |
| 340 const OnCompleteDropCallback& callback) override; |
| 341 void OnDragDropDone() override; |
311 void OnChangeCompleted(uint32_t change_id, bool success) override; | 342 void OnChangeCompleted(uint32_t change_id, bool success) override; |
312 void RequestClose(uint32_t window_id) override; | 343 void RequestClose(uint32_t window_id) override; |
313 void GetWindowManager( | 344 void GetWindowManager( |
314 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; | 345 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; |
315 | 346 |
316 // Overridden from WindowManager: | 347 // Overridden from WindowManager: |
317 void OnConnect(ClientSpecificId client_id) override; | 348 void OnConnect(ClientSpecificId client_id) override; |
318 void WmNewDisplayAdded(const display::Display& display, | 349 void WmNewDisplayAdded(const display::Display& display, |
319 mojom::WindowDataPtr root_data, | 350 mojom::WindowDataPtr root_data, |
320 bool parent_drawn) override; | 351 bool parent_drawn) override; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 437 |
407 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>> | 438 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>> |
408 window_manager_internal_; | 439 window_manager_internal_; |
409 mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_; | 440 mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_; |
410 | 441 |
411 bool has_pointer_watcher_ = false; | 442 bool has_pointer_watcher_ = false; |
412 | 443 |
413 // The current change id for the client. | 444 // The current change id for the client. |
414 uint32_t current_move_loop_change_ = 0u; | 445 uint32_t current_move_loop_change_ = 0u; |
415 | 446 |
| 447 // Callback executed when a move loop initiated by PerformWindowMove() is |
| 448 // completed. |
| 449 base::Callback<void(bool)> on_current_move_finished_; |
| 450 |
416 // The current change id for the window manager. | 451 // The current change id for the window manager. |
417 uint32_t current_wm_move_loop_change_ = 0u; | 452 uint32_t current_wm_move_loop_change_ = 0u; |
418 Id current_wm_move_loop_window_id_ = 0u; | 453 Id current_wm_move_loop_window_id_ = 0u; |
419 | 454 |
420 // Callback executed when a move loop initiated by PerformWindowMove() is | 455 // State related to being the initiator of a drag started with |
421 // completed. | 456 // PerformDragDrop(). |
422 base::Callback<void(bool)> on_current_move_finished_; | 457 std::unique_ptr<CurrentDragState> current_drag_state_; |
| 458 |
| 459 // The mus server sends the mime drag data once per connection; we cache this |
| 460 // and are responsible for sending it to all of our windows. |
| 461 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_drag_data_; |
| 462 |
| 463 // A set of window ids for windows that we received an OnDragEnter() message |
| 464 // for. We maintain this set so we know who to send OnDragFinish() messages |
| 465 // at the end of the drag. |
| 466 std::set<Id> drag_entered_windows_; |
423 | 467 |
424 base::WeakPtrFactory<WindowTreeClient> weak_factory_; | 468 base::WeakPtrFactory<WindowTreeClient> weak_factory_; |
425 | 469 |
426 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); | 470 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); |
427 }; | 471 }; |
428 | 472 |
429 } // namespace ui | 473 } // namespace ui |
430 | 474 |
431 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ | 475 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ |
OLD | NEW |