meson.build: Increase the build version of agl-compositor
[src/agl-compositor.git] / src / policy-default.c
1 #include "ivi-compositor.h"
2 #include "policy.h"
3
4 /*
5  * default policy implementation allows every action to be possible
6  *
7  * This is an example, that implements the API
8  *
9  * - policy_rule_allow_to_add is required in order to add further policy rules
10  * - policy_rule_try_event is a hook that should be implemented in order
11  *   for agl-shell-policy to work correctly.
12  */
13 static bool
14 ivi_policy_default_surface_create(struct ivi_surface *surf, void *user_data)
15 {
16         /* verify that the surface should be created */
17         return true;
18 }
19
20 static bool
21 ivi_policy_default_surface_commmited(struct ivi_surface *surf, void *user_data)
22 {
23         /* verify that the surface should be commited */
24         return true;
25 }
26
27 static bool
28 ivi_policy_default_surface_activate(struct ivi_surface *surf, void *user_data)
29 {
30         /* verify that the surface shuld be switched to */
31         return true;
32 }
33
34 static bool
35 ivi_policy_default_allow_to_add(void *user_data)
36 {
37         /* verify that it can inject events with the protocol */
38         return true;
39 }
40
41 static void
42 ivi_policy_default_try_event(struct ivi_a_policy *a_policy)
43 {
44         uint32_t event = a_policy->event;
45
46         switch (event) {
47         case AGL_SHELL_POLICY_EVENT_SHOW:
48                 ivi_layout_activate(a_policy->output, a_policy->app_id);
49                 break;
50         case AGL_SHELL_POLICY_EVENT_HIDE:
51                 /* FIXME: remove the active one, like basically unmap it? */
52         default:
53                 break;
54         }
55 }
56
57 static const struct ivi_policy_api policy_api = {
58         .struct_size = sizeof(policy_api),
59         .surface_create = ivi_policy_default_surface_create,
60         .surface_commited = ivi_policy_default_surface_commmited,
61         .surface_activate = ivi_policy_default_surface_activate,
62         .policy_rule_allow_to_add = ivi_policy_default_allow_to_add,
63         .policy_rule_try_event = ivi_policy_default_try_event,
64 };
65
66 int
67 ivi_policy_init(struct ivi_compositor *ivi)
68 {
69         ivi->policy = ivi_policy_create(ivi, &policy_api, ivi);
70         if (!ivi->policy)
71                 return -1;
72
73         return 0;
74 }