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)
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
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
28 #ifndef KEYROUTER_CLIENT_PROTOCOL_H
29 #define KEYROUTER_CLIENT_PROTOCOL_H
37 #include "wayland-client.h"
44 extern const struct wl_interface wl_keyrouter_interface;
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,
57 #endif /* WL_KEYROUTER_ERROR_ENUM */
59 #ifndef WL_KEYROUTER_MODE_ENUM
60 #define WL_KEYROUTER_MODE_ENUM
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
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.
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,
84 #endif /* WL_KEYROUTER_MODE_ENUM */
87 * wl_keyrouter - an interface to set each focus for each key
88 * @keygrab_notify: (none)
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.
96 struct wl_keyrouter_listener {
98 * keygrab_notify - (none)
104 void (*keygrab_notify)(void *data,
105 struct wl_keyrouter *wl_keyrouter,
106 struct wl_surface *surface,
113 wl_keyrouter_add_listener(struct wl_keyrouter *wl_keyrouter,
114 const struct wl_keyrouter_listener *listener, void *data)
116 return wl_proxy_add_listener((struct wl_proxy *) wl_keyrouter,
117 (void (**)(void)) listener, data);
120 #define WL_KEYROUTER_SET_KEYGRAB 0
121 #define WL_KEYROUTER_UNSET_KEYGRAB 1
122 #define WL_KEYROUTER_GET_KEYGRAB_STATUS 2
125 wl_keyrouter_set_user_data(struct wl_keyrouter *wl_keyrouter, void *user_data)
127 wl_proxy_set_user_data((struct wl_proxy *) wl_keyrouter, user_data);
131 wl_keyrouter_get_user_data(struct wl_keyrouter *wl_keyrouter)
133 return wl_proxy_get_user_data((struct wl_proxy *) wl_keyrouter);
137 wl_keyrouter_destroy(struct wl_keyrouter *wl_keyrouter)
139 wl_proxy_destroy((struct wl_proxy *) wl_keyrouter);
143 wl_keyrouter_set_keygrab(struct wl_keyrouter *wl_keyrouter, struct wl_surface *surface, uint32_t key, uint32_t mode)
145 wl_proxy_marshal((struct wl_proxy *) wl_keyrouter,
146 WL_KEYROUTER_SET_KEYGRAB, surface, key, mode);
150 wl_keyrouter_unset_keygrab(struct wl_keyrouter *wl_keyrouter, struct wl_surface *surface, uint32_t key)
152 wl_proxy_marshal((struct wl_proxy *) wl_keyrouter,
153 WL_KEYROUTER_UNSET_KEYGRAB, surface, key);
157 wl_keyrouter_get_keygrab_status(struct wl_keyrouter *wl_keyrouter, struct wl_surface *surface, uint32_t key)
159 wl_proxy_marshal((struct wl_proxy *) wl_keyrouter,
160 WL_KEYROUTER_GET_KEYGRAB_STATUS, surface, key);