diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/bin/Makefile.am | 5 | ||||
-rw-r--r-- | src/bin/engine_wayland_common.c | 111 | ||||
-rw-r--r-- | src/bin/engine_wayland_common.h | 19 | ||||
-rw-r--r-- | src/bin/engine_wayland_egl.c | 124 | ||||
-rw-r--r-- | src/bin/engine_wayland_shm.c | 19 |
6 files changed, 152 insertions, 130 deletions
@@ -25,3 +25,7 @@ | |||
25 | 2012-11-16 Eduardo Lima (Etrunko) | 25 | 2012-11-16 Eduardo Lima (Etrunko) |
26 | 26 | ||
27 | * Keyboard Support for Wayland EGL | 27 | * Keyboard Support for Wayland EGL |
28 | |||
29 | 2012-11-21 Eduardo Lima (Etrunko) | ||
30 | |||
31 | * Keyboard Support for Wayland SHM | ||
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 0cd055a..fb2ccf4 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am | |||
@@ -222,6 +222,11 @@ expedite_SOURCES += \ | |||
222 | engine_software_16_wince.c engine_software_16_wince.h engine_software_16_wince.rc | 222 | engine_software_16_wince.c engine_software_16_wince.h engine_software_16_wince.rc |
223 | endif | 223 | endif |
224 | 224 | ||
225 | if BUILD_WAYLAND | ||
226 | expedite_SOURCES += \ | ||
227 | engine_wayland_common.c engine_wayland_common.h | ||
228 | endif | ||
229 | |||
225 | if BUILD_WAYLAND_EGL | 230 | if BUILD_WAYLAND_EGL |
226 | expedite_SOURCES += \ | 231 | expedite_SOURCES += \ |
227 | engine_wayland_egl.c engine_wayland_egl.h | 232 | engine_wayland_egl.c engine_wayland_egl.h |
diff --git a/src/bin/engine_wayland_common.c b/src/bin/engine_wayland_common.c new file mode 100644 index 0000000..9968f80 --- /dev/null +++ b/src/bin/engine_wayland_common.c | |||
@@ -0,0 +1,111 @@ | |||
1 | #include <linux/input.h> | ||
2 | |||
3 | #include "main.h" | ||
4 | #include "engine_wayland_common.h" | ||
5 | |||
6 | |||
7 | /* Seat (input) handler */ | ||
8 | static const struct wl_seat_listener engine_wayland_seat_listener = | ||
9 | { | ||
10 | engine_wayland_seat_handle_capabilities, | ||
11 | }; | ||
12 | |||
13 | static const struct wl_keyboard_listener engine_wayland_keyboard_listener = | ||
14 | { | ||
15 | engine_wayland_keyboard_handle_keymap, | ||
16 | engine_wayland_keyboard_handle_enter, | ||
17 | engine_wayland_keyboard_handle_leave, | ||
18 | engine_wayland_keyboard_handle_key, | ||
19 | engine_wayland_keyboard_handle_modifiers, | ||
20 | }; | ||
21 | |||
22 | void | ||
23 | engine_wayland_register_seat(struct wl_registry *registry, unsigned int id) | ||
24 | { | ||
25 | struct wl_seat *seat = wl_registry_bind(registry, id, &wl_seat_interface, 1); | ||
26 | wl_seat_add_listener(seat, &engine_wayland_seat_listener, NULL); | ||
27 | } | ||
28 | |||
29 | void | ||
30 | engine_wayland_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps) | ||
31 | { | ||
32 | static struct wl_keyboard *kbd = NULL; | ||
33 | |||
34 | if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !kbd) | ||
35 | { | ||
36 | kbd = wl_seat_get_keyboard(seat); | ||
37 | wl_keyboard_add_listener(kbd, &engine_wayland_keyboard_listener, NULL); | ||
38 | } | ||
39 | else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && kbd) | ||
40 | { | ||
41 | wl_keyboard_destroy(kbd); | ||
42 | kbd = NULL; | ||
43 | } | ||
44 | } | ||
45 | |||
46 | void | ||
47 | engine_wayland_keyboard_handle_keymap(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t format __UNUSED__, int fd __UNUSED__, uint32_t size __UNUSED__) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | void | ||
52 | engine_wayland_keyboard_handle_enter(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__, struct wl_array *keys __UNUSED__) | ||
53 | { | ||
54 | } | ||
55 | |||
56 | void | ||
57 | engine_wayland_keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__) | ||
58 | { | ||
59 | } | ||
60 | |||
61 | void | ||
62 | engine_wayland_keyboard_handle_key(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, uint32_t time __UNUSED__, uint32_t key, uint32_t state) | ||
63 | { | ||
64 | const char *key_str; | ||
65 | |||
66 | switch (key) | ||
67 | { | ||
68 | case KEY_LEFT: | ||
69 | key_str = "Left"; | ||
70 | break; | ||
71 | |||
72 | case KEY_RIGHT: | ||
73 | key_str = "Right"; | ||
74 | break; | ||
75 | |||
76 | case KEY_ENTER: | ||
77 | case KEY_KPENTER: | ||
78 | key_str = "Return"; | ||
79 | break; | ||
80 | |||
81 | case KEY_ESC: | ||
82 | key_str = "Escape"; | ||
83 | break; | ||
84 | |||
85 | default: | ||
86 | key_str = NULL; | ||
87 | break; | ||
88 | } | ||
89 | |||
90 | if (key_str) | ||
91 | { | ||
92 | switch (state) | ||
93 | { | ||
94 | case WL_KEYBOARD_KEY_STATE_RELEASED: | ||
95 | evas_event_feed_key_up(evas, key_str, key_str, NULL, NULL, 0, NULL); | ||
96 | break; | ||
97 | |||
98 | case WL_KEYBOARD_KEY_STATE_PRESSED: | ||
99 | evas_event_feed_key_down(evas, key_str, key_str, NULL, NULL, 0, NULL); | ||
100 | break; | ||
101 | |||
102 | default: | ||
103 | break; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | |||
108 | void | ||
109 | engine_wayland_keyboard_handle_modifiers(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, uint32_t mods_depressed __UNUSED__, uint32_t mods_latched __UNUSED__, uint32_t mods_locked __UNUSED__, uint32_t group __UNUSED__) | ||
110 | { | ||
111 | } | ||
diff --git a/src/bin/engine_wayland_common.h b/src/bin/engine_wayland_common.h new file mode 100644 index 0000000..ed839c2 --- /dev/null +++ b/src/bin/engine_wayland_common.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #ifndef ENGINE_WAYLAND_COMMON_H | ||
2 | #define ENGINE_WAYLAND_COMMON_H | ||
3 | |||
4 | #include <wayland-client.h> | ||
5 | |||
6 | void engine_wayland_register_seat(struct wl_registry *registry, unsigned int id); | ||
7 | |||
8 | /* Seat (input) handler */ | ||
9 | void engine_wayland_seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps); | ||
10 | |||
11 | /* Keyboard handler */ | ||
12 | void engine_wayland_keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size); | ||
13 | void engine_wayland_keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys); | ||
14 | void engine_wayland_keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface); | ||
15 | void engine_wayland_keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); | ||
16 | void engine_wayland_keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); | ||
17 | |||
18 | #endif | ||
19 | |||
diff --git a/src/bin/engine_wayland_egl.c b/src/bin/engine_wayland_egl.c index 6b91eb6..fe2cff9 100644 --- a/src/bin/engine_wayland_egl.c +++ b/src/bin/engine_wayland_egl.c | |||
@@ -1,9 +1,8 @@ | |||
1 | #include "main.h" | ||
2 | |||
3 | #include <string.h> | 1 | #include <string.h> |
4 | #include <assert.h> | 2 | #include <assert.h> |
5 | 3 | ||
6 | #include <linux/input.h> | 4 | #include "main.h" |
5 | #include "engine_wayland_common.h" | ||
7 | 6 | ||
8 | #include <Evas_Engine_Wayland_Egl.h> | 7 | #include <Evas_Engine_Wayland_Egl.h> |
9 | #include <wayland-client.h> | 8 | #include <wayland-client.h> |
@@ -41,28 +40,6 @@ static const struct wl_shell_surface_listener _shell_surface_listener = | |||
41 | NULL, /* popup_done */ | 40 | NULL, /* popup_done */ |
42 | }; | 41 | }; |
43 | 42 | ||
44 | /* Seat (input) handler */ | ||
45 | static void _seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps); | ||
46 | static const struct wl_seat_listener _seat_listener = | ||
47 | { | ||
48 | _seat_handle_capabilities, | ||
49 | }; | ||
50 | |||
51 | /* Keyboard handler */ | ||
52 | static void _keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size); | ||
53 | static void _keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys); | ||
54 | static void _keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface); | ||
55 | static void _keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state); | ||
56 | static void _keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group); | ||
57 | static const struct wl_keyboard_listener _keyboard_listener = | ||
58 | { | ||
59 | _keyboard_handle_keymap, /* keymap */ | ||
60 | _keyboard_handle_enter, /* enter */ | ||
61 | _keyboard_handle_leave, /* leave */ | ||
62 | _keyboard_handle_key, | ||
63 | _keyboard_handle_modifiers, /* modifiers */ | ||
64 | }; | ||
65 | |||
66 | /* | 43 | /* |
67 | * API | 44 | * API |
68 | */ | 45 | */ |
@@ -129,19 +106,11 @@ static void | |||
129 | _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__) | 106 | _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__) |
130 | { | 107 | { |
131 | if (!strcmp(interface, "wl_compositor")) | 108 | if (!strcmp(interface, "wl_compositor")) |
132 | { | 109 | wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); |
133 | wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); | ||
134 | } | ||
135 | else if (!strcmp(interface, "wl_shell")) | 110 | else if (!strcmp(interface, "wl_shell")) |
136 | { | 111 | wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); |
137 | wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); | ||
138 | } | ||
139 | else if (!strcmp(interface, "wl_seat")) | 112 | else if (!strcmp(interface, "wl_seat")) |
140 | { | 113 | engine_wayland_register_seat(registry, id); |
141 | struct wl_seat *seat; | ||
142 | seat = wl_registry_bind(registry, id, &wl_seat_interface, 1); | ||
143 | wl_seat_add_listener(seat, &_seat_listener, NULL); | ||
144 | } | ||
145 | } | 114 | } |
146 | 115 | ||
147 | static void | 116 | static void |
@@ -150,86 +119,3 @@ _shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell | |||
150 | wl_shell_surface_pong(shell_surface, serial); | 119 | wl_shell_surface_pong(shell_surface, serial); |
151 | } | 120 | } |
152 | 121 | ||
153 | static void | ||
154 | _seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps) | ||
155 | { | ||
156 | static struct wl_keyboard *kbd = NULL; | ||
157 | |||
158 | if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !kbd) | ||
159 | { | ||
160 | kbd = wl_seat_get_keyboard(seat); | ||
161 | wl_keyboard_add_listener(kbd, &_keyboard_listener, NULL); | ||
162 | } | ||
163 | else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && kbd) | ||
164 | { | ||
165 | wl_keyboard_destroy(kbd); | ||
166 | kbd = NULL; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | static void | ||
171 | _keyboard_handle_keymap(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t format __UNUSED__, int fd __UNUSED__, uint32_t size __UNUSED__) | ||
172 | { | ||
173 | } | ||
174 | |||
175 | static void | ||
176 | _keyboard_handle_enter(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__, struct wl_array *keys __UNUSED__) | ||
177 | { | ||
178 | } | ||
179 | |||
180 | static void | ||
181 | _keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__) | ||
182 | { | ||
183 | } | ||
184 | |||
185 | static void | ||
186 | _keyboard_handle_key(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, uint32_t time __UNUSED__, uint32_t key, uint32_t state) | ||
187 | { | ||
188 | const char *key_str; | ||
189 | |||
190 | switch (key) | ||
191 | { | ||
192 | case KEY_LEFT: | ||
193 | key_str = "Left"; | ||
194 | break; | ||
195 | |||
196 | case KEY_RIGHT: | ||
197 | key_str = "Right"; | ||
198 | break; | ||
199 | |||
200 | case KEY_ENTER: | ||
201 | case KEY_KPENTER: | ||
202 | key_str = "Return"; | ||
203 | break; | ||
204 | |||
205 | case KEY_ESC: | ||
206 | key_str = "Escape"; | ||
207 | break; | ||
208 | |||
209 | default: | ||
210 | key_str = NULL; | ||
211 | break; | ||
212 | } | ||
213 | |||
214 | if (key_str) | ||
215 | { | ||
216 | switch (state) | ||
217 | { | ||
218 | case WL_KEYBOARD_KEY_STATE_RELEASED: | ||
219 | evas_event_feed_key_up(evas, key_str, key_str, NULL, NULL, 0, NULL); | ||
220 | break; | ||
221 | |||
222 | case WL_KEYBOARD_KEY_STATE_PRESSED: | ||
223 | evas_event_feed_key_down(evas, key_str, key_str, NULL, NULL, 0, NULL); | ||
224 | break; | ||
225 | |||
226 | default: | ||
227 | break; | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | static void | ||
233 | _keyboard_handle_modifiers(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, uint32_t mods_depressed __UNUSED__, uint32_t mods_latched __UNUSED__, uint32_t mods_locked __UNUSED__, uint32_t group __UNUSED__) | ||
234 | { | ||
235 | } | ||
diff --git a/src/bin/engine_wayland_shm.c b/src/bin/engine_wayland_shm.c index 4ebe721..611aca2 100644 --- a/src/bin/engine_wayland_shm.c +++ b/src/bin/engine_wayland_shm.c | |||
@@ -1,10 +1,11 @@ | |||
1 | #include "main.h" | ||
2 | |||
3 | #include <stdio.h> | 1 | #include <stdio.h> |
4 | #include <string.h> | 2 | #include <string.h> |
5 | #include <assert.h> | 3 | #include <assert.h> |
6 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
7 | 5 | ||
6 | #include "main.h" | ||
7 | #include "engine_wayland_common.h" | ||
8 | |||
8 | #include <Evas_Engine_Wayland_Shm.h> | 9 | #include <Evas_Engine_Wayland_Shm.h> |
9 | #include <wayland-client.h> | 10 | #include <wayland-client.h> |
10 | 11 | ||
@@ -142,17 +143,13 @@ static void | |||
142 | _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__) | 143 | _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__) |
143 | { | 144 | { |
144 | if (!strcmp(interface, "wl_compositor")) | 145 | if (!strcmp(interface, "wl_compositor")) |
145 | { | 146 | wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); |
146 | wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1); | ||
147 | } | ||
148 | else if (!strcmp(interface, "wl_shell")) | 147 | else if (!strcmp(interface, "wl_shell")) |
149 | { | 148 | wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); |
150 | wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1); | ||
151 | } | ||
152 | else if (!strcmp(interface, "wl_shm")) | 149 | else if (!strcmp(interface, "wl_shm")) |
153 | { | 150 | wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); |
154 | wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); | 151 | else if (!strcmp(interface, "wl_seat")) |
155 | } | 152 | engine_wayland_register_seat(registry, id); |
156 | } | 153 | } |
157 | 154 | ||
158 | static void | 155 | static void |