forked from enlightenment/expedite
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
This commit is contained in:
parent
d27dc525eb
commit
167611c5f1
|
@ -25,3 +25,7 @@
|
|||
2012-11-16 Eduardo Lima (Etrunko)
|
||||
|
||||
* Keyboard Support for Wayland EGL
|
||||
|
||||
2012-11-21 Eduardo Lima (Etrunko)
|
||||
|
||||
* Keyboard Support for Wayland SHM
|
||||
|
|
|
@ -222,6 +222,11 @@ expedite_SOURCES += \
|
|||
engine_software_16_wince.c engine_software_16_wince.h engine_software_16_wince.rc
|
||||
endif
|
||||
|
||||
if BUILD_WAYLAND
|
||||
expedite_SOURCES += \
|
||||
engine_wayland_common.c engine_wayland_common.h
|
||||
endif
|
||||
|
||||
if BUILD_WAYLAND_EGL
|
||||
expedite_SOURCES += \
|
||||
engine_wayland_egl.c engine_wayland_egl.h
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
#include <linux/input.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "engine_wayland_common.h"
|
||||
|
||||
|
||||
/* Seat (input) handler */
|
||||
static const struct wl_seat_listener engine_wayland_seat_listener =
|
||||
{
|
||||
engine_wayland_seat_handle_capabilities,
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
void
|
||||
engine_wayland_register_seat(struct wl_registry *registry, unsigned int id)
|
||||
{
|
||||
struct wl_seat *seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
|
||||
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)
|
||||
{
|
||||
static struct wl_keyboard *kbd = NULL;
|
||||
|
||||
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !kbd)
|
||||
{
|
||||
kbd = wl_seat_get_keyboard(seat);
|
||||
wl_keyboard_add_listener(kbd, &engine_wayland_keyboard_listener, NULL);
|
||||
}
|
||||
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && kbd)
|
||||
{
|
||||
wl_keyboard_destroy(kbd);
|
||||
kbd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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__)
|
||||
{
|
||||
}
|
||||
|
||||
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__)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
engine_wayland_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)
|
||||
{
|
||||
const char *key_str;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case KEY_LEFT:
|
||||
key_str = "Left";
|
||||
break;
|
||||
|
||||
case KEY_RIGHT:
|
||||
key_str = "Right";
|
||||
break;
|
||||
|
||||
case KEY_ENTER:
|
||||
case KEY_KPENTER:
|
||||
key_str = "Return";
|
||||
break;
|
||||
|
||||
case KEY_ESC:
|
||||
key_str = "Escape";
|
||||
break;
|
||||
|
||||
default:
|
||||
key_str = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (key_str)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case WL_KEYBOARD_KEY_STATE_RELEASED:
|
||||
evas_event_feed_key_up(evas, key_str, key_str, NULL, NULL, 0, NULL);
|
||||
break;
|
||||
|
||||
case WL_KEYBOARD_KEY_STATE_PRESSED:
|
||||
evas_event_feed_key_down(evas, key_str, key_str, NULL, NULL, 0, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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__)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef ENGINE_WAYLAND_COMMON_H
|
||||
#define ENGINE_WAYLAND_COMMON_H
|
||||
|
||||
#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);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
#include "main.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
#include "main.h"
|
||||
#include "engine_wayland_common.h"
|
||||
|
||||
#include <Evas_Engine_Wayland_Egl.h>
|
||||
#include <wayland-client.h>
|
||||
|
@ -41,28 +40,6 @@ static const struct wl_shell_surface_listener _shell_surface_listener =
|
|||
NULL, /* popup_done */
|
||||
};
|
||||
|
||||
/* 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 _seat_listener =
|
||||
{
|
||||
_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 _keyboard_listener =
|
||||
{
|
||||
_keyboard_handle_keymap, /* keymap */
|
||||
_keyboard_handle_enter, /* enter */
|
||||
_keyboard_handle_leave, /* leave */
|
||||
_keyboard_handle_key,
|
||||
_keyboard_handle_modifiers, /* modifiers */
|
||||
};
|
||||
|
||||
/*
|
||||
* API
|
||||
*/
|
||||
|
@ -129,19 +106,11 @@ static void
|
|||
_registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__)
|
||||
{
|
||||
if (!strcmp(interface, "wl_compositor"))
|
||||
{
|
||||
wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
||||
}
|
||||
wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
||||
else if (!strcmp(interface, "wl_shell"))
|
||||
{
|
||||
wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
||||
}
|
||||
wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
||||
else if (!strcmp(interface, "wl_seat"))
|
||||
{
|
||||
struct wl_seat *seat;
|
||||
seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
|
||||
wl_seat_add_listener(seat, &_seat_listener, NULL);
|
||||
}
|
||||
engine_wayland_register_seat(registry, id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -150,86 +119,3 @@ _shell_surface_handle_ping(void *data __UNUSED__, struct wl_shell_surface *shell
|
|||
wl_shell_surface_pong(shell_surface, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
_seat_handle_capabilities(void *data __UNUSED__, struct wl_seat *seat, enum wl_seat_capability caps)
|
||||
{
|
||||
static struct wl_keyboard *kbd = NULL;
|
||||
|
||||
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !kbd)
|
||||
{
|
||||
kbd = wl_seat_get_keyboard(seat);
|
||||
wl_keyboard_add_listener(kbd, &_keyboard_listener, NULL);
|
||||
}
|
||||
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && kbd)
|
||||
{
|
||||
wl_keyboard_destroy(kbd);
|
||||
kbd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_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_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_leave(void *data __UNUSED__, struct wl_keyboard *keyboard __UNUSED__, uint32_t serial __UNUSED__, struct wl_surface *surface __UNUSED__)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case KEY_LEFT:
|
||||
key_str = "Left";
|
||||
break;
|
||||
|
||||
case KEY_RIGHT:
|
||||
key_str = "Right";
|
||||
break;
|
||||
|
||||
case KEY_ENTER:
|
||||
case KEY_KPENTER:
|
||||
key_str = "Return";
|
||||
break;
|
||||
|
||||
case KEY_ESC:
|
||||
key_str = "Escape";
|
||||
break;
|
||||
|
||||
default:
|
||||
key_str = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (key_str)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case WL_KEYBOARD_KEY_STATE_RELEASED:
|
||||
evas_event_feed_key_up(evas, key_str, key_str, NULL, NULL, 0, NULL);
|
||||
break;
|
||||
|
||||
case WL_KEYBOARD_KEY_STATE_PRESSED:
|
||||
evas_event_feed_key_down(evas, key_str, key_str, NULL, NULL, 0, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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__)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include "main.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "engine_wayland_common.h"
|
||||
|
||||
#include <Evas_Engine_Wayland_Shm.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
|
@ -142,17 +143,13 @@ static void
|
|||
_registry_handle_global(void *data __UNUSED__, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__)
|
||||
{
|
||||
if (!strcmp(interface, "wl_compositor"))
|
||||
{
|
||||
wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
||||
}
|
||||
wl.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
||||
else if (!strcmp(interface, "wl_shell"))
|
||||
{
|
||||
wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
||||
}
|
||||
wl.shell = wl_registry_bind(registry, id, &wl_shell_interface, 1);
|
||||
else if (!strcmp(interface, "wl_shm"))
|
||||
{
|
||||
wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
||||
}
|
||||
wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
||||
else if (!strcmp(interface, "wl_seat"))
|
||||
engine_wayland_register_seat(registry, id);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue