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
This commit is contained in:
Eduardo Lima (Etrunko) 2012-11-21 22:17:45 +00:00 committed by Eduardo de Barros Lima
parent 167611c5f1
commit 267f9e2106
4 changed files with 61 additions and 67 deletions

View File

@ -5,20 +5,39 @@
/* Seat (input) handler */
static void _seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps);
static const struct wl_seat_listener engine_wayland_seat_listener =
{
engine_wayland_seat_handle_capabilities,
_seat_handle_capabilities,
};
/* Keyboard handler */
static void _keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size);
static void _keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys);
static void _keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface);
static void _keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
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);
static const struct wl_keyboard_listener engine_wayland_keyboard_listener =
{
engine_wayland_keyboard_handle_keymap,
engine_wayland_keyboard_handle_enter,
engine_wayland_keyboard_handle_leave,
engine_wayland_keyboard_handle_key,
engine_wayland_keyboard_handle_modifiers,
_keyboard_handle_keymap,
_keyboard_handle_enter,
_keyboard_handle_leave,
_keyboard_handle_key,
_keyboard_handle_modifiers,
};
/* Shell Surface handler */
static void _shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial);
static const struct wl_shell_surface_listener _shell_surface_listener =
{
_shell_surface_handle_ping,
NULL, /* configure */
NULL, /* popup_done */
};
/*
* Public
*/
void
engine_wayland_register_seat(struct wl_registry *registry, unsigned int id)
{
@ -26,8 +45,22 @@ engine_wayland_register_seat(struct wl_registry *registry, unsigned int id)
wl_seat_add_listener(seat, &engine_wayland_seat_listener, NULL);
}
void
engine_wayland_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps)
struct wl_shell_surface *
engine_wayland_create_shell_surface(struct wl_shell *shell, struct wl_surface *surface, const char *title)
{
struct wl_shell_surface *shell_surface = wl_shell_get_shell_surface(shell, surface);
wl_shell_surface_set_title(shell_surface, title);
wl_shell_surface_add_listener(shell_surface, &_shell_surface_listener, NULL);
wl_shell_surface_set_toplevel(shell_surface);
return shell_surface;
}
/*
* Static
*/
static void
_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps)
{
static struct wl_keyboard *kbd = NULL;
@ -43,23 +76,23 @@ engine_wayland_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *s
}
}
void
engine_wayland_keyboard_handle_keymap(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t format __UNUSED__, int fd __UNUSED__, uint32_t size __UNUSED__)
static void
_keyboard_handle_keymap(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t format __UNUSED__, int fd __UNUSED__, uint32_t size __UNUSED__)
{
}
void
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__)
static void
_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__)
{
}
void
engine_wayland_keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__)
static void
_keyboard_handle_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__)
{
}
void
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)
static void
_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)
{
const char *key_str;
@ -105,7 +138,14 @@ engine_wayland_keyboard_handle_key(void *data __UNUSED__, struct wl_keyboard *ke
}
}
void
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__)
static void
_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__)
{
}
static void
_shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, uint32_t serial)
{
wl_shell_surface_pong(shell_surface, serial);
}

View File

@ -4,16 +4,7 @@
#include <wayland-client.h>
void engine_wayland_register_seat(struct wl_registry *registry, unsigned int id);
/* Seat (input) handler */
void engine_wayland_seat_handle_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps);
/* Keyboard handler */
void engine_wayland_keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size);
void engine_wayland_keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys);
void engine_wayland_keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface);
void engine_wayland_keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
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);
struct wl_shell_surface *engine_wayland_create_shell_surface(struct wl_shell *shell, struct wl_surface *surface, const char *title);
#endif

View File

@ -31,15 +31,6 @@ static const struct wl_registry_listener _registry_listener =
NULL, /* global_remove */
};
/* Shell Surface handler */
static void _shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial);
static const struct wl_shell_surface_listener _shell_surface_listener =
{
_shell_surface_handle_ping,
NULL, /* configure */
NULL, /* popup_done */
};
/*
* API
*/
@ -66,10 +57,7 @@ engine_wayland_egl_args(const char *engine __UNUSED__, int width __UNUSED__, int
assert(wl.shell != NULL);
wl.surface = wl_compositor_create_surface(wl.compositor);
wl.shell_surface = wl_shell_get_shell_surface(wl.shell, wl.surface);
wl_shell_surface_set_title(wl.shell_surface, "Expedite Wayland EGL");
wl_shell_surface_add_listener(wl.shell_surface, &_shell_surface_listener, NULL);
wl_shell_surface_set_toplevel(wl.shell_surface);
wl.shell_surface = engine_wayland_create_shell_surface(wl.shell, wl.surface, "Expedite Wayland EGL");
einfo->info.display = wl.display;
einfo->info.surface = wl.surface;
@ -112,10 +100,3 @@ _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, uns
else if (!strcmp(interface, "wl_seat"))
engine_wayland_register_seat(registry, id);
}
static void
_shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, uint32_t serial)
{
wl_shell_surface_pong(shell_surface, serial);
}

View File

@ -42,15 +42,6 @@ static const struct wl_registry_listener _registry_listener =
NULL, /* global_remove */
};
/* Shell Surface handler */
static void _shell_surface_handle_ping(void *data, struct wl_shell_surface *shell_surface, uint32_t serial);
static const struct wl_shell_surface_listener _shell_surface_listener =
{
_shell_surface_handle_ping,
NULL, /* configure */
NULL, /* popup_done */
};
/* Frame handler */
static void _surface_frame_handle_complete(void *data, struct wl_callback *callback, uint32_t time __UNUSED__);
static const struct wl_callback_listener _surface_frame_listener =
@ -86,10 +77,7 @@ engine_wayland_shm_args(const char *engine __UNUSED__, int width, int height)
assert(wl.shm != NULL);
wl.surface = wl_compositor_create_surface(wl.compositor);
wl.shell_surface = wl_shell_get_shell_surface(wl.shell, wl.surface);
wl_shell_surface_set_title(wl.shell_surface, "Expedite Wayland SHM");
wl_shell_surface_add_listener(wl.shell_surface, &_shell_surface_listener, NULL);
wl_shell_surface_set_toplevel(wl.shell_surface);
wl.shell_surface = engine_wayland_create_shell_surface(wl.shell, wl.surface, "Expedite Wayland SHM");
_engine_wayland_shm_create_buffer(width, height);
@ -152,12 +140,6 @@ _registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, uns
engine_wayland_register_seat(registry, id);
}
static void
_shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell_surface, uint32_t serial)
{
wl_shell_surface_pong(shell_surface, serial);
}
static void
_engine_wayland_shm_create_buffer(int width, int height)
{