| 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 UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ | 5 #ifndef UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ |
| 6 #define UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ | 6 #define UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/atomicops.h" | 16 #include "base/atomicops.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 21 #include "mojo/public/cpp/bindings/associated_binding.h" | 21 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 22 #include "mojo/public/cpp/bindings/strong_binding.h" | 22 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 23 #include "services/ui/public/interfaces/window_tree.mojom.h" | 23 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 24 #include "ui/aura/aura_export.h" | 24 #include "ui/aura/aura_export.h" |
| 25 #include "ui/aura/client/capture_client_observer.h" | 25 #include "ui/aura/client/capture_client_observer.h" |
| 26 #include "ui/aura/client/focus_change_observer.h" | 26 #include "ui/aura/client/focus_change_observer.h" |
| 27 #include "ui/aura/client/transient_window_client_observer.h" | 27 #include "ui/aura/client/transient_window_client_observer.h" |
| 28 #include "ui/aura/mus/drag_drop_controller_host.h" |
| 28 #include "ui/aura/mus/mus_types.h" | 29 #include "ui/aura/mus/mus_types.h" |
| 29 #include "ui/aura/mus/window_manager_delegate.h" | 30 #include "ui/aura/mus/window_manager_delegate.h" |
| 30 #include "ui/aura/mus/window_tree_host_mus_delegate.h" | 31 #include "ui/aura/mus/window_tree_host_mus_delegate.h" |
| 31 | 32 |
| 32 namespace display { | 33 namespace display { |
| 33 class Display; | 34 class Display; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace gfx { | 37 namespace gfx { |
| 37 class Insets; | 38 class Insets; |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace service_manager { | 41 namespace service_manager { |
| 41 class Connector; | 42 class Connector; |
| 42 } | 43 } |
| 43 | 44 |
| 44 namespace aura { | 45 namespace aura { |
| 46 class DragDropControllerMus; |
| 45 class InFlightBoundsChange; | 47 class InFlightBoundsChange; |
| 46 class InFlightCaptureChange; | 48 class InFlightCaptureChange; |
| 47 class InFlightChange; | 49 class InFlightChange; |
| 48 class InFlightFocusChange; | 50 class InFlightFocusChange; |
| 49 class InFlightPropertyChange; | 51 class InFlightPropertyChange; |
| 50 class InFlightVisibleChange; | 52 class InFlightVisibleChange; |
| 51 class WindowMus; | 53 class WindowMus; |
| 52 class WindowPortMus; | 54 class WindowPortMus; |
| 53 struct WindowPortInitData; | 55 struct WindowPortInitData; |
| 54 struct WindowPortPropertyData; | 56 struct WindowPortPropertyData; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 67 // | 69 // |
| 68 // WindowTreeClient is owned by the creator. Generally when the delegate gets | 70 // WindowTreeClient is owned by the creator. Generally when the delegate gets |
| 69 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the | 71 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the |
| 70 // WindowTreeClient. | 72 // WindowTreeClient. |
| 71 // | 73 // |
| 72 // When WindowTreeClient is deleted all windows are deleted (and observers | 74 // When WindowTreeClient is deleted all windows are deleted (and observers |
| 73 // notified). | 75 // notified). |
| 74 class AURA_EXPORT WindowTreeClient | 76 class AURA_EXPORT WindowTreeClient |
| 75 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient), | 77 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient), |
| 76 NON_EXPORTED_BASE(public ui::mojom::WindowManager), | 78 NON_EXPORTED_BASE(public ui::mojom::WindowManager), |
| 79 public DragDropControllerHost, |
| 77 public WindowManagerClient, | 80 public WindowManagerClient, |
| 78 public WindowTreeHostMusDelegate, | 81 public WindowTreeHostMusDelegate, |
| 79 public client::CaptureClientObserver, | 82 public client::CaptureClientObserver, |
| 80 public client::FocusChangeObserver, | 83 public client::FocusChangeObserver, |
| 81 public client::TransientWindowClientObserver { | 84 public client::TransientWindowClientObserver { |
| 82 public: | 85 public: |
| 83 explicit WindowTreeClient( | 86 explicit WindowTreeClient( |
| 84 WindowTreeClientDelegate* delegate, | 87 WindowTreeClientDelegate* delegate, |
| 85 WindowManagerDelegate* window_manager_delegate = nullptr, | 88 WindowManagerDelegate* window_manager_delegate = nullptr, |
| 86 ui::mojom::WindowTreeClientRequest request = nullptr); | 89 ui::mojom::WindowTreeClientRequest request = nullptr); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // Returns the current location of the mouse on screen. Note: this method may | 149 // Returns the current location of the mouse on screen. Note: this method may |
| 147 // race the asynchronous initialization; but in that case we return (0, 0). | 150 // race the asynchronous initialization; but in that case we return (0, 0). |
| 148 gfx::Point GetCursorScreenPoint(); | 151 gfx::Point GetCursorScreenPoint(); |
| 149 | 152 |
| 150 // See description in window_tree.mojom. When an existing pointer watcher is | 153 // See description in window_tree.mojom. When an existing pointer watcher is |
| 151 // updated or cleared then any future events from the server for that watcher | 154 // updated or cleared then any future events from the server for that watcher |
| 152 // will be ignored. | 155 // will be ignored. |
| 153 void StartPointerWatcher(bool want_moves); | 156 void StartPointerWatcher(bool want_moves); |
| 154 void StopPointerWatcher(); | 157 void StopPointerWatcher(); |
| 155 | 158 |
| 156 void PerformDragDrop( | |
| 157 Window* window, | |
| 158 const std::map<std::string, std::vector<uint8_t>>& drag_data, | |
| 159 int drag_operation, | |
| 160 const gfx::Point& cursor_location, | |
| 161 const SkBitmap& bitmap, | |
| 162 const base::Callback<void(bool, uint32_t)>& callback); | |
| 163 | |
| 164 // Cancels a in progress drag drop. (If no drag is in progress, does | |
| 165 // nothing.) | |
| 166 void CancelDragDrop(Window* window); | |
| 167 | |
| 168 // Performs a window move. |callback| will be asynchronously called with the | 159 // Performs a window move. |callback| will be asynchronously called with the |
| 169 // whether the move loop completed successfully. | 160 // whether the move loop completed successfully. |
| 170 void PerformWindowMove(Window* window, | 161 void PerformWindowMove(Window* window, |
| 171 ui::mojom::MoveLoopSource source, | 162 ui::mojom::MoveLoopSource source, |
| 172 const gfx::Point& cursor_location, | 163 const gfx::Point& cursor_location, |
| 173 const base::Callback<void(bool)>& callback); | 164 const base::Callback<void(bool)>& callback); |
| 174 | 165 |
| 175 // Cancels a in progress window move. (If no window is currently being moved, | 166 // Cancels a in progress window move. (If no window is currently being moved, |
| 176 // does nothing.) | 167 // does nothing.) |
| 177 void CancelWindowMove(Window* window); | 168 void CancelWindowMove(Window* window); |
| 178 | 169 |
| 179 void AddObserver(WindowTreeClientObserver* observer); | 170 void AddObserver(WindowTreeClientObserver* observer); |
| 180 void RemoveObserver(WindowTreeClientObserver* observer); | 171 void RemoveObserver(WindowTreeClientObserver* observer); |
| 181 | 172 |
| 182 private: | 173 private: |
| 183 friend class InFlightBoundsChange; | 174 friend class InFlightBoundsChange; |
| 184 friend class InFlightCaptureChange; | 175 friend class InFlightCaptureChange; |
| 185 friend class InFlightFocusChange; | 176 friend class InFlightFocusChange; |
| 186 friend class InFlightPropertyChange; | 177 friend class InFlightPropertyChange; |
| 187 friend class InFlightVisibleChange; | 178 friend class InFlightVisibleChange; |
| 188 friend class WindowPortMus; | 179 friend class WindowPortMus; |
| 189 friend class WindowTreeClientPrivate; | 180 friend class WindowTreeClientPrivate; |
| 190 | 181 |
| 191 struct CurrentDragState; | |
| 192 | |
| 193 using IdToWindowMap = std::map<Id, WindowMus*>; | 182 using IdToWindowMap = std::map<Id, WindowMus*>; |
| 194 | 183 |
| 195 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. | 184 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. |
| 196 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; | 185 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; |
| 197 | 186 |
| 198 void RegisterWindowMus(WindowMus* window); | 187 void RegisterWindowMus(WindowMus* window); |
| 199 | 188 |
| 200 WindowMus* GetWindowByServerId(Id id); | 189 WindowMus* GetWindowByServerId(Id id); |
| 201 | 190 |
| 202 // Returns true if the specified window was created by this client. | 191 // Returns true if the specified window was created by this client. |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 435 |
| 447 // Overriden from WindowTreeHostMusDelegate: | 436 // Overriden from WindowTreeHostMusDelegate: |
| 448 void SetRootWindowBounds(Window* window, gfx::Rect* bounds) override; | 437 void SetRootWindowBounds(Window* window, gfx::Rect* bounds) override; |
| 449 | 438 |
| 450 // Override from client::TransientWindowClientObserver: | 439 // Override from client::TransientWindowClientObserver: |
| 451 void OnTransientChildWindowAdded(Window* parent, | 440 void OnTransientChildWindowAdded(Window* parent, |
| 452 Window* transient_child) override; | 441 Window* transient_child) override; |
| 453 void OnTransientChildWindowRemoved(Window* parent, | 442 void OnTransientChildWindowRemoved(Window* parent, |
| 454 Window* transient_child) override; | 443 Window* transient_child) override; |
| 455 | 444 |
| 445 // Overriden from DragDropControllerHost: |
| 446 uint32_t CreateChangeIdForDrag(WindowMus* window) override; |
| 447 |
| 456 // The one int in |cursor_location_mapping_|. When we read from this | 448 // The one int in |cursor_location_mapping_|. When we read from this |
| 457 // location, we must always read from it atomically. | 449 // location, we must always read from it atomically. |
| 458 base::subtle::Atomic32* cursor_location_memory() { | 450 base::subtle::Atomic32* cursor_location_memory() { |
| 459 return reinterpret_cast<base::subtle::Atomic32*>( | 451 return reinterpret_cast<base::subtle::Atomic32*>( |
| 460 cursor_location_mapping_.get()); | 452 cursor_location_mapping_.get()); |
| 461 } | 453 } |
| 462 | 454 |
| 463 // This is set once and only once when we get OnEmbed(). It gives the unique | 455 // This is set once and only once when we get OnEmbed(). It gives the unique |
| 464 // id for this client. | 456 // id for this client. |
| 465 ClientSpecificId client_id_; | 457 ClientSpecificId client_id_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 uint32_t current_move_loop_change_ = 0u; | 507 uint32_t current_move_loop_change_ = 0u; |
| 516 | 508 |
| 517 // Callback executed when a move loop initiated by PerformWindowMove() is | 509 // Callback executed when a move loop initiated by PerformWindowMove() is |
| 518 // completed. | 510 // completed. |
| 519 base::Callback<void(bool)> on_current_move_finished_; | 511 base::Callback<void(bool)> on_current_move_finished_; |
| 520 | 512 |
| 521 // The current change id for the window manager. | 513 // The current change id for the window manager. |
| 522 uint32_t current_wm_move_loop_change_ = 0u; | 514 uint32_t current_wm_move_loop_change_ = 0u; |
| 523 Id current_wm_move_loop_window_id_ = 0u; | 515 Id current_wm_move_loop_window_id_ = 0u; |
| 524 | 516 |
| 525 // State related to being the initiator of a drag started with | 517 std::unique_ptr<DragDropControllerMus> drag_drop_controller_; |
| 526 // PerformDragDrop(). | |
| 527 std::unique_ptr<CurrentDragState> current_drag_state_; | |
| 528 | |
| 529 // The mus server sends the mime drag data once per connection; we cache this | |
| 530 // and are responsible for sending it to all of our windows. | |
| 531 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_drag_data_; | |
| 532 | |
| 533 // A set of window ids for windows that we received an OnDragEnter() message | |
| 534 // for. We maintain this set so we know who to send OnDragFinish() messages | |
| 535 // at the end of the drag. | |
| 536 std::set<Id> drag_entered_windows_; | |
| 537 | 518 |
| 538 base::WeakPtrFactory<WindowTreeClient> weak_factory_; | 519 base::WeakPtrFactory<WindowTreeClient> weak_factory_; |
| 539 | 520 |
| 540 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); | 521 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); |
| 541 }; | 522 }; |
| 542 | 523 |
| 543 } // namespace aura | 524 } // namespace aura |
| 544 | 525 |
| 545 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ | 526 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ |
| OLD | NEW |