| 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> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient), | 78 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient), |
| 79 NON_EXPORTED_BASE(public ui::mojom::WindowManager), | 79 NON_EXPORTED_BASE(public ui::mojom::WindowManager), |
| 80 public CaptureSynchronizerDelegate, | 80 public CaptureSynchronizerDelegate, |
| 81 public FocusSynchronizerDelegate, | 81 public FocusSynchronizerDelegate, |
| 82 public DragDropControllerHost, | 82 public DragDropControllerHost, |
| 83 public WindowManagerClient, | 83 public WindowManagerClient, |
| 84 public WindowTreeHostMusDelegate, | 84 public WindowTreeHostMusDelegate, |
| 85 public client::TransientWindowClientObserver { | 85 public client::TransientWindowClientObserver { |
| 86 public: | 86 public: |
| 87 explicit WindowTreeClient( | 87 explicit WindowTreeClient( |
| 88 service_manager::Connector* connector, |
| 88 WindowTreeClientDelegate* delegate, | 89 WindowTreeClientDelegate* delegate, |
| 89 WindowManagerDelegate* window_manager_delegate = nullptr, | 90 WindowManagerDelegate* window_manager_delegate = nullptr, |
| 90 ui::mojom::WindowTreeClientRequest request = nullptr); | 91 ui::mojom::WindowTreeClientRequest request = nullptr); |
| 91 ~WindowTreeClient() override; | 92 ~WindowTreeClient() override; |
| 92 | 93 |
| 93 // Establishes the connection by way of the WindowTreeFactory. | 94 // Establishes the connection by way of the WindowTreeFactory. |
| 94 void ConnectViaWindowTreeFactory(service_manager::Connector* connector); | 95 void ConnectViaWindowTreeFactory(); |
| 95 | 96 |
| 96 // Establishes the connection by way of WindowManagerWindowTreeFactory. | 97 // Establishes the connection by way of WindowManagerWindowTreeFactory. |
| 97 void ConnectAsWindowManager(service_manager::Connector* connector); | 98 void ConnectAsWindowManager(); |
| 99 |
| 100 service_manager::Connector* connector() { return connector_; } |
| 98 | 101 |
| 99 bool connected() const { return tree_ != nullptr; } | 102 bool connected() const { return tree_ != nullptr; } |
| 100 ClientSpecificId client_id() const { return client_id_; } | 103 ClientSpecificId client_id() const { return client_id_; } |
| 101 | 104 |
| 102 client::CaptureClient* GetCaptureClient(); | 105 client::CaptureClient* GetCaptureClient(); |
| 103 | 106 |
| 104 void SetCanFocus(Window* window, bool can_focus); | 107 void SetCanFocus(Window* window, bool can_focus); |
| 105 void SetCanAcceptDrops(Id window_id, bool can_accept_drops); | 108 void SetCanAcceptDrops(Id window_id, bool can_accept_drops); |
| 106 void SetCanAcceptEvents(Id window_id, bool can_accept_events); | 109 void SetCanAcceptEvents(Id window_id, bool can_accept_events); |
| 107 void SetPredefinedCursor(WindowMus* window, | 110 void SetPredefinedCursor(WindowMus* window, |
| 108 ui::mojom::Cursor old_cursor, | 111 ui::mojom::Cursor old_cursor, |
| 109 ui::mojom::Cursor new_cursor); | 112 ui::mojom::Cursor new_cursor); |
| 110 void SetWindowTextInputState(WindowMus* window, | 113 void SetWindowTextInputState(WindowMus* window, |
| 111 mojo::TextInputStatePtr state); | 114 mojo::TextInputStatePtr state); |
| 112 void SetImeVisibility(WindowMus* window, | 115 void SetImeVisibility(WindowMus* window, |
| 113 bool visible, | 116 bool visible, |
| 114 mojo::TextInputStatePtr state); | 117 mojo::TextInputStatePtr state); |
| 115 | 118 |
| 116 // TODO: this should take a window, not an id. | 119 // TODO: this should take a window, not an id. |
| 117 void Embed(Id window_id, | 120 void Embed(Id window_id, |
| 118 ui::mojom::WindowTreeClientPtr client, | 121 ui::mojom::WindowTreeClientPtr client, |
| 119 uint32_t flags, | 122 uint32_t flags, |
| 120 const ui::mojom::WindowTree::EmbedCallback& callback); | 123 const ui::mojom::WindowTree::EmbedCallback& callback); |
| 121 | 124 |
| 122 // TODO: this should move to WindowManager. | |
| 123 void RequestClose(Window* window); | |
| 124 | |
| 125 void AttachCompositorFrameSink( | 125 void AttachCompositorFrameSink( |
| 126 Id window_id, | 126 Id window_id, |
| 127 ui::mojom::CompositorFrameSinkType type, | 127 ui::mojom::CompositorFrameSinkType type, |
| 128 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, | 128 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, |
| 129 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 129 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 130 | 130 |
| 131 bool IsRoot(WindowMus* window) const { return roots_.count(window) > 0; } | 131 bool IsRoot(WindowMus* window) const { return roots_.count(window) > 0; } |
| 132 | 132 |
| 133 // Returns the root of this connection. | 133 // Returns the root of this connection. |
| 134 std::set<Window*> GetRoots(); | 134 std::set<Window*> GetRoots(); |
| 135 | 135 |
| 136 // Returns true if the specified window was created by this client. |
| 137 bool WasCreatedByThisClient(const WindowMus* window) const; |
| 138 |
| 136 // Returns the current location of the mouse on screen. Note: this method may | 139 // Returns the current location of the mouse on screen. Note: this method may |
| 137 // race the asynchronous initialization; but in that case we return (0, 0). | 140 // race the asynchronous initialization; but in that case we return (0, 0). |
| 138 gfx::Point GetCursorScreenPoint(); | 141 gfx::Point GetCursorScreenPoint(); |
| 139 | 142 |
| 140 // See description in window_tree.mojom. When an existing pointer watcher is | 143 // See description in window_tree.mojom. When an existing pointer watcher is |
| 141 // updated or cleared then any future events from the server for that watcher | 144 // updated or cleared then any future events from the server for that watcher |
| 142 // will be ignored. | 145 // will be ignored. |
| 143 void StartPointerWatcher(bool want_moves); | 146 void StartPointerWatcher(bool want_moves); |
| 144 void StopPointerWatcher(); | 147 void StopPointerWatcher(); |
| 145 | 148 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 172 | 175 |
| 173 using IdToWindowMap = std::map<Id, WindowMus*>; | 176 using IdToWindowMap = std::map<Id, WindowMus*>; |
| 174 | 177 |
| 175 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. | 178 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. |
| 176 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; | 179 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; |
| 177 | 180 |
| 178 void RegisterWindowMus(WindowMus* window); | 181 void RegisterWindowMus(WindowMus* window); |
| 179 | 182 |
| 180 WindowMus* GetWindowByServerId(Id id); | 183 WindowMus* GetWindowByServerId(Id id); |
| 181 | 184 |
| 182 // Returns true if the specified window was created by this client. | |
| 183 bool WasCreatedByThisClient(const WindowMus* window) const; | |
| 184 | |
| 185 // Returns the oldest InFlightChange that matches |change|. | 185 // Returns the oldest InFlightChange that matches |change|. |
| 186 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change); | 186 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change); |
| 187 | 187 |
| 188 // See InFlightChange for details on how InFlightChanges are used. | 188 // See InFlightChange for details on how InFlightChanges are used. |
| 189 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change); | 189 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change); |
| 190 | 190 |
| 191 // Returns true if there is an InFlightChange that matches |change|. If there | 191 // Returns true if there is an InFlightChange that matches |change|. If there |
| 192 // is an existing change SetRevertValueFrom() is invoked on it. Returns false | 192 // is an existing change SetRevertValueFrom() is invoked on it. Returns false |
| 193 // if there is no InFlightChange matching |change|. | 193 // if there is no InFlightChange matching |change|. |
| 194 // See InFlightChange for details on how InFlightChanges are used. | 194 // See InFlightChange for details on how InFlightChanges are used. |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 ui::mojom::EventMatcherPtr event_matcher, | 404 ui::mojom::EventMatcherPtr event_matcher, |
| 405 const base::Callback<void(bool)>& callback) override; | 405 const base::Callback<void(bool)>& callback) override; |
| 406 void RemoveAccelerator(uint32_t id) override; | 406 void RemoveAccelerator(uint32_t id) override; |
| 407 void AddActivationParent(Window* window) override; | 407 void AddActivationParent(Window* window) override; |
| 408 void RemoveActivationParent(Window* window) override; | 408 void RemoveActivationParent(Window* window) override; |
| 409 void ActivateNextWindow() override; | 409 void ActivateNextWindow() override; |
| 410 void SetUnderlaySurfaceOffsetAndExtendedHitArea( | 410 void SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 411 Window* window, | 411 Window* window, |
| 412 const gfx::Vector2d& offset, | 412 const gfx::Vector2d& offset, |
| 413 const gfx::Insets& hit_area) override; | 413 const gfx::Insets& hit_area) override; |
| 414 void RequestClose(Window* window) override; |
| 414 | 415 |
| 415 // Overriden from WindowTreeHostMusDelegate: | 416 // Overriden from WindowTreeHostMusDelegate: |
| 416 void OnWindowTreeHostBoundsWillChange(WindowTreeHostMus* window_tree_host, | 417 void OnWindowTreeHostBoundsWillChange(WindowTreeHostMus* window_tree_host, |
| 417 const gfx::Rect& bounds) override; | 418 const gfx::Rect& bounds) override; |
| 418 void OnWindowTreeHostClientAreaWillChange( | 419 void OnWindowTreeHostClientAreaWillChange( |
| 419 WindowTreeHostMus* window_tree_host, | 420 WindowTreeHostMus* window_tree_host, |
| 420 const gfx::Insets& client_area, | 421 const gfx::Insets& client_area, |
| 421 const std::vector<gfx::Rect>& additional_client_areas) override; | 422 const std::vector<gfx::Rect>& additional_client_areas) override; |
| 422 void OnWindowTreeHostHitTestMaskWillChange( | 423 void OnWindowTreeHostHitTestMaskWillChange( |
| 423 WindowTreeHostMus* window_tree_host, | 424 WindowTreeHostMus* window_tree_host, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 444 // Overrided from FocusSynchronizerDelegate: | 445 // Overrided from FocusSynchronizerDelegate: |
| 445 uint32_t CreateChangeIdForFocus(WindowMus* window) override; | 446 uint32_t CreateChangeIdForFocus(WindowMus* window) override; |
| 446 | 447 |
| 447 // 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 |
| 448 // location, we must always read from it atomically. | 449 // location, we must always read from it atomically. |
| 449 base::subtle::Atomic32* cursor_location_memory() { | 450 base::subtle::Atomic32* cursor_location_memory() { |
| 450 return reinterpret_cast<base::subtle::Atomic32*>( | 451 return reinterpret_cast<base::subtle::Atomic32*>( |
| 451 cursor_location_mapping_.get()); | 452 cursor_location_mapping_.get()); |
| 452 } | 453 } |
| 453 | 454 |
| 455 // This may be null in tests. |
| 456 service_manager::Connector* connector_; |
| 457 |
| 454 // This is set once and only once when we get OnEmbed(). It gives the unique | 458 // This is set once and only once when we get OnEmbed(). It gives the unique |
| 455 // id for this client. | 459 // id for this client. |
| 456 ClientSpecificId client_id_; | 460 ClientSpecificId client_id_; |
| 457 | 461 |
| 458 // Id assigned to the next window created. | 462 // Id assigned to the next window created. |
| 459 ClientSpecificId next_window_id_; | 463 ClientSpecificId next_window_id_; |
| 460 | 464 |
| 461 // Id used for the next change id supplied to the server. | 465 // Id used for the next change id supplied to the server. |
| 462 uint32_t next_change_id_; | 466 uint32_t next_change_id_; |
| 463 InFlightMap in_flight_map_; | 467 InFlightMap in_flight_map_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 std::unique_ptr<DragDropControllerMus> drag_drop_controller_; | 516 std::unique_ptr<DragDropControllerMus> drag_drop_controller_; |
| 513 | 517 |
| 514 base::WeakPtrFactory<WindowTreeClient> weak_factory_; | 518 base::WeakPtrFactory<WindowTreeClient> weak_factory_; |
| 515 | 519 |
| 516 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); | 520 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); |
| 517 }; | 521 }; |
| 518 | 522 |
| 519 } // namespace aura | 523 } // namespace aura |
| 520 | 524 |
| 521 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ | 525 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ |
| OLD | NEW |