| 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 UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ |
| 6 #define SERVICES_UI_PUBLIC_CPP_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/macros.h" | 18 #include "base/macros.h" |
| 18 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 19 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 20 #include "mojo/public/cpp/bindings/associated_binding.h" | 21 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 21 #include "mojo/public/cpp/bindings/strong_binding.h" | 22 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 22 #include "services/ui/common/types.h" | |
| 23 #include "services/ui/public/cpp/window.h" | |
| 24 #include "services/ui/public/cpp/window_manager_delegate.h" | |
| 25 #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" |
| 25 #include "ui/aura/client/capture_client_observer.h" |
| 26 #include "ui/aura/client/focus_change_observer.h" |
| 27 #include "ui/aura/mus/mus_types.h" |
| 28 #include "ui/aura/mus/window_manager_delegate.h" |
| 26 | 29 |
| 27 namespace display { | 30 namespace display { |
| 28 class Display; | 31 class Display; |
| 29 } | 32 } |
| 30 | 33 |
| 31 namespace gfx { | 34 namespace gfx { |
| 32 class Insets; | 35 class Insets; |
| 33 class Size; | |
| 34 } | 36 } |
| 35 | 37 |
| 36 namespace service_manager { | 38 namespace service_manager { |
| 37 class Connector; | 39 class Connector; |
| 38 } | 40 } |
| 39 | 41 |
| 40 namespace ui { | 42 namespace aura { |
| 43 class InFlightCaptureChange; |
| 41 class InFlightChange; | 44 class InFlightChange; |
| 45 class InFlightFocusChange; |
| 46 class InFlightPropertyChange; |
| 47 class WindowMus; |
| 48 class WindowPortMus; |
| 49 struct WindowPortInitData; |
| 50 struct WindowPortPropertyData; |
| 42 class WindowTreeClientDelegate; | 51 class WindowTreeClientDelegate; |
| 43 class WindowTreeClientPrivate; | 52 class WindowTreeClientPrivate; |
| 44 class WindowTreeClientObserver; | 53 class WindowTreeClientObserver; |
| 45 enum class ChangeType; | 54 class WindowTreeHost; |
| 55 |
| 56 namespace client { |
| 57 class FocusClient; |
| 58 } |
| 59 |
| 60 using EventResultCallback = base::Callback<void(ui::mojom::EventResult)>; |
| 46 | 61 |
| 47 // Manages the connection with mus. | 62 // Manages the connection with mus. |
| 48 // | 63 // |
| 49 // WindowTreeClient is owned by the creator. Generally when the delegate gets | 64 // WindowTreeClient is owned by the creator. Generally when the delegate gets |
| 50 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the | 65 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the |
| 51 // WindowTreeClient. | 66 // WindowTreeClient. |
| 52 // | 67 // |
| 53 // When WindowTreeClient is deleted all windows are deleted (and observers | 68 // When WindowTreeClient is deleted all windows are deleted (and observers |
| 54 // notified). | 69 // notified). |
| 55 class WindowTreeClient : public mojom::WindowTreeClient, | 70 class AURA_EXPORT WindowTreeClient |
| 56 public mojom::WindowManager, | 71 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient), |
| 57 public WindowManagerClient { | 72 NON_EXPORTED_BASE(public ui::mojom::WindowManager), |
| 73 public WindowManagerClient, |
| 74 public client::CaptureClientObserver, |
| 75 public client::FocusChangeObserver { |
| 58 public: | 76 public: |
| 59 explicit WindowTreeClient( | 77 explicit WindowTreeClient( |
| 60 WindowTreeClientDelegate* delegate, | 78 WindowTreeClientDelegate* delegate, |
| 61 WindowManagerDelegate* window_manager_delegate = nullptr, | 79 WindowManagerDelegate* window_manager_delegate = nullptr, |
| 62 mojom::WindowTreeClientRequest request = nullptr); | 80 ui::mojom::WindowTreeClientRequest request = nullptr); |
| 63 ~WindowTreeClient() override; | 81 ~WindowTreeClient() override; |
| 64 | 82 |
| 65 // Establishes the connection by way of the WindowTreeFactory. | 83 // Establishes the connection by way of the WindowTreeFactory. |
| 66 void ConnectViaWindowTreeFactory(service_manager::Connector* connector); | 84 void ConnectViaWindowTreeFactory(service_manager::Connector* connector); |
| 67 | 85 |
| 68 // Establishes the connection by way of WindowManagerWindowTreeFactory. | 86 // Establishes the connection by way of WindowManagerWindowTreeFactory. |
| 69 void ConnectAsWindowManager(service_manager::Connector* connector); | 87 void ConnectAsWindowManager(service_manager::Connector* connector); |
| 70 | 88 |
| 71 // Wait for OnEmbed(), returning when done. | 89 // Wait for OnEmbed(), returning when done. |
| 72 void WaitForEmbed(); | 90 void WaitForEmbed(); |
| 73 | 91 |
| 74 bool connected() const { return tree_ != nullptr; } | 92 bool connected() const { return tree_ != nullptr; } |
| 75 ClientSpecificId client_id() const { return client_id_; } | 93 ClientSpecificId client_id() const { return client_id_; } |
| 76 | 94 |
| 77 // API exposed to the window implementations that pushes local changes to the | 95 void SetClientArea(Window* window, |
| 78 // service. | |
| 79 void DestroyWindow(Window* window); | |
| 80 | |
| 81 // These methods take TransportIds. For windows owned by the current client, | |
| 82 // the client id high word can be zero. In all cases, the TransportId 0x1 | |
| 83 // refers to the root window. | |
| 84 void AddChild(Window* parent, Id child_id); | |
| 85 void RemoveChild(Window* parent, Id child_id); | |
| 86 | |
| 87 void AddTransientWindow(Window* window, Id transient_window_id); | |
| 88 void RemoveTransientWindowFromParent(Window* window); | |
| 89 | |
| 90 void SetModal(Window* window); | |
| 91 | |
| 92 void Reorder(Window* window, | |
| 93 Id relative_window_id, | |
| 94 mojom::OrderDirection direction); | |
| 95 | |
| 96 // Returns true if the specified window was created by this client. | |
| 97 bool WasCreatedByThisClient(const Window* window) const; | |
| 98 | |
| 99 void SetBounds(Window* window, | |
| 100 const gfx::Rect& old_bounds, | |
| 101 const gfx::Rect& bounds); | |
| 102 void SetCapture(Window* window); | |
| 103 void ReleaseCapture(Window* window); | |
| 104 void SetClientArea(Id window_id, | |
| 105 const gfx::Insets& client_area, | 96 const gfx::Insets& client_area, |
| 106 const std::vector<gfx::Rect>& additional_client_areas); | 97 const std::vector<gfx::Rect>& additional_client_areas); |
| 107 void SetHitTestMask(Id window_id, const gfx::Rect& mask); | 98 void SetHitTestMask(Window* window, const gfx::Rect& mask); |
| 108 void ClearHitTestMask(Id window_id); | 99 void ClearHitTestMask(Window* window); |
| 109 void SetFocus(Window* window); | 100 void SetCanFocus(Window* window, bool can_focus); |
| 110 void SetCanFocus(Id window_id, bool can_focus); | |
| 111 void SetCanAcceptDrops(Id window_id, bool can_accept_drops); | 101 void SetCanAcceptDrops(Id window_id, bool can_accept_drops); |
| 112 void SetCanAcceptEvents(Id window_id, bool can_accept_events); | 102 void SetCanAcceptEvents(Id window_id, bool can_accept_events); |
| 113 void SetPredefinedCursor(Id window_id, ui::mojom::Cursor cursor_id); | 103 void SetPredefinedCursor(WindowMus* window, |
| 114 void SetVisible(Window* window, bool visible); | 104 ui::mojom::Cursor old_cursor, |
| 115 void SetOpacity(Window* window, float opacity); | 105 ui::mojom::Cursor new_cursor); |
| 116 void SetProperty(Window* window, | 106 void SetWindowTextInputState(WindowMus* window, |
| 117 const std::string& name, | 107 mojo::TextInputStatePtr state); |
| 118 mojo::Array<uint8_t> data); | 108 void SetImeVisibility(WindowMus* window, |
| 119 void SetWindowTextInputState(Id window_id, mojo::TextInputStatePtr state); | |
| 120 void SetImeVisibility(Id window_id, | |
| 121 bool visible, | 109 bool visible, |
| 122 mojo::TextInputStatePtr state); | 110 mojo::TextInputStatePtr state); |
| 123 | 111 |
| 112 // TODO: this should take a window, not an id. |
| 124 void Embed(Id window_id, | 113 void Embed(Id window_id, |
| 125 mojom::WindowTreeClientPtr client, | 114 ui::mojom::WindowTreeClientPtr client, |
| 126 uint32_t flags, | 115 uint32_t flags, |
| 127 const mojom::WindowTree::EmbedCallback& callback); | 116 const ui::mojom::WindowTree::EmbedCallback& callback); |
| 128 | 117 |
| 118 // TODO: this should move to WindowManager. |
| 129 void RequestClose(Window* window); | 119 void RequestClose(Window* window); |
| 130 | 120 |
| 131 void AttachCompositorFrameSink( | 121 void AttachCompositorFrameSink( |
| 132 Id window_id, | 122 Id window_id, |
| 133 mojom::CompositorFrameSinkType type, | 123 ui::mojom::CompositorFrameSinkType type, |
| 134 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, | 124 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, |
| 135 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 125 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 136 | 126 |
| 137 void OnWindowSurfaceDetached(Id window_id, | 127 bool IsRoot(WindowMus* window) const { return roots_.count(window) > 0; } |
| 138 const cc::SurfaceSequence& sequence); | |
| 139 | |
| 140 // Sets the input capture to |window| without notifying the server. | |
| 141 void LocalSetCapture(Window* window); | |
| 142 // Sets focus to |window| without notifying the server. | |
| 143 void LocalSetFocus(Window* window); | |
| 144 | |
| 145 // Start/stop tracking windows. While tracked, they can be retrieved via | |
| 146 // WindowTreeClient::GetWindowById. | |
| 147 void AddWindow(Window* window); | |
| 148 | |
| 149 bool IsRoot(Window* window) const { return roots_.count(window) > 0; } | |
| 150 | |
| 151 void OnWindowDestroying(Window* window); | |
| 152 | |
| 153 // Called after the window's observers have been notified of destruction (as | |
| 154 // the last step of ~Window). | |
| 155 void OnWindowDestroyed(Window* window); | |
| 156 | |
| 157 Window* GetWindowByServerId(Id id); | |
| 158 | 128 |
| 159 // Returns the root of this connection. | 129 // Returns the root of this connection. |
| 160 const std::set<Window*>& GetRoots(); | 130 std::set<Window*> GetRoots(); |
| 161 | 131 |
| 162 // Returns the Window with input capture; null if no window has requested | 132 // Returns the Window with input capture; null if no window has requested |
| 163 // input capture, or if another app has capture. | 133 // input capture, or if another app has capture. |
| 164 Window* GetCaptureWindow(); | 134 Window* GetCaptureWindow(); |
| 165 | 135 |
| 166 // Returns the focused window; null if focus is not yet known or another app | 136 // Returns the focused window; null if focus is not yet known or another app |
| 167 // is focused. | 137 // is focused. |
| 168 Window* GetFocusedWindow(); | 138 Window* GetFocusedWindow(); |
| 169 | 139 |
| 170 // Sets focus to null. This does nothing if focus is currently null. | |
| 171 void ClearFocus(); | |
| 172 | |
| 173 // Returns the current location of the mouse on screen. Note: this method may | 140 // Returns the current location of the mouse on screen. Note: this method may |
| 174 // race the asynchronous initialization; but in that case we return (0, 0). | 141 // race the asynchronous initialization; but in that case we return (0, 0). |
| 175 gfx::Point GetCursorScreenPoint(); | 142 gfx::Point GetCursorScreenPoint(); |
| 176 | 143 |
| 177 // See description in window_tree.mojom. When an existing pointer watcher is | 144 // See description in window_tree.mojom. When an existing pointer watcher is |
| 178 // updated or cleared then any future events from the server for that watcher | 145 // updated or cleared then any future events from the server for that watcher |
| 179 // will be ignored. | 146 // will be ignored. |
| 180 void StartPointerWatcher(bool want_moves); | 147 void StartPointerWatcher(bool want_moves); |
| 181 void StopPointerWatcher(); | 148 void StopPointerWatcher(); |
| 182 | 149 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 196 // whether the move loop completed successfully. | 163 // whether the move loop completed successfully. |
| 197 void PerformWindowMove(Window* window, | 164 void PerformWindowMove(Window* window, |
| 198 ui::mojom::MoveLoopSource source, | 165 ui::mojom::MoveLoopSource source, |
| 199 const gfx::Point& cursor_location, | 166 const gfx::Point& cursor_location, |
| 200 const base::Callback<void(bool)>& callback); | 167 const base::Callback<void(bool)>& callback); |
| 201 | 168 |
| 202 // Cancels a in progress window move. (If no window is currently being moved, | 169 // Cancels a in progress window move. (If no window is currently being moved, |
| 203 // does nothing.) | 170 // does nothing.) |
| 204 void CancelWindowMove(Window* window); | 171 void CancelWindowMove(Window* window); |
| 205 | 172 |
| 206 // Creates and returns a new Window (which is owned by the window server). | |
| 207 // Windows are initially hidden, use SetVisible(true) to show. | |
| 208 Window* NewWindow() { return NewWindow(nullptr); } | |
| 209 Window* NewWindow( | |
| 210 const std::map<std::string, std::vector<uint8_t>>* properties); | |
| 211 Window* NewTopLevelWindow( | |
| 212 const std::map<std::string, std::vector<uint8_t>>* properties); | |
| 213 | |
| 214 void AddObserver(WindowTreeClientObserver* observer); | 173 void AddObserver(WindowTreeClientObserver* observer); |
| 215 void RemoveObserver(WindowTreeClientObserver* observer); | 174 void RemoveObserver(WindowTreeClientObserver* observer); |
| 216 | 175 |
| 217 #if !defined(NDEBUG) | 176 private: |
| 218 std::string GetDebugWindowHierarchy() const; | 177 friend class InFlightCaptureChange; |
| 219 void BuildDebugInfo(const std::string& depth, | 178 friend class InFlightFocusChange; |
| 220 Window* window, | 179 friend class InFlightPropertyChange; |
| 221 std::string* result) const; | 180 friend class WindowPortMus; |
| 222 #endif | 181 friend class WindowTreeClientPrivate; |
| 223 | 182 |
| 224 private: | 183 enum class WindowTreeHostType { EMBED, TOP_LEVEL, DISPLAY }; |
| 225 friend class WindowTreeClientPrivate; | |
| 226 | 184 |
| 227 struct CurrentDragState; | 185 struct CurrentDragState; |
| 228 | 186 |
| 229 enum class NewWindowType { | 187 using IdToWindowMap = std::map<Id, WindowMus*>; |
| 230 CHILD, | |
| 231 TOP_LEVEL, | |
| 232 }; | |
| 233 | |
| 234 using IdToWindowMap = std::map<Id, Window*>; | |
| 235 | 188 |
| 236 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. | 189 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. |
| 237 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; | 190 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; |
| 238 | 191 |
| 192 void RegisterWindowMus(WindowMus* window); |
| 193 |
| 194 WindowMus* GetWindowByServerId(Id id); |
| 195 |
| 196 // Returns true if the specified window was created by this client. |
| 197 bool WasCreatedByThisClient(const WindowMus* window) const; |
| 198 |
| 199 void SetFocusFromServer(WindowMus* window); |
| 200 void SetFocusFromServerImpl(client::FocusClient* focus_client, |
| 201 WindowMus* window); |
| 202 |
| 203 void SetCaptureFromServer(WindowMus* window); |
| 204 |
| 239 // Returns the oldest InFlightChange that matches |change|. | 205 // Returns the oldest InFlightChange that matches |change|. |
| 240 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change); | 206 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change); |
| 241 | 207 |
| 242 // See InFlightChange for details on how InFlightChanges are used. | 208 // See InFlightChange for details on how InFlightChanges are used. |
| 243 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change); | 209 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change); |
| 244 | 210 |
| 245 // Returns true if there is an InFlightChange that matches |change|. If there | 211 // Returns true if there is an InFlightChange that matches |change|. If there |
| 246 // is an existing change SetRevertValueFrom() is invoked on it. Returns false | 212 // is an existing change SetRevertValueFrom() is invoked on it. Returns false |
| 247 // if there is no InFlightChange matching |change|. | 213 // if there is no InFlightChange matching |change|. |
| 248 // See InFlightChange for details on how InFlightChanges are used. | 214 // See InFlightChange for details on how InFlightChanges are used. |
| 249 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change); | 215 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change); |
| 250 | 216 |
| 251 static Id server_id(const Window* window) { return window->server_id(); } | 217 void BuildWindowTree(const mojo::Array<ui::mojom::WindowDataPtr>& windows, |
| 218 WindowMus* initial_parent); |
| 252 | 219 |
| 253 Window* BuildWindowTree(const mojo::Array<mojom::WindowDataPtr>& windows, | 220 // Creates a WindowPortMus from the server side data. |
| 254 Window* initial_parent); | 221 // NOTE: this *must* be followed by SetLocalPropertiesFromServerProperties() |
| 222 std::unique_ptr<WindowPortMus> CreateWindowPortMus( |
| 223 const ui::mojom::WindowDataPtr& window_data); |
| 255 | 224 |
| 256 Window* NewWindowImpl(NewWindowType type, | 225 // Sets local properties on the associated Window from the server properties. |
| 257 const Window::SharedProperties* properties); | 226 void SetLocalPropertiesFromServerProperties( |
| 227 WindowMus* window, |
| 228 const ui::mojom::WindowDataPtr& window_data); |
| 258 | 229 |
| 259 // Sets the mojom::WindowTree implementation. | 230 // Creates a WindowTreeHostMus and returns the window associated with it. |
| 260 void SetWindowTree(mojom::WindowTreePtr window_tree_ptr); | 231 // The returned window is either the content window of the WindowTreeHostMus |
| 232 // or the window created by WindowTreeHost. See WindowTreeHostMus for |
| 233 // details. |
| 234 // TODO(sky): it would be nice to always have a single window and not the |
| 235 // two different. That requires ownership changes to WindowTreeHost though. |
| 236 Window* CreateWindowTreeHost(WindowTreeHostType type, |
| 237 const ui::mojom::WindowDataPtr& window_data, |
| 238 Window* content_window); |
| 261 | 239 |
| 262 // Called when the mojom::WindowTree connection is lost, deletes this. | 240 WindowMus* NewWindowFromWindowData( |
| 241 WindowMus* parent, |
| 242 const ui::mojom::WindowDataPtr& window_data); |
| 243 |
| 244 // Sets the ui::mojom::WindowTree implementation. |
| 245 void SetWindowTree(ui::mojom::WindowTreePtr window_tree_ptr); |
| 246 |
| 247 // Called when the ui::mojom::WindowTree connection is lost, deletes this. |
| 263 void OnConnectionLost(); | 248 void OnConnectionLost(); |
| 264 | 249 |
| 265 // OnEmbed() calls into this. Exposed as a separate function for testing. | 250 // OnEmbed() calls into this. Exposed as a separate function for testing. |
| 266 void OnEmbedImpl(mojom::WindowTree* window_tree, | 251 void OnEmbedImpl(ui::mojom::WindowTree* window_tree, |
| 267 ClientSpecificId client_id, | 252 ClientSpecificId client_id, |
| 268 mojom::WindowDataPtr root_data, | 253 ui::mojom::WindowDataPtr root_data, |
| 269 int64_t display_id, | 254 int64_t display_id, |
| 270 Id focused_window_id, | 255 Id focused_window_id, |
| 271 bool drawn); | 256 bool drawn); |
| 272 | 257 |
| 273 // Called by WmNewDisplayAdded(). | 258 // Called by WmNewDisplayAdded(). |
| 274 void WmNewDisplayAddedImpl(const display::Display& display, | 259 WindowTreeHost* WmNewDisplayAddedImpl(const display::Display& display, |
| 275 mojom::WindowDataPtr root_data, | 260 ui::mojom::WindowDataPtr root_data, |
| 276 bool parent_drawn); | 261 bool parent_drawn); |
| 262 |
| 263 std::unique_ptr<EventResultCallback> CreateEventResultCallback( |
| 264 int32_t event_id); |
| 277 | 265 |
| 278 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle); | 266 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle); |
| 279 | 267 |
| 268 // Following are called from WindowMus. |
| 269 std::unique_ptr<WindowPortInitData> OnWindowMusCreated(WindowMus* window); |
| 270 void OnWindowMusInitDone(WindowMus* window, |
| 271 std::unique_ptr<WindowPortInitData> init_data); |
| 272 void OnWindowMusDestroyed(WindowMus* window); |
| 273 void OnWindowMusBoundsChanged(WindowMus* window, |
| 274 const gfx::Rect& old_bounds, |
| 275 const gfx::Rect& new_bounds); |
| 276 void OnWindowMusAddChild(WindowMus* parent, WindowMus* child); |
| 277 void OnWindowMusRemoveChild(WindowMus* parent, WindowMus* child); |
| 278 void OnWindowMusMoveChild(WindowMus* parent, |
| 279 size_t current_index, |
| 280 size_t dest_index); |
| 281 void OnWindowMusSetVisible(WindowMus* window, bool visible); |
| 282 std::unique_ptr<WindowPortPropertyData> OnWindowMusWillChangeProperty( |
| 283 WindowMus* window, |
| 284 const void* key); |
| 285 void OnWindowMusPropertyChanged(WindowMus* window, |
| 286 const void* key, |
| 287 std::unique_ptr<WindowPortPropertyData> data); |
| 288 void OnWindowMusSurfaceDetached(WindowMus* window, |
| 289 const cc::SurfaceSequence& sequence); |
| 290 |
| 280 // Callback passed from WmPerformMoveLoop(). | 291 // Callback passed from WmPerformMoveLoop(). |
| 281 void OnWmMoveLoopCompleted(uint32_t change_id, bool completed); | 292 void OnWmMoveLoopCompleted(uint32_t change_id, bool completed); |
| 282 | 293 |
| 283 // Overridden from WindowTreeClient: | 294 // Overridden from WindowTreeClient: |
| 284 void OnEmbed(ClientSpecificId client_id, | 295 void OnEmbed(ClientSpecificId client_id, |
| 285 mojom::WindowDataPtr root, | 296 ui::mojom::WindowDataPtr root, |
| 286 mojom::WindowTreePtr tree, | 297 ui::mojom::WindowTreePtr tree, |
| 287 int64_t display_id, | 298 int64_t display_id, |
| 288 Id focused_window_id, | 299 Id focused_window_id, |
| 289 bool drawn) override; | 300 bool drawn) override; |
| 290 void OnEmbeddedAppDisconnected(Id window_id) override; | 301 void OnEmbeddedAppDisconnected(Id window_id) override; |
| 291 void OnUnembed(Id window_id) override; | 302 void OnUnembed(Id window_id) override; |
| 292 void OnCaptureChanged(Id new_capture_window_id, | 303 void OnCaptureChanged(Id new_capture_window_id, |
| 293 Id old_capture_window_id) override; | 304 Id old_capture_window_id) override; |
| 294 void OnTopLevelCreated(uint32_t change_id, | 305 void OnTopLevelCreated(uint32_t change_id, |
| 295 mojom::WindowDataPtr data, | 306 ui::mojom::WindowDataPtr data, |
| 296 int64_t display_id, | 307 int64_t display_id, |
| 297 bool drawn) override; | 308 bool drawn) override; |
| 298 void OnWindowBoundsChanged(Id window_id, | 309 void OnWindowBoundsChanged(Id window_id, |
| 299 const gfx::Rect& old_bounds, | 310 const gfx::Rect& old_bounds, |
| 300 const gfx::Rect& new_bounds) override; | 311 const gfx::Rect& new_bounds) override; |
| 301 void OnClientAreaChanged( | 312 void OnClientAreaChanged( |
| 302 uint32_t window_id, | 313 uint32_t window_id, |
| 303 const gfx::Insets& new_client_area, | 314 const gfx::Insets& new_client_area, |
| 304 mojo::Array<gfx::Rect> new_additional_client_areas) override; | 315 mojo::Array<gfx::Rect> new_additional_client_areas) override; |
| 305 void OnTransientWindowAdded(uint32_t window_id, | 316 void OnTransientWindowAdded(uint32_t window_id, |
| 306 uint32_t transient_window_id) override; | 317 uint32_t transient_window_id) override; |
| 307 void OnTransientWindowRemoved(uint32_t window_id, | 318 void OnTransientWindowRemoved(uint32_t window_id, |
| 308 uint32_t transient_window_id) override; | 319 uint32_t transient_window_id) override; |
| 309 void OnWindowHierarchyChanged( | 320 void OnWindowHierarchyChanged( |
| 310 Id window_id, | 321 Id window_id, |
| 311 Id old_parent_id, | 322 Id old_parent_id, |
| 312 Id new_parent_id, | 323 Id new_parent_id, |
| 313 mojo::Array<mojom::WindowDataPtr> windows) override; | 324 mojo::Array<ui::mojom::WindowDataPtr> windows) override; |
| 314 void OnWindowReordered(Id window_id, | 325 void OnWindowReordered(Id window_id, |
| 315 Id relative_window_id, | 326 Id relative_window_id, |
| 316 mojom::OrderDirection direction) override; | 327 ui::mojom::OrderDirection direction) override; |
| 317 void OnWindowDeleted(Id window_id) override; | 328 void OnWindowDeleted(Id window_id) override; |
| 318 void OnWindowVisibilityChanged(Id window_id, bool visible) override; | 329 void OnWindowVisibilityChanged(Id window_id, bool visible) override; |
| 319 void OnWindowOpacityChanged(Id window_id, | 330 void OnWindowOpacityChanged(Id window_id, |
| 320 float old_opacity, | 331 float old_opacity, |
| 321 float new_opacity) override; | 332 float new_opacity) override; |
| 322 void OnWindowParentDrawnStateChanged(Id window_id, bool drawn) override; | 333 void OnWindowParentDrawnStateChanged(Id window_id, bool drawn) override; |
| 323 void OnWindowSharedPropertyChanged(Id window_id, | 334 void OnWindowSharedPropertyChanged( |
| 324 const mojo::String& name, | 335 Id window_id, |
| 325 mojo::Array<uint8_t> new_data) override; | 336 const mojo::String& name, |
| 337 mojo::Array<uint8_t> transport_data) override; |
| 326 void OnWindowInputEvent(uint32_t event_id, | 338 void OnWindowInputEvent(uint32_t event_id, |
| 327 Id window_id, | 339 Id window_id, |
| 328 std::unique_ptr<ui::Event> event, | 340 std::unique_ptr<ui::Event> event, |
| 329 bool matches_pointer_watcher) override; | 341 bool matches_pointer_watcher) override; |
| 330 void OnPointerEventObserved(std::unique_ptr<ui::Event> event, | 342 void OnPointerEventObserved(std::unique_ptr<ui::Event> event, |
| 331 uint32_t window_id) override; | 343 uint32_t window_id) override; |
| 332 void OnWindowFocused(Id focused_window_id) override; | 344 void OnWindowFocused(Id focused_window_id) override; |
| 333 void OnWindowPredefinedCursorChanged(Id window_id, | 345 void OnWindowPredefinedCursorChanged(Id window_id, |
| 334 mojom::Cursor cursor) override; | 346 ui::mojom::Cursor cursor) override; |
| 335 void OnWindowSurfaceChanged(Id window_id, | 347 void OnWindowSurfaceChanged(Id window_id, |
| 336 const cc::SurfaceId& surface_id, | 348 const cc::SurfaceId& surface_id, |
| 337 const cc::SurfaceSequence& surface_sequence, | 349 const cc::SurfaceSequence& surface_sequence, |
| 338 const gfx::Size& frame_size, | 350 const gfx::Size& frame_size, |
| 339 float device_scale_factor) override; | 351 float device_scale_factor) override; |
| 340 void OnDragDropStart( | 352 void OnDragDropStart( |
| 341 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) override; | 353 mojo::Map<mojo::String, mojo::Array<uint8_t>> mime_data) override; |
| 342 void OnDragEnter(Id window_id, | 354 void OnDragEnter(Id window_id, |
| 343 uint32_t event_flags, | 355 uint32_t event_flags, |
| 344 const gfx::Point& position, | 356 const gfx::Point& position, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 360 uint32_t action_taken) override; | 372 uint32_t action_taken) override; |
| 361 void OnDragDropDone() override; | 373 void OnDragDropDone() override; |
| 362 void OnChangeCompleted(uint32_t change_id, bool success) override; | 374 void OnChangeCompleted(uint32_t change_id, bool success) override; |
| 363 void RequestClose(uint32_t window_id) override; | 375 void RequestClose(uint32_t window_id) override; |
| 364 void GetWindowManager( | 376 void GetWindowManager( |
| 365 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; | 377 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; |
| 366 | 378 |
| 367 // Overridden from WindowManager: | 379 // Overridden from WindowManager: |
| 368 void OnConnect(ClientSpecificId client_id) override; | 380 void OnConnect(ClientSpecificId client_id) override; |
| 369 void WmNewDisplayAdded(const display::Display& display, | 381 void WmNewDisplayAdded(const display::Display& display, |
| 370 mojom::WindowDataPtr root_data, | 382 ui::mojom::WindowDataPtr root_data, |
| 371 bool parent_drawn) override; | 383 bool parent_drawn) override; |
| 372 void WmDisplayRemoved(int64_t display_id) override; | 384 void WmDisplayRemoved(int64_t display_id) override; |
| 373 void WmDisplayModified(const display::Display& display) override; | 385 void WmDisplayModified(const display::Display& display) override; |
| 374 void WmSetBounds(uint32_t change_id, | 386 void WmSetBounds(uint32_t change_id, |
| 375 Id window_id, | 387 Id window_id, |
| 376 const gfx::Rect& transit_bounds) override; | 388 const gfx::Rect& transit_bounds) override; |
| 377 void WmSetProperty(uint32_t change_id, | 389 void WmSetProperty(uint32_t change_id, |
| 378 Id window_id, | 390 Id window_id, |
| 379 const mojo::String& name, | 391 const mojo::String& name, |
| 380 mojo::Array<uint8_t> transit_data) override; | 392 mojo::Array<uint8_t> transit_data) override; |
| 381 void WmCreateTopLevelWindow(uint32_t change_id, | 393 void WmCreateTopLevelWindow(uint32_t change_id, |
| 382 ClientSpecificId requesting_client_id, | 394 ClientSpecificId requesting_client_id, |
| 383 mojo::Map<mojo::String, mojo::Array<uint8_t>> | 395 mojo::Map<mojo::String, mojo::Array<uint8_t>> |
| 384 transport_properties) override; | 396 transport_properties) override; |
| 385 void WmClientJankinessChanged(ClientSpecificId client_id, | 397 void WmClientJankinessChanged(ClientSpecificId client_id, |
| 386 bool janky) override; | 398 bool janky) override; |
| 387 void WmPerformMoveLoop(uint32_t change_id, | 399 void WmPerformMoveLoop(uint32_t change_id, |
| 388 Id window_id, | 400 Id window_id, |
| 389 mojom::MoveLoopSource source, | 401 ui::mojom::MoveLoopSource source, |
| 390 const gfx::Point& cursor_location) override; | 402 const gfx::Point& cursor_location) override; |
| 391 void WmCancelMoveLoop(uint32_t window_id) override; | 403 void WmCancelMoveLoop(uint32_t window_id) override; |
| 392 void OnAccelerator(uint32_t ack_id, | 404 void OnAccelerator(uint32_t ack_id, |
| 393 uint32_t accelerator_id, | 405 uint32_t accelerator_id, |
| 394 std::unique_ptr<ui::Event> event) override; | 406 std::unique_ptr<ui::Event> event) override; |
| 395 | 407 |
| 396 // Overridden from WindowManagerClient: | 408 // Overridden from WindowManagerClient: |
| 397 void SetFrameDecorationValues( | 409 void SetFrameDecorationValues( |
| 398 mojom::FrameDecorationValuesPtr values) override; | 410 ui::mojom::FrameDecorationValuesPtr values) override; |
| 399 void SetNonClientCursor(Window* window, ui::mojom::Cursor cursor_id) override; | 411 void SetNonClientCursor(Window* window, ui::mojom::Cursor cursor_id) override; |
| 400 void AddAccelerator(uint32_t id, | 412 void AddAccelerator(uint32_t id, |
| 401 mojom::EventMatcherPtr event_matcher, | 413 ui::mojom::EventMatcherPtr event_matcher, |
| 402 const base::Callback<void(bool)>& callback) override; | 414 const base::Callback<void(bool)>& callback) override; |
| 403 void RemoveAccelerator(uint32_t id) override; | 415 void RemoveAccelerator(uint32_t id) override; |
| 404 void AddActivationParent(Window* window) override; | 416 void AddActivationParent(Window* window) override; |
| 405 void RemoveActivationParent(Window* window) override; | 417 void RemoveActivationParent(Window* window) override; |
| 406 void ActivateNextWindow() override; | 418 void ActivateNextWindow() override; |
| 407 void SetUnderlaySurfaceOffsetAndExtendedHitArea( | 419 void SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 408 Window* window, | 420 Window* window, |
| 409 const gfx::Vector2d& offset, | 421 const gfx::Vector2d& offset, |
| 410 const gfx::Insets& hit_area) override; | 422 const gfx::Insets& hit_area) override; |
| 411 | 423 |
| 424 // Overriden from client::FocusChangeObserver: |
| 425 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override; |
| 426 |
| 427 // Overriden from client::CaptureClientObserver: |
| 428 void OnCaptureChanged(Window* lost_capture, Window* gained_capture) override; |
| 429 |
| 412 // The one int in |cursor_location_mapping_|. When we read from this | 430 // The one int in |cursor_location_mapping_|. When we read from this |
| 413 // location, we must always read from it atomically. | 431 // location, we must always read from it atomically. |
| 414 base::subtle::Atomic32* cursor_location_memory() { | 432 base::subtle::Atomic32* cursor_location_memory() { |
| 415 return reinterpret_cast<base::subtle::Atomic32*>( | 433 return reinterpret_cast<base::subtle::Atomic32*>( |
| 416 cursor_location_mapping_.get()); | 434 cursor_location_mapping_.get()); |
| 417 } | 435 } |
| 418 | 436 |
| 419 // This is set once and only once when we get OnEmbed(). It gives the unique | 437 // This is set once and only once when we get OnEmbed(). It gives the unique |
| 420 // id for this client. | 438 // id for this client. |
| 421 ClientSpecificId client_id_; | 439 ClientSpecificId client_id_; |
| 422 | 440 |
| 423 // Id assigned to the next window created. | 441 // Id assigned to the next window created. |
| 424 ClientSpecificId next_window_id_; | 442 ClientSpecificId next_window_id_; |
| 425 | 443 |
| 426 // Id used for the next change id supplied to the server. | 444 // Id used for the next change id supplied to the server. |
| 427 uint32_t next_change_id_; | 445 uint32_t next_change_id_; |
| 428 InFlightMap in_flight_map_; | 446 InFlightMap in_flight_map_; |
| 429 | 447 |
| 430 WindowTreeClientDelegate* delegate_; | 448 WindowTreeClientDelegate* delegate_; |
| 431 | 449 |
| 432 WindowManagerDelegate* window_manager_delegate_; | 450 WindowManagerDelegate* window_manager_delegate_; |
| 433 | 451 |
| 434 std::set<Window*> roots_; | 452 std::set<WindowMus*> roots_; |
| 435 | 453 |
| 436 IdToWindowMap windows_; | 454 IdToWindowMap windows_; |
| 437 std::map<ClientSpecificId, std::set<Window*>> embedded_windows_; | 455 std::map<ClientSpecificId, std::set<Window*>> embedded_windows_; |
| 438 | 456 |
| 439 Window* capture_window_; | 457 bool setting_capture_ = false; |
| 458 WindowMus* window_setting_capture_to_ = nullptr; |
| 459 WindowMus* capture_window_ = nullptr; |
| 440 | 460 |
| 441 Window* focused_window_; | 461 bool setting_focus_ = false; |
| 462 WindowMus* window_setting_focus_to_ = nullptr; |
| 463 WindowMus* focused_window_ = nullptr; |
| 442 | 464 |
| 443 mojo::Binding<mojom::WindowTreeClient> binding_; | 465 mojo::Binding<ui::mojom::WindowTreeClient> binding_; |
| 444 mojom::WindowTreePtr tree_ptr_; | 466 ui::mojom::WindowTreePtr tree_ptr_; |
| 445 // Typically this is the value contained in |tree_ptr_|, but tests may | 467 // Typically this is the value contained in |tree_ptr_|, but tests may |
| 446 // directly set this. | 468 // directly set this. |
| 447 mojom::WindowTree* tree_; | 469 ui::mojom::WindowTree* tree_; |
| 448 | 470 |
| 449 // Set to true if OnEmbed() was received. | 471 // Set to true if OnEmbed() was received. |
| 450 bool is_from_embed_ = false; | 472 bool is_from_embed_ = false; |
| 451 | 473 |
| 452 bool in_destructor_; | 474 bool in_destructor_; |
| 453 | 475 |
| 454 // A mapping to shared memory that is one 32 bit integer long. The window | 476 // A mapping to shared memory that is one 32 bit integer long. The window |
| 455 // server uses this to let us synchronously read the cursor location. | 477 // server uses this to let us synchronously read the cursor location. |
| 456 mojo::ScopedSharedBufferMapping cursor_location_mapping_; | 478 mojo::ScopedSharedBufferMapping cursor_location_mapping_; |
| 457 | 479 |
| 458 base::ObserverList<WindowTreeClientObserver> observers_; | 480 base::ObserverList<WindowTreeClientObserver> observers_; |
| 459 | 481 |
| 460 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManager>> | 482 std::unique_ptr<mojo::AssociatedBinding<ui::mojom::WindowManager>> |
| 461 window_manager_internal_; | 483 window_manager_internal_; |
| 462 mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_; | 484 ui::mojom::WindowManagerClientAssociatedPtr window_manager_internal_client_; |
| 463 | 485 |
| 464 bool has_pointer_watcher_ = false; | 486 bool has_pointer_watcher_ = false; |
| 465 | 487 |
| 466 // The current change id for the client. | 488 // The current change id for the client. |
| 467 uint32_t current_move_loop_change_ = 0u; | 489 uint32_t current_move_loop_change_ = 0u; |
| 468 | 490 |
| 469 // Callback executed when a move loop initiated by PerformWindowMove() is | 491 // Callback executed when a move loop initiated by PerformWindowMove() is |
| 470 // completed. | 492 // completed. |
| 471 base::Callback<void(bool)> on_current_move_finished_; | 493 base::Callback<void(bool)> on_current_move_finished_; |
| 472 | 494 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 485 // A set of window ids for windows that we received an OnDragEnter() message | 507 // A set of window ids for windows that we received an OnDragEnter() message |
| 486 // for. We maintain this set so we know who to send OnDragFinish() messages | 508 // for. We maintain this set so we know who to send OnDragFinish() messages |
| 487 // at the end of the drag. | 509 // at the end of the drag. |
| 488 std::set<Id> drag_entered_windows_; | 510 std::set<Id> drag_entered_windows_; |
| 489 | 511 |
| 490 base::WeakPtrFactory<WindowTreeClient> weak_factory_; | 512 base::WeakPtrFactory<WindowTreeClient> weak_factory_; |
| 491 | 513 |
| 492 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); | 514 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); |
| 493 }; | 515 }; |
| 494 | 516 |
| 495 } // namespace ui | 517 } // namespace aura |
| 496 | 518 |
| 497 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ | 519 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ |
| OLD | NEW |