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

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

Issue 1775583002: Moves FrameDecorations from Display to WindowManagerState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: override 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/BUILD.gn ('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>
12 #include <vector> 11 #include <vector>
13 12
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
16 #include "base/timer/timer.h"
17 #include "components/mus/public/interfaces/display.mojom.h"
18 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" 15 #include "components/mus/public/interfaces/window_manager_factory.mojom.h"
19 #include "components/mus/public/interfaces/window_tree.mojom.h" 16 #include "components/mus/public/interfaces/window_tree.mojom.h"
20 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 17 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
21 #include "components/mus/surfaces/surfaces_state.h" 18 #include "components/mus/surfaces/surfaces_state.h"
22 #include "components/mus/ws/display.h" 19 #include "components/mus/ws/display.h"
23 #include "components/mus/ws/display_manager_delegate.h" 20 #include "components/mus/ws/display_manager_delegate.h"
24 #include "components/mus/ws/ids.h" 21 #include "components/mus/ws/ids.h"
25 #include "components/mus/ws/operation.h" 22 #include "components/mus/ws/operation.h"
26 #include "components/mus/ws/server_window_delegate.h" 23 #include "components/mus/ws/server_window_delegate.h"
27 #include "components/mus/ws/server_window_observer.h" 24 #include "components/mus/ws/server_window_observer.h"
28 #include "components/mus/ws/user_id_tracker.h" 25 #include "components/mus/ws/user_id_tracker.h"
29 #include "components/mus/ws/window_manager_factory_registry.h" 26 #include "components/mus/ws/window_manager_factory_registry.h"
30 #include "mojo/converters/surfaces/custom_surface_converter.h" 27 #include "mojo/converters/surfaces/custom_surface_converter.h"
31 #include "mojo/public/cpp/bindings/array.h" 28 #include "mojo/public/cpp/bindings/array.h"
32 #include "mojo/public/cpp/bindings/binding.h" 29 #include "mojo/public/cpp/bindings/binding.h"
33 #include "mojo/public/cpp/bindings/binding_set.h"
34 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
35 30
36 namespace mus { 31 namespace mus {
37 namespace ws { 32 namespace ws {
38 33
39 class ConnectionManagerDelegate; 34 class ConnectionManagerDelegate;
40 class DisplayManager; 35 class DisplayManager;
41 class ServerWindow; 36 class ServerWindow;
42 class WindowManagerState; 37 class WindowManagerState;
43 class WindowTree; 38 class WindowTree;
44 class WindowTreeBinding; 39 class WindowTreeBinding;
45 40
46 // ConnectionManager manages the set of connections to the window server (all 41 // ConnectionManager manages the set of connections to the window server (all
47 // the WindowTrees) as well as providing the root of the hierarchy. 42 // the WindowTrees) as well as providing the root of the hierarchy.
48 // 43 //
49 // TODO(sky): this class is doing too much. Refactor to make responsibilities 44 // TODO(sky): this class is doing too much. Refactor to make responsibilities
50 // clearer. 45 // clearer.
51 class ConnectionManager : public ServerWindowDelegate, 46 class ConnectionManager : public ServerWindowDelegate,
52 public ServerWindowObserver, 47 public ServerWindowObserver,
53 public mojom::DisplayManager,
54 public DisplayManagerDelegate { 48 public DisplayManagerDelegate {
55 public: 49 public:
56 ConnectionManager(ConnectionManagerDelegate* delegate, 50 ConnectionManager(ConnectionManagerDelegate* delegate,
57 const scoped_refptr<mus::SurfacesState>& surfaces_state); 51 const scoped_refptr<mus::SurfacesState>& surfaces_state);
58 ~ConnectionManager() override; 52 ~ConnectionManager() override;
59 53
60 ConnectionManagerDelegate* delegate() { return delegate_; } 54 ConnectionManagerDelegate* delegate() { return delegate_; }
61 55
62 UserIdTracker* user_id_tracker() { return &user_id_tracker_; } 56 UserIdTracker* user_id_tracker() { return &user_id_tracker_; }
63 57
64 ws::DisplayManager* display_manager() { return display_manager_.get(); } 58 DisplayManager* display_manager() { return display_manager_.get(); }
65 const ws::DisplayManager* display_manager() const { 59 const DisplayManager* display_manager() const {
66 return display_manager_.get(); 60 return display_manager_.get();
67 } 61 }
68 62
69 // Creates a new ServerWindow. The return value is owned by the caller, but 63 // Creates a new ServerWindow. The return value is owned by the caller, but
70 // must be destroyed before ConnectionManager. 64 // must be destroyed before ConnectionManager.
71 ServerWindow* CreateServerWindow( 65 ServerWindow* CreateServerWindow(
72 const WindowId& id, 66 const WindowId& id,
73 const std::map<std::string, std::vector<uint8_t>>& properties); 67 const std::map<std::string, std::vector<uint8_t>>& properties);
74 68
75 // Returns the id for the next WindowTree. 69 // Returns the id for the next WindowTree.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 mojom::ViewportMetricsPtr GetViewportMetricsForWindow( 114 mojom::ViewportMetricsPtr GetViewportMetricsForWindow(
121 const ServerWindow* window); 115 const ServerWindow* window);
122 116
123 // Returns the WindowTree that has |id| as a root. 117 // Returns the WindowTree that has |id| as a root.
124 WindowTree* GetTreeWithRoot(const ServerWindow* window) { 118 WindowTree* GetTreeWithRoot(const ServerWindow* window) {
125 return const_cast<WindowTree*>( 119 return const_cast<WindowTree*>(
126 const_cast<const ConnectionManager*>(this)->GetTreeWithRoot(window)); 120 const_cast<const ConnectionManager*>(this)->GetTreeWithRoot(window));
127 } 121 }
128 const WindowTree* GetTreeWithRoot(const ServerWindow* window) const; 122 const WindowTree* GetTreeWithRoot(const ServerWindow* window) const;
129 123
130 void AddDisplayManagerBinding(
131 mojo::InterfaceRequest<mojom::DisplayManager> request);
132
133 void OnFirstWindowManagerFactorySet(); 124 void OnFirstWindowManagerFactorySet();
134 125
135 WindowManagerFactoryRegistry* window_manager_factory_registry() { 126 WindowManagerFactoryRegistry* window_manager_factory_registry() {
136 return &window_manager_factory_registry_; 127 return &window_manager_factory_registry_;
137 } 128 }
138 129
139 // Returns a change id for the window manager that is associated with 130 // Returns a change id for the window manager that is associated with
140 // |source| and |client_change_id|. When the window manager replies 131 // |source| and |client_change_id|. When the window manager replies
141 // WindowManagerChangeCompleted() is called to obtain the original source 132 // WindowManagerChangeCompleted() is called to obtain the original source
142 // and client supplied change_id that initiated the called. 133 // and client supplied change_id that initiated the called.
143 uint32_t GenerateWindowManagerChangeId(WindowTree* source, 134 uint32_t GenerateWindowManagerChangeId(WindowTree* source,
144 uint32_t client_change_id); 135 uint32_t client_change_id);
145 136
146 // Called when a response from the window manager is obtained. Calls to 137 // Called when a response from the window manager is obtained. Calls to
147 // the client that initiated the change with the change id originally 138 // the client that initiated the change with the change id originally
148 // supplied by the client. 139 // supplied by the client.
149 void WindowManagerChangeCompleted(uint32_t window_manager_change_id, 140 void WindowManagerChangeCompleted(uint32_t window_manager_change_id,
150 bool success); 141 bool success);
151 void WindowManagerCreatedTopLevelWindow(WindowTree* wm_tree, 142 void WindowManagerCreatedTopLevelWindow(WindowTree* wm_tree,
152 uint32_t window_manager_change_id, 143 uint32_t window_manager_change_id,
153 const ServerWindow* window); 144 const ServerWindow* window);
154 145
155 // Called when we get an unexpected message from the WindowManager. 146 // Called when we get an unexpected message from the WindowManager.
156 // TODO(sky): decide what we want to do here. 147 // TODO(sky): decide what we want to do here.
157 void WindowManagerSentBogusMessage() {} 148 void WindowManagerSentBogusMessage() {}
158 149
159 // Returns the Display for |display|.
160 mojom::DisplayPtr DisplayToMojomDisplay(Display* display);
161
162 // These functions trivially delegate to all WindowTrees, which in 150 // These functions trivially delegate to all WindowTrees, which in
163 // term notify their clients. 151 // term notify their clients.
164 void ProcessWindowBoundsChanged(const ServerWindow* window, 152 void ProcessWindowBoundsChanged(const ServerWindow* window,
165 const gfx::Rect& old_bounds, 153 const gfx::Rect& old_bounds,
166 const gfx::Rect& new_bounds); 154 const gfx::Rect& new_bounds);
167 void ProcessClientAreaChanged( 155 void ProcessClientAreaChanged(
168 const ServerWindow* window, 156 const ServerWindow* window,
169 const gfx::Insets& new_client_area, 157 const gfx::Insets& new_client_area,
170 const std::vector<gfx::Rect>& new_additional_client_areas); 158 const std::vector<gfx::Rect>& new_additional_client_areas);
171 void ProcessLostCapture(const ServerWindow* window); 159 void ProcessLostCapture(const ServerWindow* window);
172 void ProcessViewportMetricsChanged(Display* display, 160 void ProcessViewportMetricsChanged(Display* display,
173 const mojom::ViewportMetrics& old_metrics, 161 const mojom::ViewportMetrics& old_metrics,
174 const mojom::ViewportMetrics& new_metrics); 162 const mojom::ViewportMetrics& new_metrics);
175 void ProcessWillChangeWindowHierarchy(const ServerWindow* window, 163 void ProcessWillChangeWindowHierarchy(const ServerWindow* window,
176 const ServerWindow* new_parent, 164 const ServerWindow* new_parent,
177 const ServerWindow* old_parent); 165 const ServerWindow* old_parent);
178 void ProcessWindowHierarchyChanged(const ServerWindow* window, 166 void ProcessWindowHierarchyChanged(const ServerWindow* window,
179 const ServerWindow* new_parent, 167 const ServerWindow* new_parent,
180 const ServerWindow* old_parent); 168 const ServerWindow* old_parent);
181 void ProcessWindowReorder(const ServerWindow* window, 169 void ProcessWindowReorder(const ServerWindow* window,
182 const ServerWindow* relative_window, 170 const ServerWindow* relative_window,
183 const mojom::OrderDirection direction); 171 const mojom::OrderDirection direction);
184 void ProcessWindowDeleted(const ServerWindow* window); 172 void ProcessWindowDeleted(const ServerWindow* window);
185 void ProcessWillChangeWindowPredefinedCursor(ServerWindow* window, 173 void ProcessWillChangeWindowPredefinedCursor(ServerWindow* window,
186 int32_t cursor_id); 174 int32_t cursor_id);
187 void ProcessFrameDecorationValuesChanged(Display* display);
188 175
189 private: 176 private:
190 friend class Operation; 177 friend class Operation;
191 178
192 using WindowTreeMap = std::map<ConnectionSpecificId, scoped_ptr<WindowTree>>; 179 using WindowTreeMap = std::map<ConnectionSpecificId, scoped_ptr<WindowTree>>;
193 180
194 struct InFlightWindowManagerChange { 181 struct InFlightWindowManagerChange {
195 // Identifies the client that initiated the change. 182 // Identifies the client that initiated the change.
196 ConnectionSpecificId connection_id; 183 ConnectionSpecificId connection_id;
197 184
(...skipping 21 matching lines...) Expand all
219 206
220 // Returns true if the specified connection issued the current operation. 207 // Returns true if the specified connection issued the current operation.
221 bool IsOperationSource(ConnectionSpecificId tree_id) const { 208 bool IsOperationSource(ConnectionSpecificId tree_id) const {
222 return current_operation_ && 209 return current_operation_ &&
223 current_operation_->source_tree_id() == tree_id; 210 current_operation_->source_tree_id() == tree_id;
224 } 211 }
225 212
226 // Run in response to events which may cause us to change the native cursor. 213 // Run in response to events which may cause us to change the native cursor.
227 void MaybeUpdateNativeCursor(ServerWindow* window); 214 void MaybeUpdateNativeCursor(ServerWindow* window);
228 215
229 // Calls OnDisplays() on |observer|.
230 void CallOnDisplays(mojom::DisplayManagerObserver* observer);
231
232 // Calls observer->OnDisplaysChanged() with the display for |display|.
233 void CallOnDisplayChanged(mojom::DisplayManagerObserver* observer,
234 Display* display);
235
236 // Overridden from ServerWindowDelegate: 216 // Overridden from ServerWindowDelegate:
237 mus::SurfacesState* GetSurfacesState() override; 217 mus::SurfacesState* GetSurfacesState() override;
238 void OnScheduleWindowPaint(ServerWindow* window) override; 218 void OnScheduleWindowPaint(ServerWindow* window) override;
239 const ServerWindow* GetRootWindow(const ServerWindow* window) const override; 219 const ServerWindow* GetRootWindow(const ServerWindow* window) const override;
240 void ScheduleSurfaceDestruction(ServerWindow* window) override; 220 void ScheduleSurfaceDestruction(ServerWindow* window) override;
241 ServerWindow* FindWindowForSurface( 221 ServerWindow* FindWindowForSurface(
242 const ServerWindow* ancestor, 222 const ServerWindow* ancestor,
243 mojom::SurfaceType surface_type, 223 mojom::SurfaceType surface_type,
244 const ClientWindowId& client_window_id) override; 224 const ClientWindowId& client_window_id) override;
245 225
(...skipping 22 matching lines...) Expand all
268 const std::vector<uint8_t>* new_data) override; 248 const std::vector<uint8_t>* new_data) override;
269 void OnWindowPredefinedCursorChanged(ServerWindow* window, 249 void OnWindowPredefinedCursorChanged(ServerWindow* window,
270 int32_t cursor_id) override; 250 int32_t cursor_id) override;
271 void OnWindowTextInputStateChanged(ServerWindow* window, 251 void OnWindowTextInputStateChanged(ServerWindow* window,
272 const ui::TextInputState& state) override; 252 const ui::TextInputState& state) override;
273 void OnTransientWindowAdded(ServerWindow* window, 253 void OnTransientWindowAdded(ServerWindow* window,
274 ServerWindow* transient_child) override; 254 ServerWindow* transient_child) override;
275 void OnTransientWindowRemoved(ServerWindow* window, 255 void OnTransientWindowRemoved(ServerWindow* window,
276 ServerWindow* transient_child) override; 256 ServerWindow* transient_child) override;
277 257
278 // Overriden from mojom::DisplayManager:
279 void AddObserver(mojom::DisplayManagerObserverPtr observer) override;
280
281 // DisplayManagerDelegate: 258 // DisplayManagerDelegate:
282 void OnWillDestroyDisplay(Display* display) override; 259 void OnWillDestroyDisplay(Display* display) override;
283 void OnFirstDisplayReady() override; 260 void OnFirstDisplayReady() override;
284 void OnNoMoreDisplays() override; 261 void OnNoMoreDisplays() override;
285 262
286 UserIdTracker user_id_tracker_; 263 UserIdTracker user_id_tracker_;
287 264
288 ConnectionManagerDelegate* delegate_; 265 ConnectionManagerDelegate* delegate_;
289 266
290 // State for rendering into a Surface. 267 // State for rendering into a Surface.
291 scoped_refptr<mus::SurfacesState> surfaces_state_; 268 scoped_refptr<mus::SurfacesState> surfaces_state_;
292 269
293 // ID to use for next WindowTree. 270 // ID to use for next WindowTree.
294 ConnectionSpecificId next_connection_id_; 271 ConnectionSpecificId next_connection_id_;
295 272
296 scoped_ptr<ws::DisplayManager> display_manager_; 273 scoped_ptr<DisplayManager> display_manager_;
297 274
298 // Set of WindowTrees. 275 // Set of WindowTrees.
299 WindowTreeMap tree_map_; 276 WindowTreeMap tree_map_;
300 277
301 // If non-null then we're processing a client operation. The Operation is 278 // If non-null then we're processing a client operation. The Operation is
302 // not owned by us (it's created on the stack by WindowTree). 279 // not owned by us (it's created on the stack by WindowTree).
303 Operation* current_operation_; 280 Operation* current_operation_;
304 281
305 bool in_destructor_; 282 bool in_destructor_;
306 283
307 // Maps from window manager change id to the client that initiated the 284 // Maps from window manager change id to the client that initiated the
308 // request. 285 // request.
309 InFlightWindowManagerChangeMap in_flight_wm_change_map_; 286 InFlightWindowManagerChangeMap in_flight_wm_change_map_;
310 287
311 // Next id supplied to the window manager. 288 // Next id supplied to the window manager.
312 uint32_t next_wm_change_id_; 289 uint32_t next_wm_change_id_;
313 290
314 mojo::BindingSet<mojom::DisplayManager> display_manager_bindings_;
315 // WARNING: only use these once |got_valid_frame_decorations_| is true.
316 // TODO(sky): refactor this out into its own class.
317 mojo::InterfacePtrSet<mojom::DisplayManagerObserver>
318 display_manager_observers_;
319
320 bool got_valid_frame_decorations_;
321
322 WindowManagerFactoryRegistry window_manager_factory_registry_; 291 WindowManagerFactoryRegistry window_manager_factory_registry_;
323 292
324 DISALLOW_COPY_AND_ASSIGN(ConnectionManager); 293 DISALLOW_COPY_AND_ASSIGN(ConnectionManager);
325 }; 294 };
326 295
327 } // namespace ws 296 } // namespace ws
328 } // namespace mus 297 } // namespace mus
329 298
330 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ 299 #endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698