| 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_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_WINDOW_H_ |
| 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_WINDOW_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/timer/timer.h" |
| 14 #include "mojo/public/cpp/bindings/array.h" | 15 #include "mojo/public/cpp/bindings/array.h" |
| 15 #include "services/shell/public/interfaces/interface_provider.mojom.h" | 16 #include "services/shell/public/interfaces/interface_provider.mojom.h" |
| 16 #include "services/ui/common/types.h" | 17 #include "services/ui/common/types.h" |
| 17 #include "services/ui/public/interfaces/mus_constants.mojom.h" | 18 #include "services/ui/public/interfaces/mus_constants.mojom.h" |
| 18 #include "services/ui/public/interfaces/window_tree.mojom.h" | 19 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 19 #include "ui/gfx/geometry/insets.h" | 20 #include "ui/gfx/geometry/insets.h" |
| 20 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
| 21 | 22 |
| 22 namespace gfx { | 23 namespace gfx { |
| 23 class Size; | 24 class Size; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // from other connections (except the roots), Destroy() does nothing. If the | 61 // from other connections (except the roots), Destroy() does nothing. If the |
| 61 // destruction is allowed observers are notified and the Window is | 62 // destruction is allowed observers are notified and the Window is |
| 62 // immediately deleted. | 63 // immediately deleted. |
| 63 void Destroy(); | 64 void Destroy(); |
| 64 | 65 |
| 65 // Returns true if this client created and owns this window. | 66 // Returns true if this client created and owns this window. |
| 66 bool WasCreatedByThisClient() const; | 67 bool WasCreatedByThisClient() const; |
| 67 | 68 |
| 68 WindowTreeClient* window_tree() { return client_; } | 69 WindowTreeClient* window_tree() { return client_; } |
| 69 | 70 |
| 71 void SetIsContainer(); |
| 72 |
| 70 // The local_id is provided for client code. The local_id is not set or | 73 // The local_id is provided for client code. The local_id is not set or |
| 71 // manipulated by mus. The default value is -1. | 74 // manipulated by mus. The default value is -1. |
| 72 void set_local_id(int id) { local_id_ = id; } | 75 void set_local_id(int id) { local_id_ = id; } |
| 73 int local_id() const { return local_id_; } | 76 int local_id() const { return local_id_; } |
| 74 | 77 |
| 75 int64_t display_id() const { return display_id_; } | 78 int64_t display_id() const { return display_id_; } |
| 76 | 79 |
| 77 // Geometric disposition relative to parent window. | 80 // Geometric disposition relative to parent window. |
| 78 const gfx::Rect& bounds() const { return bounds_; } | 81 const gfx::Rect& bounds() const { return bounds_; } |
| 79 void SetBounds(const gfx::Rect& bounds); | 82 void SetBounds(const gfx::Rect& bounds); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 260 |
| 258 // Tells the window manager to abort any current move initiated by | 261 // Tells the window manager to abort any current move initiated by |
| 259 // PerformWindowMove(). | 262 // PerformWindowMove(). |
| 260 void CancelWindowMove(); | 263 void CancelWindowMove(); |
| 261 | 264 |
| 262 // Returns an internal name, set by a client app when it creates a window. | 265 // Returns an internal name, set by a client app when it creates a window. |
| 263 std::string GetName() const; | 266 std::string GetName() const; |
| 264 | 267 |
| 265 protected: | 268 protected: |
| 266 // This class is subclassed only by test classes that provide a public ctor. | 269 // This class is subclassed only by test classes that provide a public ctor. |
| 267 Window(); | 270 Window(bool container = false); |
| 268 ~Window(); | 271 ~Window(); |
| 269 | 272 |
| 270 private: | 273 private: |
| 271 friend class WindowPrivate; | 274 friend class WindowPrivate; |
| 272 friend class WindowTreeClient; | 275 friend class WindowTreeClient; |
| 273 friend class WindowTreeClientPrivate; | 276 friend class WindowTreeClientPrivate; |
| 274 | 277 |
| 275 Window(WindowTreeClient* client, Id id); | 278 Window(WindowTreeClient* client, Id id, bool container = false); |
| 279 |
| 280 void WantToDraw(); |
| 281 void Draw(); |
| 276 | 282 |
| 277 // Used to identify this Window on the server. Clients can not change this | 283 // Used to identify this Window on the server. Clients can not change this |
| 278 // value. | 284 // value. |
| 279 Id server_id() const { return server_id_; } | 285 Id server_id() const { return server_id_; } |
| 280 | 286 |
| 281 // Applies a shared property change locally and forwards to the server. If | 287 // Applies a shared property change locally and forwards to the server. If |
| 282 // |data| is null, this property is deleted. | 288 // |data| is null, this property is deleted. |
| 283 void SetSharedPropertyInternal(const std::string& name, | 289 void SetSharedPropertyInternal(const std::string& name, |
| 284 const std::vector<uint8_t>* data); | 290 const std::vector<uint8_t>* data); |
| 285 // Called by the public {Set,Get,Clear}Property functions. | 291 // Called by the public {Set,Get,Clear}Property functions. |
| 286 int64_t SetLocalPropertyInternal(const void* key, | 292 int64_t SetLocalPropertyInternal(const void* key, |
| 287 const char* name, | 293 const char* name, |
| 288 PropertyDeallocator deallocator, | 294 PropertyDeallocator deallocator, |
| 289 int64_t value, | 295 int64_t value, |
| 290 int64_t default_value); | 296 int64_t default_value); |
| 291 int64_t GetLocalPropertyInternal(const void* key, | 297 int64_t GetLocalPropertyInternal(const void* key, |
| 292 int64_t default_value) const; | 298 int64_t default_value) const; |
| 293 | 299 |
| 294 void LocalDestroy(); | 300 void LocalDestroy(); |
| 295 void LocalAddChild(Window* child); | 301 void LocalAddChild(Window* child); |
| 296 void LocalRemoveChild(Window* child); | 302 void LocalRemoveChild(Window* child); |
| 297 void LocalAddTransientWindow(Window* transient_window); | 303 void LocalAddTransientWindow(Window* transient_window); |
| 298 void LocalRemoveTransientWindow(Window* transient_window); | 304 void LocalRemoveTransientWindow(Window* transient_window); |
| 299 void LocalSetModal(); | 305 void LocalSetModal(); |
| 300 // Returns true if the order actually changed. | 306 // Returns true if the order actually changed. |
| 301 bool LocalReorder(Window* relative, mojom::OrderDirection direction); | 307 bool LocalReorder(Window* relative, mojom::OrderDirection direction); |
| 302 void LocalSetBounds(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds); | 308 void LocalSetBounds(const gfx::Rect& old_bounds, const gfx::Rect& new_bounds); |
| 309 void LocalSetSurfaceId(const gfx::Size& size, |
| 310 float device_scale_factor, |
| 311 const cc::SurfaceId& surface_id, |
| 312 const cc::SurfaceSequence& surface_sequence); |
| 303 void LocalSetClientArea( | 313 void LocalSetClientArea( |
| 304 const gfx::Insets& new_client_area, | 314 const gfx::Insets& new_client_area, |
| 305 const std::vector<gfx::Rect>& additional_client_areas); | 315 const std::vector<gfx::Rect>& additional_client_areas); |
| 306 void LocalSetParentDrawn(bool drawn); | 316 void LocalSetParentDrawn(bool drawn); |
| 307 void LocalSetDisplay(int64_t display_id); | 317 void LocalSetDisplay(int64_t display_id); |
| 308 void LocalSetVisible(bool visible); | 318 void LocalSetVisible(bool visible); |
| 309 void LocalSetOpacity(float opacity); | 319 void LocalSetOpacity(float opacity); |
| 310 void LocalSetPredefinedCursor(mojom::Cursor cursor_id); | 320 void LocalSetPredefinedCursor(mojom::Cursor cursor_id); |
| 311 void LocalSetSharedProperty(const std::string& name, | 321 void LocalSetSharedProperty(const std::string& name, |
| 312 const std::vector<uint8_t>* data); | 322 const std::vector<uint8_t>* data); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 336 static bool ReorderImpl(Window* window, | 346 static bool ReorderImpl(Window* window, |
| 337 Window* relative, | 347 Window* relative, |
| 338 mojom::OrderDirection direction, | 348 mojom::OrderDirection direction, |
| 339 OrderChangedNotifier* notifier); | 349 OrderChangedNotifier* notifier); |
| 340 | 350 |
| 341 // Returns a pointer to the stacking target that can be used by | 351 // Returns a pointer to the stacking target that can be used by |
| 342 // RestackTransientDescendants. | 352 // RestackTransientDescendants. |
| 343 static Window** GetStackingTarget(Window* window); | 353 static Window** GetStackingTarget(Window* window); |
| 344 | 354 |
| 345 WindowTreeClient* client_; | 355 WindowTreeClient* client_; |
| 356 bool container_ = false; |
| 346 Id server_id_; | 357 Id server_id_; |
| 347 int local_id_ = -1; | 358 int local_id_ = -1; |
| 348 Window* parent_; | 359 Window* parent_; |
| 349 Children children_; | 360 Children children_; |
| 350 | 361 |
| 351 Window* stacking_target_; | 362 Window* stacking_target_; |
| 352 Window* transient_parent_; | 363 Window* transient_parent_; |
| 353 Children transient_children_; | 364 Children transient_children_; |
| 354 | 365 |
| 355 bool is_modal_; | 366 bool is_modal_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 386 // Key cannot be used for this purpose because it can be char* or | 397 // Key cannot be used for this purpose because it can be char* or |
| 387 // WindowProperty<>. | 398 // WindowProperty<>. |
| 388 struct Value { | 399 struct Value { |
| 389 const char* name; | 400 const char* name; |
| 390 int64_t value; | 401 int64_t value; |
| 391 PropertyDeallocator deallocator; | 402 PropertyDeallocator deallocator; |
| 392 }; | 403 }; |
| 393 | 404 |
| 394 std::map<const void*, Value> prop_map_; | 405 std::map<const void*, Value> prop_map_; |
| 395 | 406 |
| 407 base::Timer draw_timer_; |
| 408 |
| 409 struct SurfaceInfo { |
| 410 gfx::Size size; |
| 411 float device_scale_factor; |
| 412 cc::SurfaceId surface_id; |
| 413 cc::SurfaceSequence surface_sequence; |
| 414 }; |
| 415 SurfaceInfo surface_info_; |
| 416 std::unique_ptr<WindowSurface> container_surface_; |
| 417 |
| 418 base::WeakPtrFactory<Window> weak_factory_; |
| 419 |
| 396 DISALLOW_COPY_AND_ASSIGN(Window); | 420 DISALLOW_COPY_AND_ASSIGN(Window); |
| 397 }; | 421 }; |
| 398 | 422 |
| 399 } // namespace ui | 423 } // namespace ui |
| 400 | 424 |
| 401 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_H_ | 425 #endif // SERVICES_UI_PUBLIC_CPP_WINDOW_H_ |
| OLD | NEW |