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

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

Issue 2018823002: Eliminate WindowTreeConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@connection
Patch Set: . 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_H_ 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_H_
6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_H_ 6 #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 class Size; 23 class Size;
24 } 24 }
25 25
26 namespace mus { 26 namespace mus {
27 27
28 class InputEventHandler; 28 class InputEventHandler;
29 class ServiceProviderImpl; 29 class ServiceProviderImpl;
30 class WindowObserver; 30 class WindowObserver;
31 class WindowSurface; 31 class WindowSurface;
32 class WindowSurfaceBinding; 32 class WindowSurfaceBinding;
33 class WindowTreeClientImpl; 33 class WindowTreeClient;
34 class WindowTreeClientImplPrivate; 34 class WindowTreeClientPrivate;
35 class WindowTreeConnection;
36 35
37 namespace { 36 namespace {
38 class OrderChangedNotifier; 37 class OrderChangedNotifier;
39 } 38 }
40 39
41 // Defined in window_property.h (which we do not include) 40 // Defined in window_property.h (which we do not include)
42 template <typename T> 41 template <typename T>
43 struct WindowProperty; 42 struct WindowProperty;
44 43
45 // Windows are owned by the WindowTreeConnection. See WindowTreeDelegate for 44 // Windows are owned by the WindowTreeClient. See WindowTreeClientDelegate for
46 // details on ownership. 45 // details on ownership.
47 // 46 //
48 // TODO(beng): Right now, you'll have to implement a WindowObserver to track 47 // TODO(beng): Right now, you'll have to implement a WindowObserver to track
49 // destruction and NULL any pointers you have. 48 // destruction and NULL any pointers you have.
50 // Investigate some kind of smart pointer or weak pointer for these. 49 // Investigate some kind of smart pointer or weak pointer for these.
51 class Window { 50 class Window {
52 public: 51 public:
53 using Children = std::vector<Window*>; 52 using Children = std::vector<Window*>;
54 using EmbedCallback = base::Callback<void(bool)>; 53 using EmbedCallback = base::Callback<void(bool)>;
55 using PropertyDeallocator = void (*)(int64_t value); 54 using PropertyDeallocator = void (*)(int64_t value);
56 using SharedProperties = std::map<std::string, std::vector<uint8_t>>; 55 using SharedProperties = std::map<std::string, std::vector<uint8_t>>;
57 56
58 // Destroys this window and all its children. Destruction is allowed for 57 // Destroys this window and all its children. Destruction is allowed for
59 // windows that were created by this connection, or the roots. For windows 58 // windows that were created by this connection, or the roots. For windows
60 // from other connections (except the roots), Destroy() does nothing. If the 59 // from other connections (except the roots), Destroy() does nothing. If the
61 // destruction is allowed observers are notified and the Window is 60 // destruction is allowed observers are notified and the Window is
62 // immediately deleted. 61 // immediately deleted.
63 void Destroy(); 62 void Destroy();
64 63
65 WindowTreeConnection* connection() { return connection_; } 64 WindowTreeClient* window_tree() { return client_; }
66 65
67 // The local_id is provided for client code. The local_id is not set or 66 // The local_id is provided for client code. The local_id is not set or
68 // manipulated by mus. The default value is -1. 67 // manipulated by mus. The default value is -1.
69 void set_local_id(int id) { local_id_ = id; } 68 void set_local_id(int id) { local_id_ = id; }
70 int local_id() const { return local_id_; } 69 int local_id() const { return local_id_; }
71 70
72 int64_t display_id() const { return display_id_; } 71 int64_t display_id() const { return display_id_; }
73 72
74 // Geometric disposition relative to parent window. 73 // Geometric disposition relative to parent window.
75 const gfx::Rect& bounds() const { return bounds_; } 74 const gfx::Rect& bounds() const { return bounds_; }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 197
199 Window* GetChildByLocalId(int id); 198 Window* GetChildByLocalId(int id);
200 199
201 void SetTextInputState(mojo::TextInputStatePtr state); 200 void SetTextInputState(mojo::TextInputStatePtr state);
202 void SetImeVisibility(bool visible, mojo::TextInputStatePtr state); 201 void SetImeVisibility(bool visible, mojo::TextInputStatePtr state);
203 202
204 bool HasCapture() const; 203 bool HasCapture() const;
205 void SetCapture(); 204 void SetCapture();
206 void ReleaseCapture(); 205 void ReleaseCapture();
207 206
208 // Focus. See WindowTreeConnection::ClearFocus() to reset focus. 207 // Focus. See WindowTreeClient::ClearFocus() to reset focus.
209 void SetFocus(); 208 void SetFocus();
210 bool HasFocus() const; 209 bool HasFocus() const;
211 void SetCanFocus(bool can_focus); 210 void SetCanFocus(bool can_focus);
212 211
213 // Embedding. See window_tree.mojom for details. 212 // Embedding. See window_tree.mojom for details.
214 void Embed(mus::mojom::WindowTreeClientPtr client); 213 void Embed(mus::mojom::WindowTreeClientPtr client);
215 214
216 // NOTE: callback is run synchronously if Embed() is not allowed on this 215 // NOTE: callback is run synchronously if Embed() is not allowed on this
217 // Window. 216 // Window.
218 void Embed(mus::mojom::WindowTreeClientPtr client, 217 void Embed(mus::mojom::WindowTreeClientPtr client,
219 const EmbedCallback& callback); 218 const EmbedCallback& callback);
220 219
221 // TODO(sky): this API is only applicable to the WindowManager. Move it 220 // TODO(sky): this API is only applicable to the WindowManager. Move it
222 // to a better place. 221 // to a better place.
223 void RequestClose(); 222 void RequestClose();
224 223
225 // Returns an internal name, set by a client app when it creates a window. 224 // Returns an internal name, set by a client app when it creates a window.
226 std::string GetName() const; 225 std::string GetName() const;
227 226
228 protected: 227 protected:
229 // This class is subclassed only by test classes that provide a public ctor. 228 // This class is subclassed only by test classes that provide a public ctor.
230 Window(); 229 Window();
231 ~Window(); 230 ~Window();
232 231
233 private: 232 private:
234 friend class WindowPrivate; 233 friend class WindowPrivate;
235 friend class WindowTreeClientImpl; 234 friend class WindowTreeClient;
236 friend class WindowTreeClientImplPrivate; 235 friend class WindowTreeClientPrivate;
237 236
238 Window(WindowTreeConnection* connection, Id id); 237 Window(WindowTreeClient* client, Id id);
239 238
240 // Used to identify this Window on the server. Clients can not change this 239 // Used to identify this Window on the server. Clients can not change this
241 // value. 240 // value.
242 Id server_id() const { return server_id_; } 241 Id server_id() const { return server_id_; }
243 242
244 WindowTreeClientImpl* tree_client();
245
246 // Applies a shared property change locally and forwards to the server. If 243 // Applies a shared property change locally and forwards to the server. If
247 // |data| is null, this property is deleted. 244 // |data| is null, this property is deleted.
248 void SetSharedPropertyInternal(const std::string& name, 245 void SetSharedPropertyInternal(const std::string& name,
249 const std::vector<uint8_t>* data); 246 const std::vector<uint8_t>* data);
250 // Called by the public {Set,Get,Clear}Property functions. 247 // Called by the public {Set,Get,Clear}Property functions.
251 int64_t SetLocalPropertyInternal(const void* key, 248 int64_t SetLocalPropertyInternal(const void* key,
252 const char* name, 249 const char* name,
253 PropertyDeallocator deallocator, 250 PropertyDeallocator deallocator,
254 int64_t value, 251 int64_t value,
255 int64_t default_value); 252 int64_t default_value);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 mojom::OrderDirection direction); 297 mojom::OrderDirection direction);
301 static bool ReorderImpl(Window* window, 298 static bool ReorderImpl(Window* window,
302 Window* relative, 299 Window* relative,
303 mojom::OrderDirection direction, 300 mojom::OrderDirection direction,
304 OrderChangedNotifier* notifier); 301 OrderChangedNotifier* notifier);
305 302
306 // Returns a pointer to the stacking target that can be used by 303 // Returns a pointer to the stacking target that can be used by
307 // RestackTransientDescendants. 304 // RestackTransientDescendants.
308 static Window** GetStackingTarget(Window* window); 305 static Window** GetStackingTarget(Window* window);
309 306
310 WindowTreeConnection* connection_; 307 WindowTreeClient* client_;
311 Id server_id_; 308 Id server_id_;
312 int local_id_ = -1; 309 int local_id_ = -1;
313 Window* parent_; 310 Window* parent_;
314 Children children_; 311 Children children_;
315 312
316 Window* stacking_target_; 313 Window* stacking_target_;
317 Window* transient_parent_; 314 Window* transient_parent_;
318 Children transient_children_; 315 Children transient_children_;
319 316
320 bool is_modal_; 317 bool is_modal_;
(...skipping 28 matching lines...) Expand all
349 }; 346 };
350 347
351 std::map<const void*, Value> prop_map_; 348 std::map<const void*, Value> prop_map_;
352 349
353 DISALLOW_COPY_AND_ASSIGN(Window); 350 DISALLOW_COPY_AND_ASSIGN(Window);
354 }; 351 };
355 352
356 } // namespace mus 353 } // namespace mus
357 354
358 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_H_ 355 #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_H_
OLDNEW
« no previous file with comments | « components/mus/public/cpp/tests/window_tree_client_unittest.cc ('k') | components/mus/public/cpp/window_tree_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698