DSWaylandServer: swap tizen_policy_ext files to tizen-policy-ext
[platform/core/uifw/libds.git] / src / DSWaylandServer / dswayland-server-tizen-policy-ext.h
1 /* Protocol XML file : wayland-extension/tizen-policy-ext.xml */
2
3 #ifndef __DS_TIZEN_POLICY_EXT_PROTOCOL_H__
4 #define __DS_TIZEN_POLICY_EXT_PROTOCOL_H__
5
6 #include "wayland-server-core.h"
7 #include "tizen-policy-ext-server-protocol.h"
8 #include <cstdio>
9 #include <cassert>
10 #include <string>
11 #include <map>
12 #include <algorithm>
13
14 #ifndef WAYLAND_VERSION_CHECK
15 #define WAYLAND_VERSION_CHECK(major, minor, micro) \
16     ((WAYLAND_VERSION_MAJOR > (major)) || \
17     (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR > (minor)) || \
18     (WAYLAND_VERSION_MAJOR == (major) && WAYLAND_VERSION_MINOR == (minor) && WAYLAND_VERSION_MICRO >= (micro)))
19 #endif
20
21
22 namespace DSWaylandServer {
23     class  tizen_policy_ext
24     {
25     public:
26         tizen_policy_ext(struct ::wl_client *client, uint32_t id, int version);
27         tizen_policy_ext(struct ::wl_display *display, int version);
28         tizen_policy_ext(struct ::wl_resource *resource);
29         tizen_policy_ext();
30
31         virtual ~tizen_policy_ext();
32
33         class Resource
34         {
35         public:
36             Resource() : tizen_policy_ext_object(NULL), handle(NULL) {}
37             virtual ~Resource() {}
38
39             tizen_policy_ext *tizen_policy_ext_object;
40             tizen_policy_ext *object() { return tizen_policy_ext_object; } 
41             struct ::wl_resource *handle;
42
43             struct ::wl_client *client() const { return wl_resource_get_client(handle); }
44             int version() const { return wl_resource_get_version(handle); }
45
46             static Resource *fromResource(struct ::wl_resource *resource);
47         };
48
49         void init(struct ::wl_client *client, uint32_t id, int version);
50         void init(struct ::wl_display *display, int version);
51         void init(struct ::wl_resource *resource);
52
53         Resource *add(struct ::wl_client *client, int version);
54         Resource *add(struct ::wl_client *client, uint32_t id, int version);
55         Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version);
56
57         Resource *resource() { return m_resource; }
58         const Resource *resource() const { return m_resource; }
59
60         std::multimap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }
61         const std::multimap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }
62
63         bool isGlobal() const { return m_global != NULL; }
64         bool isResource() const { return m_resource != NULL; }
65
66         static const struct ::wl_interface *interface();
67         static std::string interfaceName() { return interface()->name; }
68         static int interfaceVersion() { return interface()->version; }
69
70
71         void send_active_angle(uint32_t angle);
72         void send_active_angle(struct ::wl_resource *resource, uint32_t angle);
73
74     protected:
75         virtual Resource *tizen_policy_ext_allocate();
76
77         virtual void tizen_policy_ext_bind_resource(Resource *resource);
78         virtual void tizen_policy_ext_destroy_resource(Resource *resource);
79
80         virtual void tizen_policy_ext_get_rotation(Resource *resource, uint32_t id, struct ::wl_resource *surface);
81         virtual void tizen_policy_ext_get_active_angle(Resource *resource, struct ::wl_resource *surface);
82
83     private:
84         static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);
85         static void destroy_func(struct ::wl_resource *client_resource);
86         static void display_destroy_func(struct ::wl_listener *listener, void *data);
87
88         Resource *bind(struct ::wl_client *client, uint32_t id, int version);
89         Resource *bind(struct ::wl_resource *handle);
90
91         static const struct ::tizen_policy_ext_interface m_tizen_policy_ext_interface;
92
93         static void handle_get_rotation(
94             ::wl_client *client,
95             struct wl_resource *resource,
96             uint32_t id,
97             struct ::wl_resource *surface);
98         static void handle_get_active_angle(
99             ::wl_client *client,
100             struct wl_resource *resource,
101             struct ::wl_resource *surface);
102
103         std::multimap<struct ::wl_client*, Resource*> m_resource_map;
104         Resource *m_resource;
105         struct ::wl_global *m_global;
106         uint32_t m_globalVersion;
107         struct DisplayDestroyedListener : ::wl_listener {
108             tizen_policy_ext *parent;
109             DisplayDestroyedListener(): parent(NULL) {}
110         };
111         DisplayDestroyedListener m_displayDestroyedListener;
112     };
113
114     class  tizen_rotation
115     {
116     public:
117         tizen_rotation(struct ::wl_client *client, uint32_t id, int version);
118         tizen_rotation(struct ::wl_display *display, int version);
119         tizen_rotation(struct ::wl_resource *resource);
120         tizen_rotation();
121
122         virtual ~tizen_rotation();
123
124         class Resource
125         {
126         public:
127             Resource() : tizen_rotation_object(NULL), handle(NULL) {}
128             virtual ~Resource() {}
129
130             tizen_rotation *tizen_rotation_object;
131             tizen_rotation *object() { return tizen_rotation_object; } 
132             struct ::wl_resource *handle;
133
134             struct ::wl_client *client() const { return wl_resource_get_client(handle); }
135             int version() const { return wl_resource_get_version(handle); }
136
137             static Resource *fromResource(struct ::wl_resource *resource);
138         };
139
140         void init(struct ::wl_client *client, uint32_t id, int version);
141         void init(struct ::wl_display *display, int version);
142         void init(struct ::wl_resource *resource);
143
144         Resource *add(struct ::wl_client *client, int version);
145         Resource *add(struct ::wl_client *client, uint32_t id, int version);
146         Resource *add(struct wl_list *resource_list, struct ::wl_client *client, uint32_t id, int version);
147
148         Resource *resource() { return m_resource; }
149         const Resource *resource() const { return m_resource; }
150
151         std::multimap<struct ::wl_client*, Resource*> resourceMap() { return m_resource_map; }
152         const std::multimap<struct ::wl_client*, Resource*> resourceMap() const { return m_resource_map; }
153
154         bool isGlobal() const { return m_global != NULL; }
155         bool isResource() const { return m_resource != NULL; }
156
157         static const struct ::wl_interface *interface();
158         static std::string interfaceName() { return interface()->name; }
159         static int interfaceVersion() { return interface()->version; }
160
161
162         enum angle {
163             angle_none = 0,
164             angle_0 = 1,
165             angle_90 = 2,
166             angle_180 = 4,
167             angle_270 = 8,
168         };
169
170         void send_available_angles_done(uint32_t angles);
171         void send_available_angles_done(struct ::wl_resource *resource, uint32_t angles);
172         void send_preferred_angle_done(uint32_t angle);
173         void send_preferred_angle_done(struct ::wl_resource *resource, uint32_t angle);
174         void send_angle_change(uint32_t angle, uint32_t serial);
175         void send_angle_change(struct ::wl_resource *resource, uint32_t angle, uint32_t serial);
176         void send_angle_change_with_resize(uint32_t angle, uint32_t serial, uint32_t width, uint32_t height);
177         void send_angle_change_with_resize(struct ::wl_resource *resource, uint32_t angle, uint32_t serial, uint32_t width, uint32_t height);
178
179     protected:
180         virtual Resource *tizen_rotation_allocate();
181
182         virtual void tizen_rotation_bind_resource(Resource *resource);
183         virtual void tizen_rotation_destroy_resource(Resource *resource);
184
185         virtual void tizen_rotation_destroy(Resource *resource);
186         virtual void tizen_rotation_set_available_angles(Resource *resource, uint32_t angles);
187         virtual void tizen_rotation_set_preferred_angle(Resource *resource, uint32_t angle);
188         virtual void tizen_rotation_ack_angle_change(Resource *resource, uint32_t serial);
189         virtual void tizen_rotation_set_geometry_hint(Resource *resource, uint32_t angle, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
190
191     private:
192         static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);
193         static void destroy_func(struct ::wl_resource *client_resource);
194         static void display_destroy_func(struct ::wl_listener *listener, void *data);
195
196         Resource *bind(struct ::wl_client *client, uint32_t id, int version);
197         Resource *bind(struct ::wl_resource *handle);
198
199         static const struct ::tizen_rotation_interface m_tizen_rotation_interface;
200
201         static void handle_destroy(
202             ::wl_client *client,
203             struct wl_resource *resource);
204         static void handle_set_available_angles(
205             ::wl_client *client,
206             struct wl_resource *resource,
207             uint32_t angles);
208         static void handle_set_preferred_angle(
209             ::wl_client *client,
210             struct wl_resource *resource,
211             uint32_t angle);
212         static void handle_ack_angle_change(
213             ::wl_client *client,
214             struct wl_resource *resource,
215             uint32_t serial);
216         static void handle_set_geometry_hint(
217             ::wl_client *client,
218             struct wl_resource *resource,
219             uint32_t angle,
220             uint32_t x,
221             uint32_t y,
222             uint32_t w,
223             uint32_t h);
224
225         std::multimap<struct ::wl_client*, Resource*> m_resource_map;
226         Resource *m_resource;
227         struct ::wl_global *m_global;
228         uint32_t m_globalVersion;
229         struct DisplayDestroyedListener : ::wl_listener {
230             tizen_rotation *parent;
231             DisplayDestroyedListener(): parent(NULL) {}
232         };
233         DisplayDestroyedListener m_displayDestroyedListener;
234     };
235 }
236
237 #endif