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

Side by Side Diff: components/mus/public/cpp/window_tree_client.h

Issue 2072343002: Changes how window manager obtains WindowTree from mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include Created 4 years, 6 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
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_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_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 <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/atomicops.h" 15 #include "base/atomicops.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "components/mus/common/types.h" 19 #include "components/mus/common/types.h"
20 #include "components/mus/public/cpp/window.h" 20 #include "components/mus/public/cpp/window.h"
21 #include "components/mus/public/cpp/window_manager_delegate.h" 21 #include "components/mus/public/cpp/window_manager_delegate.h"
22 #include "components/mus/public/interfaces/window_tree.mojom.h" 22 #include "components/mus/public/interfaces/window_tree.mojom.h"
23 #include "mojo/public/cpp/bindings/associated_binding.h" 23 #include "mojo/public/cpp/bindings/associated_binding.h"
24 #include "mojo/public/cpp/bindings/strong_binding.h" 24 #include "mojo/public/cpp/bindings/strong_binding.h"
25 25
26 namespace display {
27 class Display;
28 }
29
26 namespace gfx { 30 namespace gfx {
27 class Insets; 31 class Insets;
28 class Size; 32 class Size;
29 } 33 }
30 34
31 namespace shell { 35 namespace shell {
32 class Connector; 36 class Connector;
33 } 37 }
34 38
35 namespace mus { 39 namespace mus {
36 class InFlightChange; 40 class InFlightChange;
37 class WindowTreeClientDelegate; 41 class WindowTreeClientDelegate;
38 class WindowTreeClientPrivate; 42 class WindowTreeClientPrivate;
39 class WindowTreeClientObserver; 43 class WindowTreeClientObserver;
40 enum class ChangeType; 44 enum class ChangeType;
41 45
42 // Manages the connection with the Window Server service. 46 // Manages the connection with mus.
47 //
48 // WindowTreeClient is deleted by any of the following:
49 // . If all the roots of the connection are destroyed and the connection is
50 // configured to delete when there are no roots (true if the WindowTreeClient
51 // is created with a mojom::WindowTreeClientRequest). This happens
52 // if the owner of the roots Embed()s another app in all the roots, or all
53 // the roots are explicitly deleted.
54 // . The connection to mus is lost.
55 // . Explicitly by way of calling delete.
56 //
57 // When WindowTreeClient is deleted all windows are deleted (and observers
58 // notified). This is followed by calling
59 // WindowTreeClientDelegate::OnWindowTreeClientDestroyed().
43 class WindowTreeClient : public mojom::WindowTreeClient, 60 class WindowTreeClient : public mojom::WindowTreeClient,
44 public mojom::WindowManager, 61 public mojom::WindowManager,
45 public WindowManagerClient { 62 public WindowManagerClient {
46 public: 63 public:
47 WindowTreeClient(WindowTreeClientDelegate* delegate, 64 WindowTreeClient(WindowTreeClientDelegate* delegate,
48 WindowManagerDelegate* window_manager_delegate, 65 WindowManagerDelegate* window_manager_delegate,
49 mojom::WindowTreeClientRequest request); 66 mojom::WindowTreeClientRequest request);
50 ~WindowTreeClient() override; 67 ~WindowTreeClient() override;
51 68
52 // Establishes the connection by way of the WindowTreeFactory. 69 // Establishes the connection by way of the WindowTreeFactory.
53 void ConnectViaWindowTreeFactory(shell::Connector* connector); 70 void ConnectViaWindowTreeFactory(shell::Connector* connector);
54 71
72 // Establishes the connection by way of WindowManagerWindowTreeFactory.
73 void ConnectAsWindowManager(shell::Connector* connector);
74
55 // Wait for OnEmbed(), returning when done. 75 // Wait for OnEmbed(), returning when done.
56 void WaitForEmbed(); 76 void WaitForEmbed();
57 77
58 bool connected() const { return tree_ != nullptr; } 78 bool connected() const { return tree_ != nullptr; }
59 ClientSpecificId client_id() const { return client_id_; } 79 ClientSpecificId client_id() const { return client_id_; }
60 80
61 // API exposed to the window implementations that pushes local changes to the 81 // API exposed to the window implementations that pushes local changes to the
62 // service. 82 // service.
63 void DestroyWindow(Window* window); 83 void DestroyWindow(Window* window);
64 84
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 219
200 // Returns true if there is an InFlightChange that matches |change|. If there 220 // Returns true if there is an InFlightChange that matches |change|. If there
201 // is an existing change SetRevertValueFrom() is invoked on it. Returns false 221 // is an existing change SetRevertValueFrom() is invoked on it. Returns false
202 // if there is no InFlightChange matching |change|. 222 // if there is no InFlightChange matching |change|.
203 // See InFlightChange for details on how InFlightChanges are used. 223 // See InFlightChange for details on how InFlightChanges are used.
204 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change); 224 bool ApplyServerChangeToExistingInFlightChange(const InFlightChange& change);
205 225
206 Window* NewWindowImpl(NewWindowType type, 226 Window* NewWindowImpl(NewWindowType type,
207 const Window::SharedProperties* properties); 227 const Window::SharedProperties* properties);
208 228
229 // Sets the mojom::WindowTree implementation.
230 void SetWindowTree(mojom::WindowTreePtr window_tree_ptr);
231
232 // Called when the mojom::WindowTree connection is lost, deletes this.
233 void OnConnectionLost();
234
209 // OnEmbed() calls into this. Exposed as a separate function for testing. 235 // OnEmbed() calls into this. Exposed as a separate function for testing.
210 void OnEmbedImpl(mojom::WindowTree* window_tree, 236 void OnEmbedImpl(mojom::WindowTree* window_tree,
211 ClientSpecificId client_id, 237 ClientSpecificId client_id,
212 mojom::WindowDataPtr root_data, 238 mojom::WindowDataPtr root_data,
213 int64_t display_id, 239 int64_t display_id,
214 Id focused_window_id, 240 Id focused_window_id,
215 bool drawn); 241 bool drawn);
216 242
243 // Called by WmNewDisplayAdded().
244 void WmNewDisplayAddedImpl(const display::Display& display,
245 mojom::WindowDataPtr root_data,
246 bool parent_drawn);
247
217 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle); 248 void OnReceivedCursorLocationMemory(mojo::ScopedSharedBufferHandle handle);
218 249
219 // Overridden from WindowTreeClient: 250 // Overridden from WindowTreeClient:
220 void OnEmbed(ClientSpecificId client_id, 251 void OnEmbed(ClientSpecificId client_id,
221 mojom::WindowDataPtr root, 252 mojom::WindowDataPtr root,
222 mojom::WindowTreePtr tree, 253 mojom::WindowTreePtr tree,
223 int64_t display_id, 254 int64_t display_id,
224 Id focused_window_id, 255 Id focused_window_id,
225 bool drawn) override; 256 bool drawn) override;
226 void OnEmbeddedAppDisconnected(Id window_id) override; 257 void OnEmbeddedAppDisconnected(Id window_id) override;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 uint32_t event_observer_id) override; 297 uint32_t event_observer_id) override;
267 void OnWindowFocused(Id focused_window_id) override; 298 void OnWindowFocused(Id focused_window_id) override;
268 void OnWindowPredefinedCursorChanged(Id window_id, 299 void OnWindowPredefinedCursorChanged(Id window_id,
269 mojom::Cursor cursor) override; 300 mojom::Cursor cursor) override;
270 void OnChangeCompleted(uint32_t change_id, bool success) override; 301 void OnChangeCompleted(uint32_t change_id, bool success) override;
271 void RequestClose(uint32_t window_id) override; 302 void RequestClose(uint32_t window_id) override;
272 void GetWindowManager( 303 void GetWindowManager(
273 mojo::AssociatedInterfaceRequest<WindowManager> internal) override; 304 mojo::AssociatedInterfaceRequest<WindowManager> internal) override;
274 305
275 // Overridden from WindowManager: 306 // Overridden from WindowManager:
307 void OnConnect(ClientSpecificId client_id) override;
308 void WmNewDisplayAdded(mojom::DisplayPtr display,
309 mojom::WindowDataPtr root_data,
310 bool parent_drawn) override;
276 void WmSetBounds(uint32_t change_id, 311 void WmSetBounds(uint32_t change_id,
277 Id window_id, 312 Id window_id,
278 const gfx::Rect& transit_bounds) override; 313 const gfx::Rect& transit_bounds) override;
279 void WmSetProperty(uint32_t change_id, 314 void WmSetProperty(uint32_t change_id,
280 Id window_id, 315 Id window_id,
281 const mojo::String& name, 316 const mojo::String& name,
282 mojo::Array<uint8_t> transit_data) override; 317 mojo::Array<uint8_t> transit_data) override;
283 void WmCreateTopLevelWindow(uint32_t change_id, 318 void WmCreateTopLevelWindow(uint32_t change_id,
284 ClientSpecificId requesting_client_id, 319 ClientSpecificId requesting_client_id,
285 mojo::Map<mojo::String, mojo::Array<uint8_t>> 320 mojo::Map<mojo::String, mojo::Array<uint8_t>>
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 uint32_t event_observer_id_ = 0u; 394 uint32_t event_observer_id_ = 0u;
360 395
361 base::WeakPtrFactory<WindowTreeClient> weak_factory_; 396 base::WeakPtrFactory<WindowTreeClient> weak_factory_;
362 397
363 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); 398 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient);
364 }; 399 };
365 400
366 } // namespace mus 401 } // namespace mus
367 402
368 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_ 403 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_TREE_CLIENT_H_
OLDNEW
« no previous file with comments | « components/mus/public/cpp/window_manager_delegate.h ('k') | components/mus/public/cpp/window_tree_client_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698