Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: components/mus/ws/connection_manager.h

Issue 1755223002: Adds WindowManagerManager to mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge and WindowManagerState Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/ws/client_connection.cc ('k') | components/mus/ws/connection_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ 5 #ifndef COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_
6 #define COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ 6 #define COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "components/mus/public/interfaces/display.mojom.h" 17 #include "components/mus/public/interfaces/display.mojom.h"
18 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" 18 #include "components/mus/public/interfaces/window_manager_factory.mojom.h"
19 #include "components/mus/public/interfaces/window_tree.mojom.h" 19 #include "components/mus/public/interfaces/window_tree.mojom.h"
20 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 20 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
21 #include "components/mus/surfaces/surfaces_state.h" 21 #include "components/mus/surfaces/surfaces_state.h"
22 #include "components/mus/ws/ids.h" 22 #include "components/mus/ws/ids.h"
23 #include "components/mus/ws/operation.h" 23 #include "components/mus/ws/operation.h"
24 #include "components/mus/ws/server_window_delegate.h" 24 #include "components/mus/ws/server_window_delegate.h"
25 #include "components/mus/ws/server_window_observer.h" 25 #include "components/mus/ws/server_window_observer.h"
26 #include "components/mus/ws/window_manager_factory_registry.h"
26 #include "components/mus/ws/window_tree_host_impl.h" 27 #include "components/mus/ws/window_tree_host_impl.h"
27 #include "mojo/converters/surfaces/custom_surface_converter.h" 28 #include "mojo/converters/surfaces/custom_surface_converter.h"
28 #include "mojo/public/cpp/bindings/array.h" 29 #include "mojo/public/cpp/bindings/array.h"
29 #include "mojo/public/cpp/bindings/binding.h" 30 #include "mojo/public/cpp/bindings/binding.h"
30 #include "mojo/public/cpp/bindings/binding_set.h" 31 #include "mojo/public/cpp/bindings/binding_set.h"
31 #include "mojo/public/cpp/bindings/interface_ptr_set.h" 32 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
32 33
33 namespace mus { 34 namespace mus {
34 namespace ws { 35 namespace ws {
35 36
36 class ClientConnection; 37 class ClientConnection;
37 class ConnectionManagerDelegate; 38 class ConnectionManagerDelegate;
38 class ServerWindow; 39 class ServerWindow;
39 class WindowManagerFactoryService; 40 class WindowManagerState;
40 class WindowTreeHostConnection; 41 class WindowTreeHostConnection;
41 class WindowTreeImpl; 42 class WindowTreeImpl;
42 43
44 struct WindowManagerAndHost {
45 WindowManagerAndHost()
46 : window_manager_state(nullptr), window_tree_host(nullptr) {}
47
48 WindowManagerState* window_manager_state;
49 WindowTreeHostImpl* window_tree_host;
50 };
51
52 struct WindowManagerAndHostConst {
53 WindowManagerAndHostConst()
54 : window_manager_state(nullptr), window_tree_host(nullptr) {}
55 const WindowManagerState* window_manager_state;
56 const WindowTreeHostImpl* window_tree_host;
57 };
58
43 // ConnectionManager manages the set of connections to the window server (all 59 // ConnectionManager manages the set of connections to the window server (all
44 // the WindowTreeImpls) as well as providing the root of the hierarchy. 60 // the WindowTreeImpls) as well as providing the root of the hierarchy.
45 // 61 //
46 // TODO(sky): this class is doing too much. Refactor to make responsibilities 62 // TODO(sky): this class is doing too much. Refactor to make responsibilities
47 // clearer. 63 // clearer.
48 class ConnectionManager : public ServerWindowDelegate, 64 class ConnectionManager : public ServerWindowDelegate,
49 public ServerWindowObserver, 65 public ServerWindowObserver,
50 public mojom::DisplayManager { 66 public mojom::DisplayManager {
51 public: 67 public:
52 ConnectionManager(ConnectionManagerDelegate* delegate, 68 ConnectionManager(ConnectionManagerDelegate* delegate,
53 const scoped_refptr<mus::SurfacesState>& surfaces_state); 69 const scoped_refptr<mus::SurfacesState>& surfaces_state);
54 ~ConnectionManager() override; 70 ~ConnectionManager() override;
55 71
72 ConnectionManagerDelegate* delegate() { return delegate_; }
73
56 // Adds/removes a WindowTreeHost. ConnectionManager owns the 74 // Adds/removes a WindowTreeHost. ConnectionManager owns the
57 // WindowTreeHostImpls. 75 // WindowTreeHostImpls.
58 void AddHost(WindowTreeHostImpl* host); 76 void AddHost(WindowTreeHostImpl* host);
59 void DestroyHost(WindowTreeHostImpl* host); 77 void DestroyHost(WindowTreeHostImpl* host);
60 78
61 // Creates a new ServerWindow. The return value is owned by the caller, but 79 // Creates a new ServerWindow. The return value is owned by the caller, but
62 // must be destroyed before ConnectionManager. 80 // must be destroyed before ConnectionManager.
63 ServerWindow* CreateServerWindow( 81 ServerWindow* CreateServerWindow(
64 const WindowId& id, 82 const WindowId& id,
65 const std::map<std::string, std::vector<uint8_t>>& properties); 83 const std::map<std::string, std::vector<uint8_t>>& properties);
66 84
67 // Returns the id for the next WindowTreeImpl. 85 // Returns the id for the next WindowTreeImpl.
68 ConnectionSpecificId GetAndAdvanceNextConnectionId(); 86 ConnectionSpecificId GetAndAdvanceNextConnectionId();
69 87
70 // Returns the id for the next WindowTreeHostImpl. 88 // Returns the id for the next WindowTreeHostImpl.
71 uint16_t GetAndAdvanceNextHostId(); 89 uint16_t GetAndAdvanceNextHostId();
72 90
73 // Invoked when a WindowTreeImpl's connection encounters an error. 91 // Invoked when a WindowTreeImpl's connection encounters an error.
74 void OnConnectionError(ClientConnection* connection); 92 void OnConnectionError(ClientConnection* connection);
75 93
76 ClientConnection* GetClientConnection(WindowTreeImpl* window_tree); 94 ClientConnection* GetClientConnection(WindowTreeImpl* window_tree);
77 95
78 void OnHostConnectionClosed(WindowTreeHostImpl* host);
79
80 // See description of WindowTree::Embed() for details. This assumes 96 // See description of WindowTree::Embed() for details. This assumes
81 // |transport_window_id| is valid. 97 // |transport_window_id| is valid.
82 WindowTreeImpl* EmbedAtWindow(ServerWindow* root, 98 WindowTreeImpl* EmbedAtWindow(ServerWindow* root,
83 uint32_t policy_bitmask, 99 uint32_t policy_bitmask,
84 mojom::WindowTreeClientPtr client); 100 mojom::WindowTreeClientPtr client);
85 101
86 // Adds |connection| to internal maps. 102 // Adds |connection| to internal maps.
87 void AddConnection(scoped_ptr<ClientConnection> owned_connection, 103 void AddConnection(scoped_ptr<ClientConnection> owned_connection,
88 mojom::WindowTreePtr tree_ptr); 104 mojom::WindowTreePtr tree_ptr);
89 105
90 // Returns the connection by id. 106 // Returns the connection by id.
91 WindowTreeImpl* GetConnection(ConnectionSpecificId connection_id); 107 WindowTreeImpl* GetConnection(ConnectionSpecificId connection_id);
92 108
93 // Returns the Window identified by |id|. 109 // Returns the Window identified by |id|.
94 ServerWindow* GetWindow(const WindowId& id); 110 ServerWindow* GetWindow(const WindowId& id);
95 111
96 // Returns whether |window| is a descendant of some root window but not itself
97 // a root window.
98 bool IsWindowAttachedToRoot(const ServerWindow* window) const;
99
100 // Schedules a paint for the specified region in the coordinates of |window|. 112 // Schedules a paint for the specified region in the coordinates of |window|.
101 void SchedulePaint(const ServerWindow* window, const gfx::Rect& bounds); 113 void SchedulePaint(const ServerWindow* window, const gfx::Rect& bounds);
102 114
103 OperationType current_operation_type() const { 115 OperationType current_operation_type() const {
104 return current_operation_ ? current_operation_->type() 116 return current_operation_ ? current_operation_->type()
105 : OperationType::NONE; 117 : OperationType::NONE;
106 } 118 }
107 119
108 // Invoked when the WindowTreeHostImpl's display is closed. 120 // Invoked when the WindowTreeHostImpl's display is closed.
109 void OnDisplayClosed(); 121 void OnDisplayClosed();
(...skipping 18 matching lines...) Expand all
128 return const_cast<WindowTreeImpl*>( 140 return const_cast<WindowTreeImpl*>(
129 const_cast<const ConnectionManager*>(this) 141 const_cast<const ConnectionManager*>(this)
130 ->GetConnectionWithRoot(window)); 142 ->GetConnectionWithRoot(window));
131 } 143 }
132 const WindowTreeImpl* GetConnectionWithRoot(const ServerWindow* window) const; 144 const WindowTreeImpl* GetConnectionWithRoot(const ServerWindow* window) const;
133 145
134 WindowTreeHostImpl* GetWindowTreeHostByWindow(const ServerWindow* window); 146 WindowTreeHostImpl* GetWindowTreeHostByWindow(const ServerWindow* window);
135 const WindowTreeHostImpl* GetWindowTreeHostByWindow( 147 const WindowTreeHostImpl* GetWindowTreeHostByWindow(
136 const ServerWindow* window) const; 148 const ServerWindow* window) const;
137 149
150 WindowManagerAndHostConst GetWindowManagerAndHost(
151 const ServerWindow* window) const;
152 WindowManagerAndHost GetWindowManagerAndHost(const ServerWindow* window);
153
138 WindowTreeHostImpl* GetActiveWindowTreeHost(); 154 WindowTreeHostImpl* GetActiveWindowTreeHost();
139 155
140 bool has_tree_host_connections() const { return !hosts_.empty(); } 156 bool has_tree_host_connections() const { return !hosts_.empty(); }
141 157
142 void AddDisplayManagerBinding( 158 void AddDisplayManagerBinding(
143 mojo::InterfaceRequest<mojom::DisplayManager> request); 159 mojo::InterfaceRequest<mojom::DisplayManager> request);
144 160
145 void CreateWindowManagerFactoryService( 161 void CreateWindowManagerFactoryService(
162 const uint32_t user_id,
146 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request); 163 mojo::InterfaceRequest<mojom::WindowManagerFactoryService> request);
164 void OnWindowManagerFactorySet();
165
166 WindowManagerFactoryRegistry* window_manager_factory_registry() {
167 return &window_manager_factory_registry_;
168 }
147 169
148 // Returns a change id for the window manager that is associated with 170 // Returns a change id for the window manager that is associated with
149 // |source| and |client_change_id|. When the window manager replies 171 // |source| and |client_change_id|. When the window manager replies
150 // WindowManagerChangeCompleted() is called to obtain the original source 172 // WindowManagerChangeCompleted() is called to obtain the original source
151 // and client supplied change_id that initiated the called. 173 // and client supplied change_id that initiated the called.
152 uint32_t GenerateWindowManagerChangeId(WindowTreeImpl* source, 174 uint32_t GenerateWindowManagerChangeId(WindowTreeImpl* source,
153 uint32_t client_change_id); 175 uint32_t client_change_id);
154 176
155 // Called when a response from the window manager is obtained. Calls to 177 // Called when a response from the window manager is obtained. Calls to
156 // the client that initiated the change with the change id originally 178 // the client that initiated the change with the change id originally
157 // supplied by the client. 179 // supplied by the client.
158 void WindowManagerChangeCompleted(uint32_t window_manager_change_id, 180 void WindowManagerChangeCompleted(uint32_t window_manager_change_id,
159 bool success); 181 bool success);
160 void WindowManagerCreatedTopLevelWindow(WindowTreeImpl* wm_connection, 182 void WindowManagerCreatedTopLevelWindow(WindowTreeImpl* wm_connection,
161 uint32_t window_manager_change_id, 183 uint32_t window_manager_change_id,
162 const ServerWindow* window); 184 const ServerWindow* window);
163 185
164 // Called when we get an unexpected message from the WindowManager. 186 // Called when we get an unexpected message from the WindowManager.
165 // TODO(sky): decide what we want to do here. 187 // TODO(sky): decide what we want to do here.
166 void WindowManagerSentBogusMessage() {} 188 void WindowManagerSentBogusMessage() {}
167 189
190 // Returns the Display for |host|.
191 mojom::DisplayPtr DisplayForHost(WindowTreeHostImpl* host);
192
168 // These functions trivially delegate to all WindowTreeImpls, which in 193 // These functions trivially delegate to all WindowTreeImpls, which in
169 // term notify their clients. 194 // term notify their clients.
170 void ProcessWindowDestroyed(ServerWindow* window);
171 void ProcessWindowBoundsChanged(const ServerWindow* window, 195 void ProcessWindowBoundsChanged(const ServerWindow* window,
172 const gfx::Rect& old_bounds, 196 const gfx::Rect& old_bounds,
173 const gfx::Rect& new_bounds); 197 const gfx::Rect& new_bounds);
174 void ProcessClientAreaChanged( 198 void ProcessClientAreaChanged(
175 const ServerWindow* window, 199 const ServerWindow* window,
176 const gfx::Insets& new_client_area, 200 const gfx::Insets& new_client_area,
177 const std::vector<gfx::Rect>& new_additional_client_areas); 201 const std::vector<gfx::Rect>& new_additional_client_areas);
178 void ProcessLostCapture(const ServerWindow* window); 202 void ProcessLostCapture(const ServerWindow* window);
179 void ProcessViewportMetricsChanged(WindowTreeHostImpl* host, 203 void ProcessViewportMetricsChanged(WindowTreeHostImpl* host,
180 const mojom::ViewportMetrics& old_metrics, 204 const mojom::ViewportMetrics& old_metrics,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Run in response to events which may cause us to change the native cursor. 259 // Run in response to events which may cause us to change the native cursor.
236 void MaybeUpdateNativeCursor(ServerWindow* window); 260 void MaybeUpdateNativeCursor(ServerWindow* window);
237 261
238 // Calls OnDisplays() on |observer|. 262 // Calls OnDisplays() on |observer|.
239 void CallOnDisplays(mojom::DisplayManagerObserver* observer); 263 void CallOnDisplays(mojom::DisplayManagerObserver* observer);
240 264
241 // Calls observer->OnDisplaysChanged() with the display for |host|. 265 // Calls observer->OnDisplaysChanged() with the display for |host|.
242 void CallOnDisplayChanged(mojom::DisplayManagerObserver* observer, 266 void CallOnDisplayChanged(mojom::DisplayManagerObserver* observer,
243 WindowTreeHostImpl* host); 267 WindowTreeHostImpl* host);
244 268
245 // Returns the Display for |host|.
246 mojom::DisplayPtr DisplayForHost(WindowTreeHostImpl* host);
247
248 // Overridden from ServerWindowDelegate: 269 // Overridden from ServerWindowDelegate:
249 mus::SurfacesState* GetSurfacesState() override; 270 mus::SurfacesState* GetSurfacesState() override;
250 void OnScheduleWindowPaint(const ServerWindow* window) override; 271 void OnScheduleWindowPaint(const ServerWindow* window) override;
251 const ServerWindow* GetRootWindow(const ServerWindow* window) const override; 272 const ServerWindow* GetRootWindow(const ServerWindow* window) const override;
252 void ScheduleSurfaceDestruction(ServerWindow* window) override; 273 void ScheduleSurfaceDestruction(ServerWindow* window) override;
253 ServerWindow* FindWindowForSurface( 274 ServerWindow* FindWindowForSurface(
254 const ServerWindow* ancestor, 275 const ServerWindow* ancestor,
255 mojom::SurfaceType surface_type, 276 mojom::SurfaceType surface_type,
256 const ClientWindowId& client_window_id) override; 277 const ClientWindowId& client_window_id) override;
257 278
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 uint32_t next_wm_change_id_; 345 uint32_t next_wm_change_id_;
325 346
326 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_; 347 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_;
327 // WARNING: only use these once |got_valid_frame_decorations_| is true. 348 // WARNING: only use these once |got_valid_frame_decorations_| is true.
328 // TODO(sky): refactor this out into its own class. 349 // TODO(sky): refactor this out into its own class.
329 mojo::InterfacePtrSet<mojom::DisplayManagerObserver> 350 mojo::InterfacePtrSet<mojom::DisplayManagerObserver>
330 display_manager_observers_; 351 display_manager_observers_;
331 352
332 bool got_valid_frame_decorations_; 353 bool got_valid_frame_decorations_;
333 354
334 scoped_ptr<WindowManagerFactoryService> window_manager_factory_service_; 355 WindowManagerFactoryRegistry window_manager_factory_registry_;
335 356
336 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 357 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
337 }; 358 };
338 359
339 } // namespace ws 360 } // namespace ws
340 } // namespace mus 361 } // namespace mus
341 362
342 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ 363 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « components/mus/ws/client_connection.cc ('k') | components/mus/ws/connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698