tree: 86d437d3f900bd4858eb130ebfbafc72654d96c6 [path history] [tgz]
  1. BUILD.gn
  2. DEPS
  3. OWNERS
  4. README.md
  5. client_change.cc
  6. client_change.h
  7. client_change_tracker.cc
  8. client_change_tracker.h
  9. client_root.cc
  10. client_root.h
  11. client_root_test_helper.cc
  12. client_root_test_helper.h
  13. client_root_unittest.cc
  14. common/
  15. drag_drop_delegate.cc
  16. drag_drop_delegate.h
  17. drag_drop_delegate_unittest.cc
  18. embedding.cc
  19. embedding.h
  20. embedding_unittest.cc
  21. event_injector.cc
  22. event_injector.h
  23. event_injector_unittest.cc
  24. event_observer_helper.cc
  25. event_observer_helper.h
  26. event_queue.cc
  27. event_queue.h
  28. event_queue_test_helper.cc
  29. event_queue_test_helper.h
  30. event_queue_unittest.cc
  31. event_test_utils.cc
  32. event_test_utils.h
  33. focus_handler.cc
  34. focus_handler.h
  35. focus_handler_unittest.cc
  36. gpu_host/
  37. host_context_factory.cc
  38. host_context_factory.h
  39. ids.h
  40. ime/
  41. injected_event_handler.cc
  42. injected_event_handler.h
  43. injected_event_handler_unittest.cc
  44. input_devices/
  45. proxy_window.cc
  46. proxy_window.h
  47. proxy_window_test_helper.cc
  48. proxy_window_test_helper.h
  49. proxy_window_unittest.cc
  50. public/
  51. remote_view_host/
  52. remoting_event_injector.cc
  53. remoting_event_injector.h
  54. screen_provider.cc
  55. screen_provider.h
  56. screen_provider_unittest.cc
  57. test_change_tracker.cc
  58. test_change_tracker.h
  59. test_screen_provider_observer.cc
  60. test_screen_provider_observer.h
  61. test_window_service_delegate.cc
  62. test_window_service_delegate.h
  63. test_window_tree_client.cc
  64. test_window_tree_client.h
  65. test_wm.mojom
  66. test_ws/
  67. top_level_proxy_window.h
  68. top_level_proxy_window_impl.cc
  69. top_level_proxy_window_impl.h
  70. topmost_window_observer.cc
  71. topmost_window_observer.h
  72. topmost_window_observer_unittest.cc
  73. user_activity_monitor.cc
  74. user_activity_monitor.h
  75. user_activity_monitor_unittest.cc
  76. window_delegate_impl.cc
  77. window_delegate_impl.h
  78. window_delegate_impl_unittest.cc
  79. window_manager_interface.h
  80. window_occlusion_change_builder.cc
  81. window_occlusion_change_builder.h
  82. window_properties.cc
  83. window_properties.h
  84. window_server_service_test_base.cc
  85. window_server_service_test_base.h
  86. window_server_test_impl.cc
  87. window_server_test_impl.h
  88. window_service.cc
  89. window_service.h
  90. window_service_delegate.cc
  91. window_service_delegate.h
  92. window_service_observer.h
  93. window_service_observer_unittest.cc
  94. window_service_test_helper.cc
  95. window_service_test_helper.h
  96. window_service_test_setup.cc
  97. window_service_test_setup.h
  98. window_service_unittest.cc
  99. window_tree.cc
  100. window_tree.h
  101. window_tree_binding.cc
  102. window_tree_binding.h
  103. window_tree_client_unittest.cc
  104. window_tree_factory.cc
  105. window_tree_factory.h
  106. window_tree_test_helper.cc
  107. window_tree_test_helper.h
  108. window_tree_unittest.cc
  109. window_utils.cc
  110. window_utils.h
services/ws/README.md

This directory contains the code for building a Window Service implementation on top of an existing Aura hierarchy.

Each client is managed by an instance of WindowTree. In this directory, a client generally means a unique connection to the WindowService. More specifically a client is an implementation of ws::mojom::WindowTreeClient. WindowTree implements the ws::mojom::WindowTree implementation that is passed to the client. WindowTree creates a ClientRoot for the window the client is embedded in, as well as a ClientRoot for all top-level window requests.

