[3.0] Add key grab/ungrab interfaces for Tizen (X11/Wayland)
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / keyrouter-client-protocol.h
1 /* 
2  * Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.
3  * Contact: Sung-Jin Park (sj76.park@samsung.com),
4  * Jeonghyun Kang (jhyuni.kang@samsung.com)
5  * 
6  * Permission to use, copy, modify, distribute, and sell this
7  * software and its documentation for any purpose is hereby granted
8  * without fee, provided that the above copyright notice appear in
9  * all copies and that both that copyright notice and this permission
10  * notice appear in supporting documentation, and that the name of
11  * the copyright holders not be used in advertising or publicity
12  * pertaining to distribution of the software without specific,
13  * written prior permission.  The copyright holders make no
14  * representations about the suitability of this software for any
15  * purpose.  It is provided "as is" without express or implied
16  * warranty.
17  * 
18  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
19  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
23  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
25  * THIS SOFTWARE.
26  */
27
28 #ifndef KEYROUTER_CLIENT_PROTOCOL_H
29 #define KEYROUTER_CLIENT_PROTOCOL_H
30
31 #ifdef  __cplusplus
32 extern "C" {
33 #endif
34
35 #include <stdint.h>
36 #include <stddef.h>
37 #include "wayland-client.h"
38
39 struct wl_client;
40 struct wl_resource;
41
42 struct wl_keyrouter;
43
44 extern const struct wl_interface wl_keyrouter_interface;
45
46 #ifndef WL_KEYROUTER_ERROR_ENUM
47 #define WL_KEYROUTER_ERROR_ENUM
48 enum wl_keyrouter_error {
49         WL_KEYROUTER_ERROR_NONE = 0,
50         WL_KEYROUTER_ERROR_INVALID_SURFACE = 1,
51         WL_KEYROUTER_ERROR_INVALID_KEY = 2,
52         WL_KEYROUTER_ERROR_INVALID_MODE = 3,
53         WL_KEYROUTER_ERROR_GRABBED_ALREADY = 4,
54         WL_KEYROUTER_ERROR_NO_PERMISSION = 5,
55         WL_KEYROUTER_ERROR_NO_SYSTEM_RESOURCES = 6,
56 };
57 #endif /* WL_KEYROUTER_ERROR_ENUM */
58
59 #ifndef WL_KEYROUTER_MODE_ENUM
60 #define WL_KEYROUTER_MODE_ENUM
61 /**
62  * wl_keyrouter_mode - mode for a key grab
63  * @WL_KEYROUTER_MODE_NONE: none
64  * @WL_KEYROUTER_MODE_SHARED: mode to get a key grab with the other
65  *      client surfaces when the focused client surface gets the key
66  * @WL_KEYROUTER_MODE_TOPMOST: mode to get a key grab when the client
67  *      surface is the top most surface
68  * @WL_KEYROUTER_MODE_OVERRIDABLE_EXCLUSIVE: mode to get a key grab
69  *      exclusively, overridably regardless of the order in the surface stack
70  * @WL_KEYROUTER_MODE_EXCLUSIVE: mode to get a key grab exclusively
71  *      regardless of the order in surface stack
72  *
73  * This value is used to set a mode for a key grab. With this mode and
74  * the order of the surface between surfaces' stack, the compositor will
75  * determine the destination client surface.
76  */
77 enum wl_keyrouter_mode {
78         WL_KEYROUTER_MODE_NONE = 0,
79         WL_KEYROUTER_MODE_SHARED = 1,
80         WL_KEYROUTER_MODE_TOPMOST = 2,
81         WL_KEYROUTER_MODE_OVERRIDABLE_EXCLUSIVE = 3,
82         WL_KEYROUTER_MODE_EXCLUSIVE = 4,
83 };
84 #endif /* WL_KEYROUTER_MODE_ENUM */
85
86 /**
87  * wl_keyrouter - an interface to set each focus for each key
88  * @keygrab_notify: (none)
89  *
90  * In tradition, all the keys in a keyboard and a device on which some
91  * keys are attached will be sent to focus surface by default. Currently
92  * it's possible to set up each focus for each key in a keyboard and a
93  * device. Therefore, by setting a key grab for a surface, the owner of the
94  * surface will get the key event when it has the key grab for the key.
95  */
96 struct wl_keyrouter_listener {
97         /**
98          * keygrab_notify - (none)
99          * @surface: (none)
100          * @key: (none)
101          * @mode: (none)
102          * @error: (none)
103          */
104         void (*keygrab_notify)(void *data,
105                                struct wl_keyrouter *wl_keyrouter,
106                                struct wl_surface *surface,
107                                uint32_t key,
108                                uint32_t mode,
109                                uint32_t error);
110 };
111
112 static inline int
113 wl_keyrouter_add_listener(struct wl_keyrouter *wl_keyrouter,
114                           const struct wl_keyrouter_listener *listener, void *data)
115 {
116         return wl_proxy_add_listener((struct wl_proxy *) wl_keyrouter,
117                                      (void (**)(void)) listener, data);
118 }
119
120 #define WL_KEYROUTER_SET_KEYGRAB        0
121 #define WL_KEYROUTER_UNSET_KEYGRAB      1
122 #define WL_KEYROUTER_GET_KEYGRAB_STATUS 2
123
124 static inline void
125 wl_keyrouter_set_user_data(struct wl_keyrouter *wl_keyrouter, void *user_data)
126 {
127         wl_proxy_set_user_data((struct wl_proxy *) wl_keyrouter, user_data);
128 }
129
130 static inline void *
131 wl_keyrouter_get_user_data(struct wl_keyrouter *wl_keyrouter)
132 {
133         return wl_proxy_get_user_data((struct wl_proxy *) wl_keyrouter);
134 }
135
136 static inline void
137 wl_keyrouter_destroy(struct wl_keyrouter *wl_keyrouter)
138 {
139         wl_proxy_destroy((struct wl_proxy *) wl_keyrouter);
140 }
141
142 static inline void
143 wl_keyrouter_set_keygrab(struct wl_keyrouter *wl_keyrouter, struct wl_surface *surface, uint32_t key, uint32_t mode)
144 {
145         wl_proxy_marshal((struct wl_proxy *) wl_keyrouter,
146                          WL_KEYROUTER_SET_KEYGRAB, surface, key, mode);
147 }
148
149 static inline void
150 wl_keyrouter_unset_keygrab(struct wl_keyrouter *wl_keyrouter, struct wl_surface *surface, uint32_t key)
151 {
152         wl_proxy_marshal((struct wl_proxy *) wl_keyrouter,
153                          WL_KEYROUTER_UNSET_KEYGRAB, surface, key);
154 }
155
156 static inline void
157 wl_keyrouter_get_keygrab_status(struct wl_keyrouter *wl_keyrouter, struct wl_surface *surface, uint32_t key)
158 {
159         wl_proxy_marshal((struct wl_proxy *) wl_keyrouter,
160                          WL_KEYROUTER_GET_KEYGRAB_STATUS, surface, key);
161 }
162
163 #ifdef  __cplusplus
164 }
165 #endif
166
167 #endif