7 When the AGL project was started, weston was chosen as the compositor, which is
8 the reference implementation of a Wayland compositor, while for window management
9 functionality it relied on *ivi-shell* (In-Vehicle Infotainment) together
10 with an extension, called [wayland-ivi-exension](https://github.com/GENIVI/wayland-ivi-extension).
12 A demo platform image of AGL comes with a handful of demo applications, done
13 with the Qt, which abstracts the protocol communication between the client and
14 the compositor. Additional functionality was in place under the form of
15 library, to control and signal back to the compositor when applications were
16 started, among other things.
18 Management of applications, starting, running and stopping them is done in AGL
19 with AppFW [Application Framework Management](Application_Framework/01_Introduction.md),
20 which is an umbrella name to denote the suite of tools and daemons that handle
21 all of that. It is integrated with systemd and with the current security model.
22 Applications can use AppFW to hang off data, and to pass it down to
23 other services. Together with AppFW, applications could tell the compositor
24 which application to activate or to switch to.
27 ## Simplifying the graphical stack
29 Trimming down these abstractions, simplifying the way clients interact with the
30 compositor, and avoid using modules that aren't really maintained upstream were
31 the reasons behind looking at alternatives to ivi-shell. On the desktop,
32 [xdg-shell](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/raw/master/stable/xdg-shell/xdg-shell.xml)
33 is currently de-facto protocol for handling all window management related
36 Wayland protocol has a window-like interface embedded into its protocol (called
37 wl_shell), but *xdg-shell* has long time ago deprecated it and instead
38 of adding it in the wayland protocol namespace, it was integrated
39 together with some other useful protocols, into
40 [wayland-protocols](https://gitlab.freedesktop.org/wayland/wayland-protocols)
41 project. The whole purpose of wayland-protocols is to enhance the Wayland
42 protocol with new functionality and bring new extensions entirely. Compositors
43 are free to implement, modify, enhance, and add new extensions to
44 wayland-protocols but they need to do so in consensus.
46 Besides the core wayland protocol and extended functionality from
47 wayland-protocols, a compositor can provide and implement additional protocol
48 extensions (custom to that compositor). By using such private extensions we
49 align with the AGL project and its requirements, without compromising specific
50 functionality and allows to add or improve the current ones. With that in mind,
51 the approach was to create a new compositor, called
52 [agl-compositor](https://gerrit.automotivelinux.org/gerrit/admin/repos/src/agl-compositor)
53 and implement dedicated private extensions, rather than trying to modify weston
54 itself, which AGL project would have been required to keep and maintain for
57 ## A compositor based on libweston
59 The compositor used currently in AGL, just like weston, is built on top of
60 *libweston* and *libweston-desktop*. The latter, among other things, is required
61 as it provides the server side implementation of the xdg-shell protocol which
62 underlying toolkits (like Qt/Chromium project) makes use of to deliver
63 desktop-like functionality. The former is used to provide back-ends and
64 rendering support, effectively managing the HW, besides implementing the
67 The high-level goal of [libweston](https://wayland.pages.freedesktop.org/weston/toc/libweston.html) is
68 to decouple the compositor from the shell implementation.
70 Traditionally, clients were entirely separated from the window manager, the
71 desktop environment and the display server. In wayland all these are
72 conceptually under the same entity though they are implemented as different
73 (UNIX) processes, or as a different namespaces with front and back-end APIs,
74 exposed by libraries. The compositor and the shell driving the UI should be
75 seen as one and the same, and in practice, this happens on desktop
76 environments. For AGL, the shell client can be represented under different
77 forms, as well as the fact that the process management has another layer
78 baked-in to handle MAC (Mandatory Access Control) labels and use the
79 above-mentioned Application Framework. These are all tightly
80 integrated and therefore, the AGL compositor will not automatically start the
81 shell client, although there's code to handle that.
83 ## Specifying a shell client to be started by the compositor
85 Nevertheless, one can modify the configuration file, add the shell client path, and the
86 compositor will attempt to start it.
90 command=/path/to/your/client/shell
97 Compositors can define and implement custom extensions to further control
98 application behaviour. For AGL, we have two private extensions defined.
99 One targeted at defining surface roles commonly found in desktop environments
100 (like panels, and backgrounds), which a shell client would bind to, and one
101 targeted at regular application(s) that might require additional functionality:
102 being able to display/activate its own surface or other's application surface,
103 implement some kind of split screen management of windows, or
104 dialog/pop-ups that exhibit always-on-top property even if the active
105 surface has been changed.
107 ![Layers_And_Extensions](images/agl-compositor/drawing_shell.png)
109 Clients can make use of these private extensions to define other kind of roles
110 for instance dialog/pop-ups or full-screen roles, and split windows vertically or
111 horizontally. It includes the ability to activate other applications, assuming
112 that the surfaces have been created, and the capability of delaying
113 presentation for the client shell. Doing so, all the information is displayed
114 at once, rather than waiting for the toolkit to map/show the surface.
116 An application identification mechanism was required to be able to activate
117 other clients windows/surfaces. A string-based identifier name was chosen
118 which can be used by the client to set an application-based identifier using
119 the xdg-shell protocol. While there's nothing stopping the client to avoid
120 doing that, specifically, to avoid assigning an application identifier,
121 the compositor won't be able to find which surfaces matches to a particular
122 client, if one would want to activate/display it at some time in the future.
126 Client shellls can make use of this protocol to define panels and background
127 roles for different surfaces. It includes to ability to activate other
128 applications, assuming that those are already running. Activation happens by
129 using using the app_id, respectively using set_app_id request as defined by the
130 xdg-shell protocol. Established client-side implementation of the xdg-shelll
131 protocol will have a function exposed which can be used to set an application
132 identifier. Further more, the compositor will not present/display anything to
133 the user as long the `ready()` is not requested. So, after creating the surfaces
134 assigning them panel and/or background roles, and they're fully loaded,
135 the client can then issue `ready()` request and the compositor will start
138 Please consult the [protocol file](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/agl-compositor.git;a=blob_plain;f=protocol/agl-shell.xml;hb=refs/heads/master)
139 as that is the authoritative way of getting the latest version.
143 Version 2 of the agl-shell protocol, while it is is not obligatory to be
144 supported by the shell client, it adds two new events: bound_ok and bound_fail
147 It has been observed that in some cases where we do not explicitly have a knob
148 in the toolkit to tell whether the application is a regular one (which doesn't
149 need to bind to the agl-shell protocol) or a one that needs to implement
150 agl-shell protocol might result in terminating the wayland connection.
152 That happens because we can't have multiple clients bind to the agl-shell
153 protocol interface and was particularly visible when using regular
154 flutter applications with other shell clients (Qt homescreen, or WAM/chromum),
155 basically mashing together different kind of toolkits in the same image. Once
156 a client has already bound to the agl-shell protocol interface any other client
157 that attempts to do same will get its wayland connection severed and the
158 application will be terminated.
160 These two events provide a race-free method in which the clients can tell if
161 they're in charge (of being the shell client) or their just regular
162 applications. Explicitly implementing this protocol if you have other means to
163 specify which type of application it is running wouldn't be required nor
164 necessary. But by using the protocol we can provide the same thing,
165 programmatically, without fearing that the wayland connection might be
166 severed, and implicitly taking down the application.
170 Version 3 of the agl-shell protocol adds 4 more events to signal out when the
171 application state was changed: started, activated, deactivated and terminated.
173 Version 3 update was mostly prompted by an issue with start-up of applications
174 but also is part of the first steps to reduce and simplify a bit more
175 activation handling in the compositor. Specifically with this protocol update,
176 we can correctly orchestrate start-up and activation of applications.
178 At the moment of adding this protocol update, the default compositor behaviour
179 is to display/activate applications as soon they're started, a feature which
180 we've called activate-by-default (and which is turned on by default).
181 But users can choose to disable that in such a way that activation is entirely
182 driven the shell client.
184 Implicitly having this activate-by-default papered over various
185 issue when don't have that activation by default turned on. Supporting both
186 use-cases (activate-by-default, on and off) turned out to be cluster of
187 problems and regression over time. Not only that the amount of complexity in
188 the compositor is unwarranted and can simplified by telling the shell client
189 handle any window management interaction on its own.
191 Further more, with this protocol update we also includes some events already
192 present in the agl-shell-desktop protocol like deactivate and terminate.
196 Version 4 of the agl-shell protocol brings a new request,
197 "set_activate_region". This is a hint for the compositor to use a custom area
198 for activation, rather than inferring the activation area from the panels.
199 This is a work-around designed for toolkits which can't handle multiple
200 surfaces at the same, such that it can this achieve the same functionality as
201 having multiple surfaces, but instead have just a single main surface to
202 handle. The compositor will place other applications in the designated
203 activation region, and will activate/deactivate surfaces only that in region.
204 With a custom activation area that leaves portions of the output available to
205 the toolkit this means it can achieve a similar graphical outcome as if there
206 are panels. All the toolkits, including Qt are now using this approach, with only
207 CI using distinct surfaces with panels.
211 Version 5 of the agl-shell protocol brings a new request, "deactivate_app".
212 Similar to the activate request, this will hide the current active application.
213 Depending on the window role, this request will either display the previously
214 active window (or the background in case there's no previously active surface)
215 or temporarily (or until a 'activate_app' is called upon) hide the surface.
219 Version 6 of the agl-shell protocol, brings two new request, "set_app_float" and
220 "set_app_normal". The first one is a method to change the surface role, either
221 on the fly, or at start-up to behave like a dialog/pop-up window, which can be
222 positioned anywhere on the output. The later one, is useful to return the main
223 original surface role, as maximized.
227 Version 7 of the agl-shell protocol, brings one new request, "set_app_fullscreen".
228 This is similar to "set_app_float", but it changes the surface role to fullscreen.
229 Going back to the orignal, maximized role should be with "set_app_normal".
233 Version 8 of the agl-shell protocol, adds a new request, "set_app_output", and
234 a new event, "app_on_output". This request/event is useful to migrate
235 applications from one output to another and signal out when that happens.
239 Version 9 of the agl-shell protocol, adds a new request, "set_app_position". This
240 request only makes sense for float type of surface, which was previously set with
245 Version 10 of the agl-shell protocol, adds a new request, "set_app_scale".
246 Similar to the "set_app_position", the surface role must be a floating type,
247 before using this request. The app scale request is actually a resize
248 hint for the client to change its dimensions to the one specified in the
249 request arguments. The client should use [wp_viewporter
250 interface](https://wayland.app/protocols/viewporter#wp_viewporter) to perform
251 cropping and scaling.
255 Version 11 of the agl-shell protocol, adds a new request "set_app_split". This
256 request only handles a single level of tiling for practical reasons as to keep
257 implementation simple and straight forward. Apart from the usual, tile
258 horizontally, and vertically, two arguments can be used to customize handling.
259 One defines the width of the split window, such that clients can specify, in
260 absolute values, the size of the split window. The other is about keeping the
261 split window always present when activating other windows.
263 By default when activating a new windows, the split window roles are destroyed
264 and new activated window will be put in front. Making the split window sticky
265 would avoid doing that. Obviously trying to activate a window already active,
266 which has the sticky role won't be possible (it is already displayed).
268 ### agl-shell-desktop (deprecated, will be removed in future, see gRPC proxy)
270 This extension is targeted at keeping some of the functionally already
271 established in AGL as to a) allow applications display/activate other
272 surfaces/application window, and b) set further roles, specially dialog/window
273 pop-ups and split-type of surfaces.
275 Clients can make use of this protocol to set further roles, like independently
276 positioned pop-up dialog windows, split type of surfaces or fullscreen ones.
277 Additional roles, and implicitly functionality can be added by extending the
278 protocol. These roles serve as hints for the compositor and should be used
279 before the actual surface creation takes place, such that the compositor can
280 take the necessary steps to satisfy those requirements.
282 Please consult the [protocol file](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/agl-compositor.git;a=blob_plain;f=protocol/agl-shell-desktop.xml;hb=refs/heads/master)
283 as that is the authoritative way of getting the latest version.
285 #### Additional surface roles in agl-shell-desktop
287 Like mentioned earlier, the compositor is already making use of some (internal)
288 roles, and with this extension we add some further ones. These are:
290 * split (there's vertical and a horizontal one)
294 Internally these are encoded with different values such that there's a
295 translation needed, between the protocol values and the internal ones. Besides
296 the roles, additional data can to be passed on, but only depending on the role.
297 It is highly recommend **to avoid** using the protocol to pass down information
298 between different applications using this communication channel. It is only
299 intended to help out with demo applications. Other sharing mechanism are
300 available in the AGL project that can satisfy those requirements.
302 #### Receiving application state events from (other) applications
304 agl-shell-desktop exposes two events which client can install handlers for, one
305 that signals when regular xdg application have been created, and one that
306 signals state changes (active/hidden) as well as destroyed/no longer present
307 surfaces. These events can be useful to add additional functionality if
310 #### Activating (other) applications
312 Both agl-shell and agl-shell-desktop have requests to activate other
313 application based on their xdg-shell app_id. In case the application is
314 present/running, it will attempt to make the surface backing that application
315 the current activate one, with each output having independently active
318 ## gRPC proxy for window management
320 The gRPC proxy is an alternative to allow management of windows,
321 without the need for clients to "speak" native Wayland C code. Most major
322 languages have RPC bindings, and in AGL clients do not touch Wayland code
323 natively, using most of the time toolkits. It seemed reasonably to use gRPC
324 as a way to interact with the compositor. The way this works is that
325 there's proxy daemon started by the compositor which translates the gRPC
326 calls to Wayland ones, using agl-shell protocol. Events coming from the
327 compositor are handled by subscribing to RPC stream events, such that
328 clients can act upon as well, so it is not just one way interaction.
330 With respect to window management: placement, movement, and surface role
331 changes all should, and can be done with RPC. Some of the calls, specifically
332 background set-up or activation area, are still required to happen prior or
333 require wayland primitives which can't be passed between processes, so those
334 can't be used with RPC proxy.
336 In terms of API, the following are available: activation/deactivation,
337 role management, and events. All the message arguments are self-explanatory,
338 requiring always an app_id, in form of string and possibly an output, in
339 form a string as well. Toolkits can set/retrieve this information so refer
340 to the respective toolkit. At the wayland level, the app_id is set/get
341 with [xdg-shell](https://wayland.app/protocols/xdg-shell#xdg_toplevel:request:set_app_id)
342 whereas output from [wl_output interface](https://wayland.app/protocols/wayland#wl_output:event:name)
344 Activation and deactivation of applications:
347 rpc ActivateApp(ActivateRequest) returns (ActivateResponse) {}
348 rpc DeactivateApp(DeactivateRequest) returns (DeactivateResponse) {}
350 With the following message arguments:
353 message ActivateRequest {
355 string output_name = 2;
358 message ActivateResponse {
362 message DeactivateRequest {
366 message DeactivateResponse {
370 Management of surface roles can be done with these requests:
374 rpc SetAppSplit(SplitRequest) returns (SplitResponse) {}
375 rpc SetAppFloat(FloatRequest) returns (FloatResponse) {}
376 rpc SetAppFullscreen(FullscreenRequest) returns (FullscreenResponse) {}
377 rpc AppStatusState(AppStateRequest) returns (stream AppStateResponse) {}
378 rpc GetOutputs(OutputRequest) returns (ListOutputResponse) {}
379 rpc SetAppNormal(NormalRequest) returns (NormalResponse) {}
380 rpc SetAppOnOutput(AppOnOutputRequest) returns (AppOnOutputResponse) {}
381 rpc SetAppPosition(AppPositionRequest) returns (AppPositionResponse) {}
382 rpc SetAppScale(AppScaleRequest) returns (AppScaleResponse) {}
385 Message arguments are:
388 message SplitRequest {
390 int32 tile_orientation = 2;
393 string output_name = 5;
396 message SplitResponse {
399 message FloatRequest {
405 message FloatResponse {
408 message NormalRequest {
412 message NormalResponse {
415 message FullscreenRequest {
419 message FullscreenResponse {
422 message AppOnOutputRequest {
427 message AppOnOutputResponse {
430 message AppPositionRequest {
436 message AppPositionResponse {
439 message AppScaleRequest {
445 message AppScaleResponse {
449 Events which clients can subscribe to:
452 rpc AppStatusState(AppStateRequest) returns (stream AppStateResponse) {}
455 With the message arguments:
458 message AppStateRequest {
461 message AppStateResponse {
467 A C++ client implementation the gRPC API can be found in [agl-shell-activator](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/agl-shell-activator.git;a=tree;h=refs/heads/master;hb=refs/heads/master)
468 or in [window-management-client-grpc](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/window-management-client-grpc.git;a=tree;h=refs/heads/master;hb=refs/heads/master).
472 The activation and setting surface roles requires passing a Wayland output
473 (wl_output). The output is the wayland interface representation of an output
474 and is **mandatory** to pass it down to the compositor when activating a surface.
475 Clients can retrieve it (the output) if they wish to place the surface on other
476 outputs by using the toolkits that expose the Wayland objects. A human-like
477 representation is provided by either the toolkit, or by using other extensions
478 implemented by the client, for instance [xdg-output](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/raw/master/unstable/xdg-output/xdg-output-unstable-v1.xml)
479 is the one recommended way and provides a mapping between a human
480 representation of the output and the wayland one.
482 One can also choose the output where the application can start, by configuring
483 directly the AGL compositor. Under the `[output]` section one can use
484 `agl-shell-app-id=appid` restart the AGL compositor unitd systemd service and
485 start the application. Currently this *only* applies to regular applications, the
486 client shell having to handle it in the code.
488 ## Available toolkits, application conversions and available eco-systems
490 Users and OEM vendors alike have the possibility, depending on their use-cases,
491 to either use some kind of a toolkit (Qt/GTK) for writing application,
492 or use plain C and the wayland library to communicate with the compositor
493 directly, without any toolkit abstraction.
495 Currently, the demo applications in AGL use the Qt platform with Chromium being
496 at this phase, a second-class citizen, being currently in the works of
497 achieving the same level of integration as QtWayland (the underlying library that
498 abstracts the Wayland interaction) has at this moment. The Qt platform has
499 long been favoured in embedded systems so it feels natural why AGL project
500 chose it over other alternatives. In the same time, as web applications are
501 for quite some time now permeating the application development scene, it also
502 felt natural to add support for a runtime that gives that option, which in AGL
503 was achieved with the help of the Chromium project.
505 For normal applications, not needing the ability to activate or displaying
506 other's application surface, would basically mean that it would use what the
507 toolkit has to offer, simplifying the application handling even more. Under
508 Qt, the client shell can use QPA (Qt Platform Abstraction) to gain access to
509 Wayland primitives, and implicitly is being able use the private extensions.
511 ![Architecture Diagram](images/agl-compositor/arch_diagram.png)
513 On the Chromium side of things, that happens indirectly, as Chromium doesn't
514 expose the Wayland primitives. Not only that, but on the Chromium platform,
515 there's another mid-layer component, called [WAM](https://github.com/webosose/wam)
516 (WebApplicationManager) with the purpose of handling web applications life-cycle.
518 So, controlling and passing information from a web application, that resembles
519 that of a shell client, has to travel more than a few levels in the software
520 stack, until it reaches the lower layers in Chromium where the Wayland
521 communication and interaction takes place. Support for the private extension
522 was done at the Ozone interface abstraction, which Chromium projects uses now
523 to handle the display/graphical interaction with the lower stack levels.
525 ## How to integrate or incorporate your own UI
527 The Minimum Viable Product (MV) to be able to switch/change/replace the current
528 UI, depending on toolkit is to call `set_background()` and `set_ready()` requests
529 from the agl-shell client protocol.
531 This means that the toolkits need to provides access to Wayland primitives,
532 exposing them in a such that they can reach the client code. For instance,
533 Qt uses [QPA](https://wiki.qt.io/Qt_Platform_Abstraction), while
534 GTK can also expose it through similar ways.
535 Chromium/CEF and flutter platform do not explicitly expose the windowing system
536 (and implictly Wayland) and have that implemented at a lower level.
538 Further more, depending on the needs, one would also need to either use the
539 gRPC proxy API or just agl-shell protocol on its own. For instance for Qt and
540 flutter we now use a combination of both. In Qt, we use QPA and Wayland native
541 code to set the [background surface](https://gerrit.automotivelinux.org/gerrit/gitweb?p=apps/homescreen.git;a=blob;f=homescreen/src/main.cpp;h=a98a15bb0113f3b28c1766e79c5d3f2d0b20fac4;hb=refs/heads/master#l255),
542 while activation/deactivation and anything else is handled using gRPC API,
543 but in the [same application](https://gerrit.automotivelinux.org/gerrit/gitweb?p=apps/homescreen.git;a=blob;f=homescreen/src/main.cpp;h=a98a15bb0113f3b28c1766e79c5d3f2d0b20fac4;hb=refs/heads/master#l355).
545 In flutter because we can't reach Wayland code
546 from within the client, we handle the Wayland part in the
547 [flutter embedder](https://github.com/toyota-connected/ivi-homescreen/blob/agl/shell/wayland/window.cc#L95-L121)
548 whereas the activation is handled in [flutter-ics-homescreen](https://gerrit.automotivelinux.org/gerrit/gitweb?p=apps/flutter-ics-homescreen.git;a=blob;f=lib/data/data_providers/app_launcher.dart;h=8762643dba7f5a6e3ad2051749e30239743e759a;hb=HEAD)
550 Similarly, CEF/Chromium has the same thing, the background and ready to present
551 request is handled at the lower levels.
553 ### Simple shell client examples
555 An alternative to using toolkits is to avoid using any of them and
556 instead use native Wayland C code to create a simple shell client. This
557 means the client needs to manage everything, including redrawing the
560 An example of that is
561 [native-shell-client](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src/native-shell-client.git;a=summary)
562 that is being used in the kvm images as a barebone shell client. Because that
563 just sets a black background matching the entire output you can have a
564 dedicated client that basically displays or mimics being fullscreen
565 (although technically it's set to maximized).
567 ## Streaming buffers and receiving events to and from remote outputs
569 Quite a common feature, in the infotainment market, is the ability to stream
570 out buffers/data to remote outputs. For instance, super-imposing the navigation
571 application, between the speedometer and tachometer, in the IC (Instrument
572 Cluster) of a car is such a scenario. Just like weston, the AGL compositor is
573 capable of loading up libweston modules and make use of them. And just like
574 weston, the AGL compositor loads up the remoting-plugin to achieve the same
577 The remoting-plugin uses the DRM virtual output API from libweston together
578 with gstreamer pipeline to capture, using DMA buffers, the DRM output and to
579 stream it, remotely to another machine. They can be over the network, or
582 Further more, to cope with situations where the output is just a
583 panel/display, without some kind of compositor driving it, the necessity of
584 handling input events is an important feature to have, giving the user to
585 possibility to manipulate the application/environment as he or she seems fit.
587 The compositor loads a plug-in that streams out the buffers to an output
588 remotely, with another plug-in was used to handle the input events. The events,
589 which are sent back from the display to the compositor, are generated with
590 the help of wayland-eque protocol that works over the network, called
591 [Waltham](https://github.com/waltham/waltham). This solution was deprecated
592 and removed a while back, with an alternative in the works to achieve
593 the same functionality.
595 Together, they provide proper means to achieve a seamless integration with
596 other display devices in the car cabin.
598 ## Policies and Role Base Arbitration
600 The compositor contains an API useful for implementing user-defined policies.
601 It contains a policy engine, and installs by default an allow-all kind of
602 policy. The policy engine controls if the client using the private extensions
603 is permitted to perform those calls. Not only that, but with some policies, it
604 won't allow the client to bind to the interfaces in the first place. That
605 happens with the deny-all policy, which is able to retrieve the client's
606 SMACK label and compares it with the ones statically defined.
608 In the works, there's a new policy model, called [Role Based
609 Arbitration](https://gerrit.automotivelinux.org/gerrit/admin/repos/staging/rba).
610 Internally, how it works, should be found at [RBA](04_Rule_Based_Arbitrator.md).
611 While the other two policies are embedded into the compositor, the RBA policy
612 model is an off the-shell policy. Obviously, vendors and users can hook up
613 their own policies, just like RBA did. These all work towards satisfying
614 the driver distraction mitigation requirement for the AGL project, as to avoid
615 overwhelming the driver with too much information.
617 Users wanting to create their own policy should create a specialized version
618 of the callbacks defined in `struct ivi_policy_api`.
620 As there's no dynamic loading of policies you'll need to recompile the compositor
621 with that policy in mind, specifically like the following:
623 $ meson -Dprefix=/path/to/install-compositor/ -Dpolicy-default=my_policy build_directory
625 The default policy found in src/policy-default.c should more than sufficient to
626 get started on creating new ones. Users can either re-purpose the default
627 policy or create a new one entirely different, based on their needs.
629 These are hooks in place by the policy engine control the creation, committing
630 and activation of surfaces (`ivi_policy_api::surface_create()`,
631 `ivi_policy_api::surface_commited()`, `ivi_policy_api::surface_activate()`),
632 among other situations.
634 Users can customize the hooks by using some sort of database to retrieve the
635 application name to compare against, or incorporate some kind of policy rule
636 engine. Alternatively, one can use the deny-all policy engine which allows the
637 top panel applications to be used/displayed as permitted applications.
641 The policy engine is stateful, and allows the ability to inject back events,
642 such that it allows the user to add custom rules into a policy and, depending
643 on the event received by the policy engine, to execute a rule match for that
644 event. Further more, the framework allows adding new states and events and the
645 default implementation has code for handling events like showing or hiding the
646 application specified in the policy rule. The most common example to exemplify
647 this feature is the ability to show a custom application, like displaying the
648 rear view camera application, when the automobile has been put in reverse.
650 For deadling with these kind of rules, `ivi_policy_api::policy_rule_allow_to_add()`
651 can be used to control if policy rules could be added or not. Finally, we have
652 `ivi_policy_api::policy_rule_try_event()` which is executed for each policy
653 rule added, by using the policy API `ivi_policy_add()` function.
655 By default the policy framework it will add the 'show', and 'hide' events and
656 the 'start', 'stop' and 'reverse' states. An special type, assigned by default
657 is 'invalid'. A **state change** has to be propagated to the compositor, which can
658 happen by using `ivi_policy_state_change()` function, and which signals the
659 compositor the state change took place, in order to apply the policy rules, and
660 implicitly to call the event handler `ivi_policy_api::policy_rule_try_event()`.
662 ## Back-ends and specific options for agl-compositor
664 The compositor has support for the following back-ends:
666 * **DRM/KMS** - runs a stand-alone back-end, uses Direct Rendering Manager/Kernel
667 Modesetting and evdev, that is utilizes and runs on real or virtualized HW
669 * **Wayland** - runs as a Wayland application, nested in another Wayland compositor
671 * **X11** - run as a x11 application, nested in a X11 display server instance
673 ### Building and running the compositor on different platforms
675 The compositor can run on desktop machines as easily as it does on AGL
676 platform. It should infer, depending on the environment, if it is being
677 compiled with the AGL SDK, or with the host build system. Running would also
678 be inferred from the environment.
680 The compositor has some additional configuration options like:
682 * `--debug` - enables the screenshooter interface, useful if one would want to
683 take a screenshot using `agl-screenshooter` client. This might be seen as a
684 security risk to it only be enabled in the AGL platform if built with agl-devel
687 Additional configuration ini options have been added to help with the CI
688 integration. Worth mentioning are:
690 * `activate-by-default=[true]` - if the surface of the client should be
691 displayed when the application started. Present in the `[core]` section.
692 By default set to `true`. Setting it to `false` will not activate,
693 by default, the client's surface when started.
694 * `hide-cursor=[false]` - do not advertise pointer/cursor to clients. Present
695 in the `[core]` section.
697 ## Running with software rendering
699 By default the compositor will attempt to use the GL-renderer, and implicitly
700 the GPU. One could instead use the CPU, by making use of the Pixman library. To
701 use it in the compositor append `--use-pixman` to the command line. This purely
702 software approach has the benefit that would not rely at all on any GL
703 implementatation or library. In constrast, even if the GL-renderer is used,
704 in some situations it won't be able to use the GPU supported implementation
705 and fallback to sofware based one, and for instance that might happen when
706 running in virtualized environments.
708 Both approaches could end up not actually using the GPU, but the latter does
709 actually use the GL library and perform the operations in software, while the
710 former does not use any GL whatsover. All back-ends support disabling the
711 GL-render to make sure it does not interfere with the composing process.
713 ## Multiple output set-up and touch input devices
715 There's no deterministic way in which the compositor enables the outputs and
716 depending on the input devices, specifically touch input devices, and the way
717 the connectors are wired, a touch input device might be associated with a
718 different output than the one intended.
720 A consistent way, that survives a reboot, is to use
721 [udev rules](https://man7.org/linux/man-pages/man7/udev.7.html), which
722 libweston would be able to use such that a particular output is tied/associated
723 to a particular touch input device.
725 For instance, assuming that you have a set-up consisting of 4 outputs, a 4
726 touch input devices, when the outputs are being enabled the compositor
727 front-end will associate all 4 touch input device -- if they haven't been
728 previously being associated to a particular output, to the first enabled
731 In order to avoid that, and associate each touch input device to
732 their respective output an udev rule can be installed, for the default
733 seat (named `seat0`).
735 Example of a udev rule:
738 SUBSYSTEM=="input", ATTRS{idVendor}=="222a", ATTRS{idProduct}=="004a", OWNER="display", ENV{ID_SEAT}="seat0", ENV{WL_OUTPUT}="HDMI-A-1"
739 SUBSYSTEM=="input", ATTRS{idVendor}=="222a", ATTRS{idProduct}=="004b", OWNER="display", ENV{ID_SEAT}="seat0", ENV{WL_OUTPUT}="HDMI-A-2"
740 SUBSYSTEM=="input", ATTRS{idVendor}=="222a", ATTRS{idProduct}=="004c", OWNER="display", ENV{ID_SEAT}="seat0", ENV{WL_OUTPUT}="HDMI-A-3"
741 SUBSYSTEM=="input", ATTRS{idVendor}=="222a", ATTRS{idProduct}=="004d", OWNER="display", ENV{ID_SEAT}="seat0", ENV{WL_OUTPUT}="HDMI-A-4"
744 Add the following under `/etc/udev/rules.d/91-output.rules` and reload udev
745 rules for these changes to take effect:
747 $ udevadm control --reload-rules && udevadm trigger
749 Note that in the above example, we use physical seat, named `seat0` which is
750 the default physical seat. You can verify that these changes have been applied by
751 checking the compositor logs (under `/run/platform/display/compositor.log` file)
752 You should be seeing `CONNECTOR-NO by udev` message like the following:
755 associating input device event0 with output HDMI-A-1 (HDMI-A-1 by udev)
761 associating input device event0 with output HDMI-A-2 (none by udev)
764 where the rules are either incorrect or badly written.
766 Retrieving device attributes could be done archaically using `lsusb` or `lspci`
767 or using `udevadm info -a /dev/input/event*` which can provide with a multitude
768 of attributes to use. In our above example we only relied `idVendor` and
769 `idProduct` but potentially other attributes might be used.