remove x11 dependencies
[platform/core/uifw/libeom.git] / protocol / eom-client-protocol.h
1 /*
2  * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
3  *
4  * Permission to use, copy, modify, distribute, and sell this
5  * software and its documentation for any purpose is hereby granted
6  * without fee, provided that\n the above copyright notice appear in
7  * all copies and that both that copyright notice and this permission
8  * notice appear in supporting documentation, and that the name of
9  * the copyright holders not be used in advertising or publicity
10  * pertaining to distribution of the software without specific,
11  * written prior permission.  The copyright holders make no
12  * representations about the suitability of this software for any
13  * purpose.  It is provided "as is" without express or implied
14  * warranty.
15  *
16  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
18  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
21  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
23  * THIS SOFTWARE.
24  */
25
26 #ifndef WL_EOM_CLIENT_PROTOCOL_H
27 #define WL_EOM_CLIENT_PROTOCOL_H
28
29 #ifdef  __cplusplus
30 extern "C" {
31 #endif
32
33 #include <stdint.h>
34 #include <stddef.h>
35 #include "wayland-client.h"
36
37 struct wl_client;
38 struct wl_resource;
39
40 struct wl_eom;
41 struct wl_shell_surface;
42 struct xdg_surface;
43
44 extern const struct wl_interface wl_eom_interface;
45
46 #ifndef WL_EOM_ERROR_ENUM
47 #define WL_EOM_ERROR_ENUM
48 enum wl_eom_error {
49         WL_EOM_ERROR_NONE = 0,
50         WL_EOM_ERROR_NO_OUTPUT = 1,
51         WL_EOM_ERROR_NO_ATTRIBUTE = 2,
52         WL_EOM_ERROR_OUTPUT_OCCUPIED = 3,
53 };
54 #endif /* WL_EOM_ERROR_ENUM */
55
56 #ifndef WL_EOM_TYPE_ENUM
57 #define WL_EOM_TYPE_ENUM
58 /**
59  * wl_eom_type - connector type
60  * @WL_EOM_TYPE_NONE: none
61  * @WL_EOM_TYPE_VGA: VGA output connector type
62  * @WL_EOM_TYPE_DVII: DVI-I output connector type
63  * @WL_EOM_TYPE_DVID: DVI-D output connector type
64  * @WL_EOM_TYPE_DVIA: DVI-A output connector type
65  * @WL_EOM_TYPE_COMPOSITE: Composite output connector type
66  * @WL_EOM_TYPE_SVIDEO: S-Video output connector type
67  * @WL_EOM_TYPE_LVDS: LVDS output connector type
68  * @WL_EOM_TYPE_COMPONENT: Component output connector type
69  * @WL_EOM_TYPE_9PINDIN: 9 pin DIN output connector type
70  * @WL_EOM_TYPE_DISPLAYPORT: DisplayPort output connector type
71  * @WL_EOM_TYPE_HDMIA: HDMI type A output connector type
72  * @WL_EOM_TYPE_HDMIB: HDMI type B output connector type
73  * @WL_EOM_TYPE_TV: TV output connector type
74  * @WL_EOM_TYPE_EDP: eDP output connector type
75  * @WL_EOM_TYPE_VIRTUAL: Virtual output connector type
76  * @WL_EOM_TYPE_DSI: DSI output connector type
77  *
78  * Define several connectors type of the external outputs
79  */
80 enum wl_eom_type {
81         WL_EOM_TYPE_NONE = 0,
82         WL_EOM_TYPE_VGA = 1,
83         WL_EOM_TYPE_DVII = 2,
84         WL_EOM_TYPE_DVID = 3,
85         WL_EOM_TYPE_DVIA = 4,
86         WL_EOM_TYPE_COMPOSITE = 5,
87         WL_EOM_TYPE_SVIDEO = 6,
88         WL_EOM_TYPE_LVDS = 7,
89         WL_EOM_TYPE_COMPONENT = 8,
90         WL_EOM_TYPE_9PINDIN = 9,
91         WL_EOM_TYPE_DISPLAYPORT = 10,
92         WL_EOM_TYPE_HDMIA = 11,
93         WL_EOM_TYPE_HDMIB = 12,
94         WL_EOM_TYPE_TV = 13,
95         WL_EOM_TYPE_EDP = 14,
96         WL_EOM_TYPE_VIRTUAL = 15,
97         WL_EOM_TYPE_DSI = 16,
98 };
99 #endif /* WL_EOM_TYPE_ENUM */
100
101 #ifndef WL_EOM_STATUS_ENUM
102 #define WL_EOM_STATUS_ENUM
103 /**
104  * wl_eom_status - connection status of the external output
105  * @WL_EOM_STATUS_NONE: none
106  * @WL_EOM_STATUS_CONNECTION: output connected
107  * @WL_EOM_STATUS_DISCONNECTION: output disconnected
108  *
109  * The status of external output is connected or not.
110  */
111 enum wl_eom_status {
112         WL_EOM_STATUS_NONE = 0,
113         WL_EOM_STATUS_CONNECTION = 1,
114         WL_EOM_STATUS_DISCONNECTION = 2,
115 };
116 #endif /* WL_EOM_STATUS_ENUM */
117
118 #ifndef WL_EOM_MODE_ENUM
119 #define WL_EOM_MODE_ENUM
120 /**
121  * wl_eom_mode - mode of the external output
122  * @WL_EOM_MODE_NONE: none
123  * @WL_EOM_MODE_MIRROR: mirror mode
124  * @WL_EOM_MODE_PRESENTATION: presentation mode
125  *
126  * There are two modes for external output. Mirror mode is showing main
127  * display screen to external output. Presentation mode is showing app's
128  * specific buffer contents to external output.
129  */
130 enum wl_eom_mode {
131         WL_EOM_MODE_NONE = 0,
132         WL_EOM_MODE_MIRROR = 1,
133         WL_EOM_MODE_PRESENTATION = 2,
134 };
135 #endif /* WL_EOM_MODE_ENUM */
136
137 #ifndef WL_EOM_ATTRIBUTE_ENUM
138 #define WL_EOM_ATTRIBUTE_ENUM
139 /**
140  * wl_eom_attribute - attribute of the external output
141  * @WL_EOM_ATTRIBUTE_NONE: none
142  * @WL_EOM_ATTRIBUTE_NORMAL: nomal attribute
143  * @WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARE: exclusive share attribute
144  * @WL_EOM_ATTRIBUTE_EXCLUSIVE: exclusive attribute
145  *
146  * Application can use external output by attribute.
147  *
148  * If application succeed to set attribute and set external output window,
149  * the external output's mode will be changed to Presentation mode.
150  *
151  * Attribute has priority. If attribute is set to normal, it can be changed
152  * by normal, exclusive_share, exclusive. If attribute is set to
153  * exclusive_share, it can be changed by exclusive_share, exclusive. If
154  * attribute is set to exclusive, it cannot be changed by other
155  * application. If application which set attribute is quit or set to none,
156  * the mode will be changed to Mirror if connected.
157  */
158 enum wl_eom_attribute {
159         WL_EOM_ATTRIBUTE_NONE = 0,
160         WL_EOM_ATTRIBUTE_NORMAL = 1,
161         WL_EOM_ATTRIBUTE_EXCLUSIVE_SHARE = 2,
162         WL_EOM_ATTRIBUTE_EXCLUSIVE = 3,
163 };
164 #endif /* WL_EOM_ATTRIBUTE_ENUM */
165
166 #ifndef WL_EOM_ATTRIBUTE_STATE_ENUM
167 #define WL_EOM_ATTRIBUTE_STATE_ENUM
168 /**
169  * wl_eom_attribute_state - state of the external output attribute
170  * @WL_EOM_ATTRIBUTE_STATE_NONE: none
171  * @WL_EOM_ATTRIBUTE_STATE_ACTIVE: attribute is active on the output
172  * @WL_EOM_ATTRIBUTE_STATE_INACTIVE: attribute is inactive on the output
173  * @WL_EOM_ATTRIBUTE_STATE_LOST: the connection of output is lost
174  *
175  * It means the state of attribute. The applicatoin which set attribute
176  * successful can get state.
177  *
178  * Active means the external window is set to external output succefully.
179  * So application can use that window. Inactive means cannot use external
180  * output, because of dissconnecting or some other reasons. But if
181  * connected again, the application can use external output. Lost means the
182  * application is lost it's right to external output by other application's
183  * attribute set.
184  */
185 enum wl_eom_attribute_state {
186         WL_EOM_ATTRIBUTE_STATE_NONE = 0,
187         WL_EOM_ATTRIBUTE_STATE_ACTIVE = 1,
188         WL_EOM_ATTRIBUTE_STATE_INACTIVE = 2,
189         WL_EOM_ATTRIBUTE_STATE_LOST = 3,
190 };
191 #endif /* WL_EOM_ATTRIBUTE_STATE_ENUM */
192
193 /**
194  * wl_eom - an interface for external outputs
195  * @output_count: external output count
196  * @output_info: 
197  * @output_type: output type and connection info
198  * @output_mode: output mode info
199  * @output_attribute: output attribute info
200  * @output_set_window: reslut of set_window
201  *
202  * An interface to get information of external outputs and to use
203  * external outputs.
204  */
205 struct wl_eom_listener {
206         /**
207          * output_count - external output count
208          * @count: (none)
209          *
210          * Get the number of external output devices that are supported
211          * by this device.
212          */
213         void (*output_count)(void *data,
214                              struct wl_eom *wl_eom,
215                              uint32_t count);
216         /**
217          * output_info - 
218          * @output_id: (none)
219          * @type: (none)
220          * @mode: (none)
221          * @w: (none)
222          * @h: (none)
223          * @w_mm: (none)
224          * @h_mm: (none)
225          * @connection: (none)
226          * @skip: (none)
227          * @attribute: (none)
228          * @attribute_state: (none)
229          * @error: (none)
230          *
231          * Send information of specific external output to client.
232          *
233          * Output_id is numbering of external outputs. It is fixed when
234          * booting time. The type, mode attribute, attribute_state is
235          * mentioned above. The w and h is the resolution of external
236          * output. The w_mm and h_mm is the physical size of external
237          * output. The unit is mm.
238          */
239         void (*output_info)(void *data,
240                             struct wl_eom *wl_eom,
241                             uint32_t output_id,
242                             uint32_t type,
243                             uint32_t mode,
244                             uint32_t w,
245                             uint32_t h,
246                             uint32_t w_mm,
247                             uint32_t h_mm,
248                             uint32_t connection,
249                             uint32_t skip,
250                             uint32_t attribute,
251                             uint32_t attribute_state,
252                             uint32_t error);
253         /**
254          * output_type - output type and connection info
255          * @output_id: (none)
256          * @type: (none)
257          * @status: (none)
258          *
259          * Send information of output type and connection.
260          */
261         void (*output_type)(void *data,
262                             struct wl_eom *wl_eom,
263                             uint32_t output_id,
264                             uint32_t type,
265                             uint32_t status);
266         /**
267          * output_mode - output mode info
268          * @output_id: (none)
269          * @mode: (none)
270          *
271          * Send information of output mode.
272          */
273         void (*output_mode)(void *data,
274                             struct wl_eom *wl_eom,
275                             uint32_t output_id,
276                             uint32_t mode);
277         /**
278          * output_attribute - output attribute info
279          * @output_id: (none)
280          * @attribute: (none)
281          * @attribute_state: (none)
282          * @error: (none)
283          *
284          * Send information of output attribute and attribute state.
285          */
286         void (*output_attribute)(void *data,
287                                  struct wl_eom *wl_eom,
288                                  uint32_t output_id,
289                                  uint32_t attribute,
290                                  uint32_t attribute_state,
291                                  uint32_t error);
292         /**
293          * output_set_window - reslut of set_window
294          * @output_id: (none)
295          * @error: (none)
296          *
297          * Send the result of set_window to client.
298          */
299         void (*output_set_window)(void *data,
300                                   struct wl_eom *wl_eom,
301                                   uint32_t output_id,
302                                   uint32_t error);
303 };
304
305 static inline int
306 wl_eom_add_listener(struct wl_eom *wl_eom,
307                     const struct wl_eom_listener *listener, void *data)
308 {
309         return wl_proxy_add_listener((struct wl_proxy *) wl_eom,
310                                      (void (**)(void)) listener, data);
311 }
312
313 #define WL_EOM_SET_ATTRIBUTE    0
314 #define WL_EOM_SET_XDG_WINDOW   1
315 #define WL_EOM_SET_SHELL_WINDOW 2
316 #define WL_EOM_GET_OUTPUT_INFO  3
317
318 #define WL_EOM_SET_ATTRIBUTE_SINCE_VERSION      1
319 #define WL_EOM_SET_XDG_WINDOW_SINCE_VERSION     1
320 #define WL_EOM_SET_SHELL_WINDOW_SINCE_VERSION   1
321 #define WL_EOM_GET_OUTPUT_INFO_SINCE_VERSION    1
322
323 static inline void
324 wl_eom_set_user_data(struct wl_eom *wl_eom, void *user_data)
325 {
326         wl_proxy_set_user_data((struct wl_proxy *) wl_eom, user_data);
327 }
328
329 static inline void *
330 wl_eom_get_user_data(struct wl_eom *wl_eom)
331 {
332         return wl_proxy_get_user_data((struct wl_proxy *) wl_eom);
333 }
334
335 static inline uint32_t
336 wl_eom_get_version(struct wl_eom *wl_eom)
337 {
338         return wl_proxy_get_version((struct wl_proxy *) wl_eom);
339 }
340
341 static inline void
342 wl_eom_destroy(struct wl_eom *wl_eom)
343 {
344         wl_proxy_destroy((struct wl_proxy *) wl_eom);
345 }
346
347 static inline void
348 wl_eom_set_attribute(struct wl_eom *wl_eom, uint32_t output_id, uint32_t attribute)
349 {
350         wl_proxy_marshal((struct wl_proxy *) wl_eom,
351                          WL_EOM_SET_ATTRIBUTE, output_id, attribute);
352 }
353
354 static inline void
355 wl_eom_set_xdg_window(struct wl_eom *wl_eom, uint32_t output_id, struct xdg_surface *surface)
356 {
357         wl_proxy_marshal((struct wl_proxy *) wl_eom,
358                          WL_EOM_SET_XDG_WINDOW, output_id, surface);
359 }
360
361 static inline void
362 wl_eom_set_shell_window(struct wl_eom *wl_eom, uint32_t output_id, struct wl_shell_surface *surface)
363 {
364         wl_proxy_marshal((struct wl_proxy *) wl_eom,
365                          WL_EOM_SET_SHELL_WINDOW, output_id, surface);
366 }
367
368 static inline void
369 wl_eom_get_output_info(struct wl_eom *wl_eom, uint32_t output_id)
370 {
371         wl_proxy_marshal((struct wl_proxy *) wl_eom,
372                          WL_EOM_GET_OUTPUT_INFO, output_id);
373 }
374
375 #ifdef  __cplusplus
376 }
377 #endif
378
379 #endif