Clients establish a connection to the WindowService by configuring Aura with a mode of MUS. See aura::Env::Mode for details.

The WindowService provides a way for one client to embed another client in a specific window (application composition). Embedding establishes a connection to a new client and provides the embedded client with a window to use. See the mojom for more details.

For example, on Chrome OS, Ash uses the WindowService to enable separate processes, such as the tap_visualizer, to connect to the WindowService. The tap_visualizer is a client of the WindowService. The tap_visualizer uses the WindowService to create and manage windows, receive events, and ultimately draw to the screen (using Viz). This is mostly seamless to the tap_visualizer. The tap_visualizer configures Views to use Mus, which results in Views and Aura, using the WindowService.

Ids

Each client connected to the Window Service is assigned a unique id inside the Window Service. This id is a monotonically increasing uint32_t. This is often referred to as the client_id.

As clients do not know their id, they always supply 0 as the client id in the mojom related functions. Internally the Window Service maps 0 to the real client id.

Windows have a couple of different (related) ids.

ClientWindowId

ClientWindowId is a uint64_t pairing of a client_id and a window_id. The window_id is a uint32_t assigned by the client, and should be unique within that client's scope. When communicating with the Window Service, clients may use 0 as the client_id to refer to their own windows. The Window Service maps 0 to the real client_id. In Window Service code the id from the client is typically referred to as the transport_window_id. Mojom functions that receive the transport_window_id map it to a ClientWindowId. ClientWindowId is a real class that provides type safety.

When a client is embedded in an existing window, the embedded client is given visibility to a Window created by the embedder. In this case the Window Service supplies the ClientWindowId to the embedded client and uses the ClientWindowId at the time the Window was created (the ClientWindowId actually comes from the FrameSinkId, see below for details on FrameSinkId). In other words, both the embedder and embedded client use the same ClientWindowId for the Window. See discussion on FrameSinkId for more details.

For a client to establish an embed root, it first calls ScheduleEmbedForExistingClient(), so it can provide a window_id that is unique within its own scope. That client then passes the returned token to what will become its embedder to call EmbedUsingToken(). In this case, the embedder and embedded client do not use the same ClientWindowId for the Window.

ClientWindowId is globally unique, but a Window may have multiple ClientWindowIds associated with it.

FrameSinkId

Each Window has a FrameSinkId that is needed for both hit-testing and embedding. The FrameSinkId is initialized to the ClientWindowId of the client creating the Window, but it changes during an embedding. In particular, when a client calls Embed() the FrameSinkId of the Window changes such that the client_id of the FrameSinkId matches the client_id of the client being embedded and the sink_id is set to 0. The embedder is informed of this by way of OnFrameSinkIdAllocated(). The embedded client is informed of the original FrameSinkId (the client_id of the FrameSinkId matches the embedder's client_id). In client code the embedded client ends up always using a client_id of 0 for the FrameSinkId. This works because Viz knows the real client_id and handles mapping 0 to the real client_id.

The FrameSinkId of top-level windows is set to the ClientWindowId from the client requesting the top-level (top-levels are created and owned by the Window Manager). The Window Manager is told the updated FrameSinkId when it is asked to create the top-level (WmCreateTopLevelWindow()).

The FrameSinkId of an embed root‘s Window is set to the ClientWindowId of the embed root’s Window from the embedded client.

LocalSurfaceId

The LocalSurfaceId (which contains unguessable) is necessary if the client wants to submit a compositor-frame for the Window (it wants to show something on screen), and not needed if the client only wants to submit a hit-test region. The LocalSurfaceId may be assigned when the bounds and/or device-scale-factor changes. The LocalSurfaceId can change at other times as well (perhaps to synchronize an effect with the embedded client). The LocalSurfaceId is intended to allow for smooth resizes and ensures at embed points the CompositorFrame from both clients match. Client code supplies a LocalSurfaceId for windows that have another client embedded in them as well as windows with a LayerTreeFrameSink. The LocalSurfaceId comes from the owner of the window. The embedded client is told of changes to the LocalSurfaceId by way of OnWindowBoundsChanged(). This is still very much a work in progress.

FrameSinkId is derived from the embedded client, where as LocalSurfaceId comes from the embedder.