policy: Init policy framework
[src/agl-compositor.git] / protocol / agl-shell-policy.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <protocol name="agl_shell_policy">
3   <copyright>
4     Copyright © 2020 Collabora, Ltd.
5
6     Permission is hereby granted, free of charge, to any person obtaining a
7     copy of this software and associated documentation files (the "Software"),
8     to deal in the Software without restriction, including without limitation
9     the rights to use, copy, modify, merge, publish, distribute, sublicense,
10     and/or sell copies of the Software, and to permit persons to whom the
11     Software is furnished to do so, subject to the following conditions:
12
13     The above copyright notice and this permission notice (including the next
14     paragraph) shall be included in all copies or substantial portions of the
15     Software.
16
17     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23     DEALINGS IN THE SOFTWARE.
24   </copyright>
25   <interface name="agl_shell_policy" version="1">
26     <description summary="Private extension for creating">
27       This protocol provides the means to signal state changes to the compositor
28       and to add generic policy rules. The client is ultimately responsible for
29       writing the policy management, as this only exposes the API to do so. Any
30       policy added with 'add' request should be also correlated with the
31       policy_api::policy_rule_try_event callback that it will receive
32       all the arguments passed in the 'add' request.
33
34       The callback receives all information provided in the 'add' request, and
35       will be executed once the state has been modified.
36       The initial state will be state to 'invalid', such that any state change
37       will trigger a check for all policy rules.
38
39       This extension provides by default, a few generic states (see state
40       enum) and a two default events (see event enum). Users can add additional
41       states and events using 'add_state' and 'add_event' request.
42       All the default states and events are already known so there's no need
43       them. Adding a new policy rule will verify if the states and events are known, so
44       it is required to add, before-hand, a new state or event.
45
46       Upon a state change, the client would inform the compositor using the
47       'apply' request that the current state has been modified.
48       The compositor will then verify if any of, previously added rule policies,
49       matches that of the state, and starts to execute the installed hooks for it.
50     </description>
51
52     <enum name="error">
53       <entry name="policy_exists" value="0"/>
54       <entry name="policy_not_allowed" value="1"/>
55       <entry name="policy_state_change_in_progress" value="2"/>
56       <entry name="policy_state_unknown" value="3"/>
57     </enum>
58
59     <enum name="state">
60       <entry name="invalid" value="0"/>
61
62       <entry name="stop" value="1"/>
63       <entry name="start" value="2"/>
64       <entry name="reverse" value="3"/>
65     </enum>
66
67     <enum name="event">
68       <entry name="show" value="0"/>
69       <entry name="hide" value="1"/>
70     </enum>
71
72     <request name="add_state">
73       <description summary="add a new state">
74         Add a new state to the state list.
75       </description>
76       <arg name="state" type="uint"/>
77       <arg name="value" type="string"/>
78     </request>
79
80     <request name="add_event">
81       <description summary="add a new event">
82         Add a new event the events list.
83       </description>
84       <arg name="event" type="uint"/>
85       <arg name="value" type="string"/>
86     </request>
87
88     <request name="add">
89       <description summary="add a rule policy">
90         Adds a policy rule for later processing, when the state change has been
91         requested upon 'apply' request. The timeout (expressed in ms) will only
92         be taken into consideration if bigger than zero.
93
94         Users wanting to check the 'event' or 'state' should alter the
95         hook associated with it.
96       </description>
97       <arg name="app_id" type="string"/>
98       <arg name="state" type="uint" enum="state"/>
99       <arg name="event" type="uint" enum="event"/>
100       <arg name="timeout" type="uint"/>
101       <arg name="output" type="object" interface="wl_output"/>
102     </request>
103
104     <request name="apply">
105       <description summary="state has changed">
106         Signals a state change, which should trigger a check of current
107         policy rules that were added so far. Users that require additional
108         states should use 'add_state' before in case they want to use that new
109         state. The same is valid for events.
110       </description>
111       <arg name="state" type="uint"/>
112     </request>
113
114     <event name="done">
115       <description summary="sent in response to apply">
116         Event sent when the 'apply' request has finished. Client should verify
117         that 'state' received back matches that the one being applied in the
118         'apply' request.
119
120         Do note, that an invalid state could be sent back by the compositor in
121         case of error.
122       </description>
123       <arg name="state" type="uint"/>
124     </event>
125
126
127   </interface>
128 </protocol>