summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Lima (Etrunko) <eduardo.lima@intel.com>2012-11-21 22:17:45 +0000
committerEduardo de Barros Lima <eblima@gmail.com>2012-11-21 22:17:45 +0000
commit267f9e21068595e44aa6f298046b51b12049e03a (patch)
treec7973a7197a931bd7a8a6f4b9426bc307bdaecca
parent167611c5f1b98e89094e36cf95ca694db99c5886 (diff)
Cleanup and Reuse Code
Most of those functions in engine_wayland_common.h should be static. Also, move the shell surface listener to the common codebase. Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com> SVN revision: 79526
-rw-r--r--src/bin/engine_wayland_common.c76
-rw-r--r--src/bin/engine_wayland_common.h11
-rw-r--r--src/bin/engine_wayland_egl.c21
-rw-r--r--src/bin/engine_wayland_shm.c20
4 files changed, 61 insertions, 67 deletions
diff --git a/src/bin/engine_wayland_common.c b/src/bin/engine_wayland_common.c
index 9968f80..2f82e6e 100644
--- a/src/bin/engine_wayland_common.c
+++ b/src/bin/engine_wayland_common.c
@@ -5,20 +5,39 @@
5 5
6 6
7/* Seat (input) handler */ 7/* Seat (input) handler */
8static void _seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps);
8static const struct wl_seat_listener engine_wayland_seat_listener = 9static const struct wl_seat_listener engine_wayland_seat_listener =
9{ 10{
10 engine_wayland_seat_handle_capabilities, 11 _seat_handle_capabilities,
11}; 12};
12 13
14/* Keyboard handler */
15static void _keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size);
16static void _keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys);
17static void _keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface);
18static void _keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
19static 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);
13static const struct wl_keyboard_listener engine_wayland_keyboard_listener = 20static const struct wl_keyboard_listener engine_wayland_keyboard_listener =
14{ 21{
15 engine_wayland_keyboard_handle_keymap, 22 _keyboard_handle_keymap,
16 engine_wayland_keyboard_handle_enter, 23 _keyboard_handle_enter,
17 engine_wayland_keyboard_handle_leave, 24 _keyboard_handle_leave,
18 engine_wayland_keyboard_handle_key, 25 _keyboard_handle_key,
19 engine_wayland_keyboard_handle_modifiers, 26 _keyboard_handle_modifiers,
20}; 27};
21 28
29/* Shell Surface handler */
30static void _shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial);
31static const struct wl_shell_surface_listener _shell_surface_listener =
32{
33 _shell_surface_handle_ping,
34 NULL, /* configure */
35 NULL, /* popup_done */
36};
37
38/*
39 * Public
40 */
22void 41void
23engine_wayland_register_seat(struct wl_registry *registry, unsigned int id) 42engine_wayland_register_seat(struct wl_registry *registry, unsigned int id)
24{ 43{
@@ -26,8 +45,22 @@ engine_wayland_register_seat(struct wl_registry *registry, unsigned int id)
26 wl_seat_add_listener(seat, &engine_wayland_seat_listener, NULL); 45 wl_seat_add_listener(seat, &engine_wayland_seat_listener, NULL);
27} 46}
28 47
29void 48struct wl_shell_surface *
30engine_wayland_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps) 49engine_wayland_create_shell_surface(struct wl_shell *shell, struct wl_surface *surface, const char *title)
50{
51 struct wl_shell_surface *shell_surface = wl_shell_get_shell_surface(shell, surface);
52 wl_shell_surface_set_title(shell_surface, title);
53 wl_shell_surface_add_listener(shell_surface, &_shell_surface_listener, NULL);
54 wl_shell_surface_set_toplevel(shell_surface);
55
56 return shell_surface;
57}
58
59/*
60 * Static
61 */
62static void
63_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps)
31{ 64{
32 static struct wl_keyboard *kbd = NULL; 65 static struct wl_keyboard *kbd = NULL;
33 66
@@ -43,23 +76,23 @@ engine_wayland_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *s
43 } 76 }
44} 77}
45 78
46void 79static void
47engine_wayland_keyboard_handle_keymap(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t format __UNUSED__, int fd __UNUSED__, uint32_t size __UNUSED__) 80_keyboard_handle_keymap(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t format __UNUSED__, int fd __UNUSED__, uint32_t size __UNUSED__)
48{ 81{
49} 82}
50 83
51void 84static void
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__) 85_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{ 86{
54} 87}
55 88
56void 89static void
57engine_wayland_keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__) 90_keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__)
58{ 91{
59} 92}
60 93
61void 94static void
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) 95_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{ 96{
64 const char *key_str; 97 const char *key_str;
65 98
@@ -105,7 +138,14 @@ engine_wayland_keyboard_handle_key(void *data __UNUSED__, struct wl_keyboard *ke
105 } 138 }
106} 139}
107 140
108void 141static void
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__) 142_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{ 143{
111} 144}
145
146static void
147_shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, uint32_t serial)
148{
149 wl_shell_surface_pong(shell_surface, serial);
150}
151
diff --git a/src/bin/engine_wayland_common.h b/src/bin/engine_wayland_common.h
index ed839c2..408b65d 100644
--- a/src/bin/engine_wayland_common.h
+++ b/src/bin/engine_wayland_common.h
@@ -4,16 +4,7 @@
4#include <wayland-client.h> 4#include <wayland-client.h>
5 5
6void engine_wayland_register_seat(struct wl_registry *registry, unsigned int id); 6void engine_wayland_register_seat(struct wl_registry *registry, unsigned int id);
7 7struct wl_shell_surface *engine_wayland_create_shell_surface(struct wl_shell *shell, struct wl_surface *surface, const char *title);
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 8
18#endif 9#endif
19 10
diff --git a/src/bin/engine_wayland_egl.c b/src/bin/engine_wayland_egl.c
index fe2cff9..cde38ca 100644
--- a/src/bin/engine_wayland_egl.c
+++ b/src/bin/engine_wayland_egl.c
@@ -31,15 +31,6 @@ static const struct wl_registry_listener _registry_listener =
31 NULL, /* global_remove */ 31 NULL, /* global_remove */
32}; 32};
33 33
34/* Shell Surface handler */
35static void _shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial);
36static const struct wl_shell_surface_listener _shell_surface_listener =
37{
38 _shell_surface_handle_ping,
39 NULL, /* configure */
40 NULL, /* popup_done */
41};
42
43/* 34/*
44 * API 35 * API
45 */ 36 */
@@ -66,10 +57,7 @@ engine_wayland_egl_args(const char *engine __UNUSED__, int width __UNUSED__, int
66 assert(wl.shell != NULL); 57 assert(wl.shell != NULL);
67 58
68 wl.surface = wl_compositor_create_surface(wl.compositor); 59 wl.surface = wl_compositor_create_surface(wl.compositor);
69 wl.shell_surface = wl_shell_get_shell_surface(wl.shell, wl.surface); 60 wl.shell_surface = engine_wayland_create_shell_surface(wl.shell, wl.surface, "Expedite Wayland EGL");
70 wl_shell_surface_set_title(wl.shell_surface, "Expedite Wayland EGL");
71 wl_shell_surface_add_listener(wl.shell_surface, &_shell_surface_listener, NULL);
72 wl_shell_surface_set_toplevel(wl.shell_surface);
73 61
74 einfo->info.display = wl.display; 62 einfo->info.display = wl.display;
75 einfo->info.surface = wl.surface; 63 einfo->info.surface = wl.surface;
@@ -112,10 +100,3 @@ _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, uns
112 else if (!strcmp(interface, "wl_seat")) 100 else if (!strcmp(interface, "wl_seat"))
113 engine_wayland_register_seat(registry, id); 101 engine_wayland_register_seat(registry, id);
114} 102}
115
116static void
117_shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, uint32_t serial)
118{
119 wl_shell_surface_pong(shell_surface, serial);
120}
121
diff --git a/src/bin/engine_wayland_shm.c b/src/bin/engine_wayland_shm.c
index 611aca2..b8d9bce 100644
--- a/src/bin/engine_wayland_shm.c
+++ b/src/bin/engine_wayland_shm.c
@@ -42,15 +42,6 @@ static const struct wl_registry_listener _registry_listener =
42 NULL, /* global_remove */ 42 NULL, /* global_remove */
43}; 43};
44 44
45/* Shell Surface handler */
46static void _shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial);
47static const struct wl_shell_surface_listener _shell_surface_listener =
48{
49 _shell_surface_handle_ping,
50 NULL, /* configure */
51 NULL, /* popup_done */
52};
53
54/* Frame handler */ 45/* Frame handler */
55static void _surface_frame_handle_complete(void *data, struct wl_callback *callback, uint32_t time __UNUSED__); 46static void _surface_frame_handle_complete(void *data, struct wl_callback *callback, uint32_t time __UNUSED__);
56static const struct wl_callback_listener _surface_frame_listener = 47static const struct wl_callback_listener _surface_frame_listener =
@@ -86,10 +77,7 @@ engine_wayland_shm_args(const char *engine __UNUSED__, int width, int height)
86 assert(wl.shm != NULL); 77 assert(wl.shm != NULL);
87 78
88 wl.surface = wl_compositor_create_surface(wl.compositor); 79 wl.surface = wl_compositor_create_surface(wl.compositor);
89 wl.shell_surface = wl_shell_get_shell_surface(wl.shell, wl.surface); 80 wl.shell_surface = engine_wayland_create_shell_surface(wl.shell, wl.surface, "Expedite Wayland SHM");
90 wl_shell_surface_set_title(wl.shell_surface, "Expedite Wayland SHM");
91 wl_shell_surface_add_listener(wl.shell_surface, &_shell_surface_listener, NULL);
92 wl_shell_surface_set_toplevel(wl.shell_surface);
93 81
94 _engine_wayland_shm_create_buffer(width, height); 82 _engine_wayland_shm_create_buffer(width, height);
95 83
@@ -153,12 +141,6 @@ _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, uns
153} 141}
154 142
155static void 143static void
156_shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, uint32_t serial)
157{
158 wl_shell_surface_pong(shell_surface, serial);
159}
160
161static void
162_engine_wayland_shm_create_buffer(int width, int height) 144_engine_wayland_shm_create_buffer(int width, int height)
163{ 145{
164 struct wl_shm_pool *pool; 146 struct wl_shm_pool *pool;