summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Lima (Etrunko) <eduardo.lima@intel.com>2012-11-21 15:45:20 +0000
committerEduardo de Barros Lima <eblima@gmail.com>2012-11-21 15:45:20 +0000
commit167611c5f1b98e89094e36cf95ca694db99c5886 (patch)
tree78bc4671b14b87897508795c48828113e0d51671 /src
parentd27dc525ebd5553192f258ff9ffeedec2109e990 (diff)
Added support for wayland SHM too
Moved most of the seat/keyboard code to a common file so both shm and egl engines can reuse the code. Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com> SVN revision: 79516
Diffstat (limited to 'src')
-rw-r--r--src/bin/Makefile.am5
-rw-r--r--src/bin/engine_wayland_common.c111
-rw-r--r--src/bin/engine_wayland_common.h19
-rw-r--r--src/bin/engine_wayland_egl.c124
-rw-r--r--src/bin/engine_wayland_shm.c19
5 files changed, 148 insertions, 130 deletions
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 += \
222engine_software_16_wince.c engine_software_16_wince.h engine_software_16_wince.rc 222engine_software_16_wince.c engine_software_16_wince.h engine_software_16_wince.rc
223endif 223endif
224 224
225if BUILD_WAYLAND
226expedite_SOURCES += \
227engine_wayland_common.c engine_wayland_common.h
228endif
229
225if BUILD_WAYLAND_EGL 230if BUILD_WAYLAND_EGL
226expedite_SOURCES += \ 231expedite_SOURCES += \
227engine_wayland_egl.c engine_wayland_egl.h 232engine_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 */
8static const struct wl_seat_listener engine_wayland_seat_listener =
9{
10 engine_wayland_seat_handle_capabilities,
11};
12
13static 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
22void
23engine_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
29void
30engine_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
46void
47engine_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
51void
52engine_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
56void
57engine_wayland_keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__)
58{
59}
60
61void
62engine_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
108void
109engine_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
6void engine_wayland_register_seat(struct wl_registry *registry, unsigned int id);
7
8/* Seat (input) handler */
9void engine_wayland_seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps);
10
11/* Keyboard handler */
12void engine_wayland_keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size);
13void engine_wayland_keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys);
14void engine_wayland_keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface);
15void engine_wayland_keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
16void 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 */
45static void _seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps);
46static const struct wl_seat_listener _seat_listener =
47{
48 _seat_handle_capabilities,
49};
50
51/* Keyboard handler */
52static void _keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size);
53static void _keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys);
54static void _keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface);
55static void _keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
56static 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);
57static 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
147static void 116static 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
153static 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
170static 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
175static 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
180static 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
185static 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
232static 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
158static void 155static void