Split evas from ecore_input

SVN revision: 44957
This commit is contained in:
Sebastian Dransfeld 2010-01-07 19:26:52 +00:00
parent 21ecfba7ad
commit b0a1a778a1
16 changed files with 555 additions and 347 deletions

View File

@ -121,6 +121,10 @@ if BUILD_ECORE_INPUT
pkgconfig_DATA += ecore-input.pc
endif
if BUILD_ECORE_INPUT_EVAS
pkgconfig_DATA += ecore-input-evas.pc
endif
if BUILD_ECORE_IPC
pkgconfig_DATA += ecore-ipc.pc
endif

View File

@ -45,6 +45,7 @@ case "$host_os" in
ecore_imf_evas_release_info="-release $release"
ecore_imf_release_info="-release $release"
ecore_input_release_info="-release $release"
ecore_input_evas_release_info="-release $release"
ecore_ipc_release_info="-release $release"
ecore_job_release_info="-release $release"
ecore_quartz_release_info="-release $release"
@ -64,6 +65,7 @@ AC_SUBST(ecore_file_release_info)
AC_SUBST(ecore_imf_evas_release_info)
AC_SUBST(ecore_imf_release_info)
AC_SUBST(ecore_input_release_info)
AC_SUBST(ecore_input_evas_release_info)
AC_SUBST(ecore_ipc_release_info)
AC_SUBST(ecore_job_release_info)
AC_SUBST(ecore_quartz_release_info)
@ -202,6 +204,7 @@ requirements_ecore_file=""
requirements_ecore_imf=""
requirements_ecore_imf_evas=""
requirements_ecore_input=""
requirements_ecore_input_evas=""
requirements_ecore_ipc=""
requirements_ecore_job=""
requirements_ecore_quartz=""
@ -373,6 +376,7 @@ requirements_ecore_file="ecore eina-0 ${requirements_ecore_file}"
requirements_ecore_imf="ecore eina-0 ${requirements_ecore_imf}"
requirements_ecore_imf_evas="ecore eina-0 ${requirements_ecore_imf_evas}"
requirements_ecore_input="ecore eina-0 ${requirements_ecore_input}"
requirements_ecore_input_evas="ecore eina-0 ${requirements_ecore_input_evas}"
requirements_ecore_ipc="ecore eina-0 ${requirements_ecore_ipc}"
requirements_ecore_job="ecore eina-0 ${requirements_ecore_job}"
requirements_ecore_quartz="ecore eina-0 ${requirements_ecore_quartz}"
@ -672,7 +676,7 @@ AM_CONDITIONAL(BUILD_ECORE_X_XLIB, test $have_ecore_x_xlib = yes)
AM_CONDITIONAL(BUILD_ECORE_X_XCB, test $have_ecore_x_xcb = yes)
# Evas library (ecore_config, ecore_input, ecore_imf_evas and ecore_evas)
# Evas library (ecore_config, ecore_input_evas, ecore_imf_evas and ecore_evas)
PKG_CHECK_MODULES([EVAS], [evas >= 0.9.9],
[have_evas="yes"],
@ -890,9 +894,10 @@ fi
ECORE_CHECK_MODULE([IMF_EVAS], [${want_ecore_imf}], [${ecore_imf_evas_deps}],
[requirements_ecore_imf_evas="ecore-imf evas ${requirements_ecore_imf_evas}"])
# ecore_input
ECORE_CHECK_MODULE([Input], [${want_ecore_input}], [${have_evas}],
[requirements_ecore_input="evas ${requirements_ecore_input}"])
# ecore_input{_evas}
ECORE_CHECK_MODULE([Input], [${want_ecore_input}])
ECORE_CHECK_MODULE([Input_Evas], [${want_ecore_input}], [${have_evas}],
[requirements_ecore_input_evas="ecore-input evas ${requirements_ecore_input}"])
## Graphic systems
@ -967,12 +972,12 @@ ECORE_CHECK_MODULE([WinCE], [${want_ecore_wince}], [${have_ecore_input}],
# ecore_evas
ecore_evas_deps="no"
if test "x${have_evas}" = "xyes" -a "x${have_ecore_input}" = "xyes" ; then
if test "x${have_evas}" = "xyes" -a "x${have_ecore_input}" = "xyes" -a "x${have_ecore_input_evas}" = "xyes" ; then
ecore_evas_deps="yes"
fi
ECORE_CHECK_MODULE([Evas], [${want_ecore_evas}], [${ecore_evas_deps}],
[requirements_ecore_evas="ecore-input evas ${requirements_ecore_evas}"])
[requirements_ecore_evas="ecore-input ecore-input-evas evas ${requirements_ecore_evas}"])
# ecore_evas_buffer
@ -1131,6 +1136,7 @@ AC_SUBST(requirements_ecore_file)
AC_SUBST(requirements_ecore_imf)
AC_SUBST(requirements_ecore_imf_evas)
AC_SUBST(requirements_ecore_input)
AC_SUBST(requirements_ecore_input_evas)
AC_SUBST(requirements_ecore_ipc)
AC_SUBST(requirements_ecore_job)
AC_SUBST(requirements_ecore_quartz)
@ -1155,6 +1161,7 @@ ecore-job.pc
ecore-txt.pc
ecore-x.pc
ecore-input.pc
ecore-input-evas.pc
ecore-win32.pc
ecore-sdl.pc
ecore-quartz.pc
@ -1178,6 +1185,7 @@ src/lib/ecore_con/Makefile
src/lib/ecore_imf/Makefile
src/lib/ecore_imf_evas/Makefile
src/lib/ecore_input/Makefile
src/lib/ecore_input_evas/Makefile
src/lib/ecore_ipc/Makefile
src/lib/ecore_txt/Makefile
src/lib/ecore_config/Makefile
@ -1236,6 +1244,7 @@ echo " Ecore_Config.................: $have_ecore_config"
echo " Ecore_IMF....................: $have_ecore_imf"
echo " Ecore_IMF_Evas...............: $have_ecore_imf_evas"
echo " Ecore_Input..................: $have_ecore_input"
echo " Ecore_Input_Evas.............: $have_ecore_input_evas"
echo
echo " Graphic systems:"

View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: ecore-input-evas
Description: E core library, Input module Evas extension
@pkgconfig_requires_private@: @requirements_ecore_input_evas@
Version: @VERSION@
Libs: -L${libdir} -lecore_input_evas
Cflags: -I${includedir}

View File

@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = \
ecore \
ecore_input \
ecore_input_evas \
ecore_job \
ecore_txt \
ecore_fb \

View File

@ -62,9 +62,11 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/ecore_evas \
-I$(top_srcdir)/src/lib/ecore_input \
-I$(top_srcdir)/src/lib/ecore_input_evas \
-I$(top_builddir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore_evas \
-I$(top_builddir)/src/lib/ecore_input \
-I$(top_builddir)/src/lib/ecore_input_evas \
@EFL_ECORE_EVAS_BUILD@ \
$(ECORE_X_INC) \
$(ECORE_FB_INC) \

View File

@ -20,6 +20,7 @@
#include <ecore_private.h>
#include <Ecore_Data.h>
#include <Ecore_Input.h>
#include <Ecore_Input_Evas.h>
#define ECORE_MAGIC_EVAS 0x76543211

View File

@ -13,6 +13,7 @@
#include "Ecore.h"
#include "ecore_private.h"
#include "Ecore_Input.h"
#include "Ecore_Input_Evas.h"
#include "ecore_evas_private.h"
#include "Ecore_Evas.h"

View File

@ -8,6 +8,7 @@
#include <Ecore.h>
#include <Ecore_Input.h>
#include <Ecore_Input_Evas.h>
#ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL
#include <Ecore_Sdl.h>
#include <Evas_Engine_SDL.h>

View File

@ -10,6 +10,7 @@
#include <Ecore.h>
#include <Ecore_Input.h>
#include <Ecore_Input_Evas.h>
#ifdef BUILD_ECORE_EVAS_X11
# include <Ecore_X.h>
# include <Ecore_X_Atoms.h>

View File

@ -6,8 +6,6 @@
#define _ECORE_INPUT_H
#include <Evas.h>
#ifdef EAPI
# undef EAPI
#endif
@ -192,33 +190,9 @@ struct _Ecore_Event_Modifiers
unsigned int array[ECORE_LAST];
};
typedef void (*Ecore_Event_Mouse_Move_Cb)(void *window, int x, int y, unsigned int timestamp);
EAPI int ecore_event_init(void);
EAPI int ecore_event_shutdown(void);
EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc);
EAPI unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier);
EAPI int ecore_event_evas_init(void);
EAPI int ecore_event_evas_shutdown(void);
EAPI int ecore_event_evas_key_down(void *data, int type, void *event);
EAPI int ecore_event_evas_key_up(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_button_up(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_button_down(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_wheel(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_move(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_in(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_out(void *data, int type, void *event);
EAPI void ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse);
EAPI void ecore_event_window_unregister(Ecore_Window id);
EAPI void* ecore_event_window_match(Ecore_Window id);
EAPI void ecore_event_window_ignore_events(Ecore_Window id, int ignore_event);
EAPI void ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers);
#ifdef __cplusplus
}
#endif

View File

@ -4,7 +4,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore \
@EFL_ECORE_INPUT_BUILD@ \
@EVAS_CFLAGS@ \
@EINA_CFLAGS@ \
@EVIL_CFLAGS@
@ -18,7 +17,6 @@ ecore_input.c
libecore_input_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
@EVAS_LIBS@ \
@EINA_LIBS@ \
@EVIL_LIBS@

View File

@ -13,21 +13,10 @@
#include "ecore_input_private.h"
#include "ecore_private.h"
#include "Ecore_Input.h"
#include "Evas.h"
int _ecore_input_log_dom = -1;
typedef struct _Ecore_Input_Window Ecore_Input_Window;
struct _Ecore_Input_Window
{
Evas *evas;
void *window;
Ecore_Event_Mouse_Move_Cb move_mouse;
int ignore_event;
};
EAPI int ECORE_EVENT_KEY_DOWN = 0;
EAPI int ECORE_EVENT_KEY_UP = 0;
EAPI int ECORE_EVENT_MOUSE_BUTTON_DOWN = 0;
@ -38,10 +27,6 @@ EAPI int ECORE_EVENT_MOUSE_IN = 0;
EAPI int ECORE_EVENT_MOUSE_OUT = 0;
static int _ecore_event_init_count = 0;
static int _ecore_event_evas_init_count = 0;
static Ecore_Event_Handler *ecore_event_evas_handlers[8];
static Eina_Hash *_window_hash = NULL;
EAPI int
ecore_event_init(void)
@ -87,304 +72,6 @@ ecore_event_shutdown(void)
return ++_ecore_event_init_count;
}
EAPI void
ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers)
{
if (modifiers & ECORE_EVENT_MODIFIER_SHIFT)
evas_key_modifier_on(e, "Shift");
else evas_key_modifier_off(e, "Shift");
if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
evas_key_modifier_on(e, "Control");
else evas_key_modifier_off(e, "Control");
if (modifiers & ECORE_EVENT_MODIFIER_ALT)
evas_key_modifier_on(e, "Alt");
else evas_key_modifier_off(e, "Alt");
if (modifiers & ECORE_EVENT_MODIFIER_WIN)
{
evas_key_modifier_on(e, "Super");
evas_key_modifier_on(e, "Hyper");
}
else
{
evas_key_modifier_off(e, "Super");
evas_key_modifier_off(e, "Hyper");
}
if (modifiers & ECORE_EVENT_LOCK_SCROLL)
evas_key_lock_on(e, "Scroll_Lock");
else evas_key_lock_off(e, "Scroll_Lock");
if (modifiers & ECORE_EVENT_LOCK_NUM)
evas_key_lock_on(e, "Num_Lock");
else evas_key_lock_off(e, "Num_Lock");
if (modifiers & ECORE_EVENT_LOCK_CAPS)
evas_key_lock_on(e, "Caps_Lock");
else evas_key_lock_off(e, "Caps_Lock");
}
EAPI void
ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse)
{
Ecore_Input_Window *new;
new = malloc(sizeof (Ecore_Input_Window));
if (!new) return ;
new->evas = evas;
new->window = window;
new->move_mouse = move_mouse;
new->ignore_event = 0;
eina_hash_add(_window_hash, &id, new);
evas_key_modifier_add(evas, "Shift");
evas_key_modifier_add(evas, "Control");
evas_key_modifier_add(evas, "Alt");
evas_key_modifier_add(evas, "Meta");
evas_key_modifier_add(evas, "Hyper");
evas_key_modifier_add(evas, "Super");
evas_key_lock_add(evas, "Caps_Lock");
evas_key_lock_add(evas, "Num_Lock");
evas_key_lock_add(evas, "Scroll_Lock");
}
EAPI void
ecore_event_window_unregister(Ecore_Window id)
{
eina_hash_del(_window_hash, &id, NULL);
}
EAPI void*
ecore_event_window_match(Ecore_Window id)
{
Ecore_Input_Window *lookup;
lookup = eina_hash_find(_window_hash, &id);
if (lookup) return lookup->window;
return NULL;
}
EAPI void
ecore_event_window_ignore_events(Ecore_Window id, int ignore_event)
{
Ecore_Input_Window *lookup;
lookup = eina_hash_find(_window_hash, &id);
if (!lookup) return ;
lookup->ignore_event = ignore_event;
}
static Ecore_Input_Window*
_ecore_event_window_match(Ecore_Window id)
{
Ecore_Input_Window *lookup;
lookup = eina_hash_find(_window_hash, &id);
if (!lookup) return NULL;
if (lookup->ignore_event) return NULL; /* Pass on event. */
return lookup;
}
static int
_ecore_event_evas_key(Ecore_Event_Key *e, Ecore_Event_Press press)
{
Ecore_Input_Window *lookup;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
if (press == ECORE_DOWN)
evas_event_feed_key_down(lookup->evas, e->keyname, e->key, e->string, e->compose, e->timestamp, NULL);
else
evas_event_feed_key_up(lookup->evas, e->keyname, e->key, e->string, e->compose, e->timestamp, NULL);
return 1;
}
static int
_ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press press)
{
Ecore_Input_Window *lookup;
Evas_Button_Flags flags = EVAS_BUTTON_NONE;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
if (press == ECORE_DOWN)
evas_event_feed_mouse_down(lookup->evas, e->buttons, flags, e->timestamp, NULL);
else
evas_event_feed_mouse_up(lookup->evas, e->buttons, flags, e->timestamp, NULL);
return 1;
}
static int
_ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io)
{
Ecore_Input_Window *lookup;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
switch (io)
{
case ECORE_IN:
evas_event_feed_mouse_in(lookup->evas, e->timestamp, NULL);
break;
case ECORE_OUT:
evas_event_feed_mouse_out(lookup->evas, e->timestamp, NULL);
break;
default:
break;
}
lookup->move_mouse(lookup->window, e->x, e->y, e->timestamp);
return 1;
}
EAPI int
ecore_event_evas_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_key((Ecore_Event_Key*) event, ECORE_DOWN);
}
EAPI int
ecore_event_evas_key_up(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_key((Ecore_Event_Key*) event, ECORE_UP);
}
EAPI int
ecore_event_evas_mouse_button_down(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_button((Ecore_Event_Mouse_Button*) event, ECORE_DOWN);
}
EAPI int
ecore_event_evas_mouse_button_up(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_button((Ecore_Event_Mouse_Button*) event, ECORE_UP);
}
EAPI int
ecore_event_evas_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Event_Mouse_Wheel *e;
Ecore_Input_Window *lookup;
e = event;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
evas_event_feed_mouse_wheel(lookup->evas, e->direction, e->z, e->timestamp, NULL);
return 1;
}
EAPI int
ecore_event_evas_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Event_Mouse_Move *e;
Ecore_Input_Window *lookup;
e = event;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
lookup->move_mouse(lookup->window, e->x, e->y, e->timestamp);
return 1;
}
EAPI int
ecore_event_evas_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_io((Ecore_Event_Mouse_IO*) event, ECORE_IN);
}
EAPI int
ecore_event_evas_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_io((Ecore_Event_Mouse_IO*) event, ECORE_OUT);
}
EAPI int
ecore_event_evas_init(void)
{
if (++_ecore_event_evas_init_count != 1)
return _ecore_event_evas_init_count;
if (!ecore_init())
{
return --_ecore_event_evas_init_count;
}
if (!ecore_event_init())
{
goto shutdown_ecore;
}
ecore_event_evas_handlers[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
ecore_event_evas_key_down,
NULL);
ecore_event_evas_handlers[1] = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
ecore_event_evas_key_up,
NULL);
ecore_event_evas_handlers[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
ecore_event_evas_mouse_button_down,
NULL);
ecore_event_evas_handlers[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
ecore_event_evas_mouse_button_up,
NULL);
ecore_event_evas_handlers[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
ecore_event_evas_mouse_move,
NULL);
ecore_event_evas_handlers[5] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL,
ecore_event_evas_mouse_wheel,
NULL);
ecore_event_evas_handlers[6] = ecore_event_handler_add(ECORE_EVENT_MOUSE_IN,
ecore_event_evas_mouse_in,
NULL);
ecore_event_evas_handlers[7] = ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT,
ecore_event_evas_mouse_out,
NULL);
_window_hash = eina_hash_pointer_new(free);
return _ecore_event_evas_init_count;
shutdown_ecore:
ecore_shutdown();
return --_ecore_event_evas_init_count;
}
EAPI int
ecore_event_evas_shutdown(void)
{
int i;
if (--_ecore_event_evas_init_count != 0)
return _ecore_event_evas_init_count;
eina_hash_free(_window_hash);
_window_hash = NULL;
for (i = 0; i < sizeof(ecore_event_evas_handlers)/sizeof(Ecore_Event_Handler*); ++i)
{
ecore_event_handler_del(ecore_event_evas_handlers[i]);
ecore_event_evas_handlers[i] = NULL;
}
ecore_event_shutdown();
ecore_shutdown();
return _ecore_event_evas_init_count;
}
typedef struct _Ecore_Event_Modifier_Match Ecore_Event_Modifier_Match;
struct _Ecore_Event_Modifier_Match
{

View File

@ -0,0 +1,65 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifndef _ECORE_INPUT_EVAS_H
#define _ECORE_INPUT_EVAS_H
#include <Evas.h>
#ifdef EAPI
# undef EAPI
#endif
#ifdef _WIN32
# ifdef EFL_ECORE_INPUT_BUILD
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
# else
# define EAPI __declspec(dllimport)
# endif /* ! EFL_ECORE_INPUT_BUILD */
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*Ecore_Event_Mouse_Move_Cb)(void *window, int x, int y, unsigned int timestamp);
EAPI int ecore_event_evas_init(void);
EAPI int ecore_event_evas_shutdown(void);
EAPI int ecore_event_evas_key_down(void *data, int type, void *event);
EAPI int ecore_event_evas_key_up(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_button_up(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_button_down(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_wheel(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_move(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_in(void *data, int type, void *event);
EAPI int ecore_event_evas_mouse_out(void *data, int type, void *event);
EAPI void ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse);
EAPI void ecore_event_window_unregister(Ecore_Window id);
EAPI void* ecore_event_window_match(Ecore_Window id);
EAPI void ecore_event_window_ignore_events(Ecore_Window id, int ignore_event);
EAPI void ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,30 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib/ecore_input \
-I$(top_builddir)/src/lib/ecore_input \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore \
@EFL_ECORE_INPUT_BUILD@ \
@EVAS_CFLAGS@ \
@EINA_CFLAGS@ \
@EVIL_CFLAGS@
if BUILD_ECORE_INPUT_EVAS
lib_LTLIBRARIES = libecore_input_evas.la
include_HEADERS = Ecore_Input_Evas.h
libecore_input_evas_la_SOURCES = \
ecore_input_evas.c
libecore_input_evas_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_input/libecore_input.la \
@EVAS_LIBS@ \
@EINA_LIBS@ \
@EVIL_LIBS@
libecore_input_evas_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @ecore_input_evas_release_info@
endif

View File

@ -0,0 +1,386 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include "Ecore.h"
#include "ecore_input_evas_private.h"
#include "Ecore_Input.h"
#include "Ecore_Input_Evas.h"
int _ecore_input_evas_log_dom = -1;
typedef struct _Ecore_Input_Window Ecore_Input_Window;
struct _Ecore_Input_Window
{
Evas *evas;
void *window;
Ecore_Event_Mouse_Move_Cb move_mouse;
int ignore_event;
};
static int _ecore_event_evas_init_count = 0;
static Ecore_Event_Handler *ecore_event_evas_handlers[8];
static Eina_Hash *_window_hash = NULL;
EAPI void
ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers)
{
if (modifiers & ECORE_EVENT_MODIFIER_SHIFT)
evas_key_modifier_on(e, "Shift");
else evas_key_modifier_off(e, "Shift");
if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
evas_key_modifier_on(e, "Control");
else evas_key_modifier_off(e, "Control");
if (modifiers & ECORE_EVENT_MODIFIER_ALT)
evas_key_modifier_on(e, "Alt");
else evas_key_modifier_off(e, "Alt");
if (modifiers & ECORE_EVENT_MODIFIER_WIN)
{
evas_key_modifier_on(e, "Super");
evas_key_modifier_on(e, "Hyper");
}
else
{
evas_key_modifier_off(e, "Super");
evas_key_modifier_off(e, "Hyper");
}
if (modifiers & ECORE_EVENT_LOCK_SCROLL)
evas_key_lock_on(e, "Scroll_Lock");
else evas_key_lock_off(e, "Scroll_Lock");
if (modifiers & ECORE_EVENT_LOCK_NUM)
evas_key_lock_on(e, "Num_Lock");
else evas_key_lock_off(e, "Num_Lock");
if (modifiers & ECORE_EVENT_LOCK_CAPS)
evas_key_lock_on(e, "Caps_Lock");
else evas_key_lock_off(e, "Caps_Lock");
}
EAPI void
ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse)
{
Ecore_Input_Window *new;
new = malloc(sizeof (Ecore_Input_Window));
if (!new) return ;
new->evas = evas;
new->window = window;
new->move_mouse = move_mouse;
new->ignore_event = 0;
eina_hash_add(_window_hash, &id, new);
evas_key_modifier_add(evas, "Shift");
evas_key_modifier_add(evas, "Control");
evas_key_modifier_add(evas, "Alt");
evas_key_modifier_add(evas, "Meta");
evas_key_modifier_add(evas, "Hyper");
evas_key_modifier_add(evas, "Super");
evas_key_lock_add(evas, "Caps_Lock");
evas_key_lock_add(evas, "Num_Lock");
evas_key_lock_add(evas, "Scroll_Lock");
}
EAPI void
ecore_event_window_unregister(Ecore_Window id)
{
eina_hash_del(_window_hash, &id, NULL);
}
EAPI void*
ecore_event_window_match(Ecore_Window id)
{
Ecore_Input_Window *lookup;
lookup = eina_hash_find(_window_hash, &id);
if (lookup) return lookup->window;
return NULL;
}
EAPI void
ecore_event_window_ignore_events(Ecore_Window id, int ignore_event)
{
Ecore_Input_Window *lookup;
lookup = eina_hash_find(_window_hash, &id);
if (!lookup) return ;
lookup->ignore_event = ignore_event;
}
static Ecore_Input_Window*
_ecore_event_window_match(Ecore_Window id)
{
Ecore_Input_Window *lookup;
lookup = eina_hash_find(_window_hash, &id);
if (!lookup) return NULL;
if (lookup->ignore_event) return NULL; /* Pass on event. */
return lookup;
}
static int
_ecore_event_evas_key(Ecore_Event_Key *e, Ecore_Event_Press press)
{
Ecore_Input_Window *lookup;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
if (press == ECORE_DOWN)
evas_event_feed_key_down(lookup->evas, e->keyname, e->key, e->string, e->compose, e->timestamp, NULL);
else
evas_event_feed_key_up(lookup->evas, e->keyname, e->key, e->string, e->compose, e->timestamp, NULL);
return 1;
}
static int
_ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press press)
{
Ecore_Input_Window *lookup;
Evas_Button_Flags flags = EVAS_BUTTON_NONE;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
if (press == ECORE_DOWN)
evas_event_feed_mouse_down(lookup->evas, e->buttons, flags, e->timestamp, NULL);
else
evas_event_feed_mouse_up(lookup->evas, e->buttons, flags, e->timestamp, NULL);
return 1;
}
static int
_ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io)
{
Ecore_Input_Window *lookup;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
switch (io)
{
case ECORE_IN:
evas_event_feed_mouse_in(lookup->evas, e->timestamp, NULL);
break;
case ECORE_OUT:
evas_event_feed_mouse_out(lookup->evas, e->timestamp, NULL);
break;
default:
break;
}
lookup->move_mouse(lookup->window, e->x, e->y, e->timestamp);
return 1;
}
EAPI int
ecore_event_evas_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_key((Ecore_Event_Key*) event, ECORE_DOWN);
}
EAPI int
ecore_event_evas_key_up(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_key((Ecore_Event_Key*) event, ECORE_UP);
}
EAPI int
ecore_event_evas_mouse_button_down(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_button((Ecore_Event_Mouse_Button*) event, ECORE_DOWN);
}
EAPI int
ecore_event_evas_mouse_button_up(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_button((Ecore_Event_Mouse_Button*) event, ECORE_UP);
}
EAPI int
ecore_event_evas_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Event_Mouse_Wheel *e;
Ecore_Input_Window *lookup;
e = event;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
evas_event_feed_mouse_wheel(lookup->evas, e->direction, e->z, e->timestamp, NULL);
return 1;
}
EAPI int
ecore_event_evas_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Event_Mouse_Move *e;
Ecore_Input_Window *lookup;
e = event;
lookup = _ecore_event_window_match(e->window);
if (!lookup) return 1;
ecore_event_evas_modifier_lock_update(lookup->evas, e->modifiers);
lookup->move_mouse(lookup->window, e->x, e->y, e->timestamp);
return 1;
}
EAPI int
ecore_event_evas_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_io((Ecore_Event_Mouse_IO*) event, ECORE_IN);
}
EAPI int
ecore_event_evas_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event)
{
return _ecore_event_evas_mouse_io((Ecore_Event_Mouse_IO*) event, ECORE_OUT);
}
EAPI int
ecore_event_evas_init(void)
{
if (++_ecore_event_evas_init_count != 1)
return _ecore_event_evas_init_count;
_ecore_input_evas_log_dom = eina_log_domain_register("EcoreInputEvas", ECORE_INPUT_EVAS_DEFAULT_LOG_COLOR);
if(_ecore_input_evas_log_dom < 0)
{
EINA_LOG_ERR("Impossible to create a log domain for the ecore input evas_module.");
return --_ecore_event_evas_init_count;
}
if (!ecore_init())
{
return --_ecore_event_evas_init_count;
}
if (!ecore_event_init())
{
goto shutdown_ecore;
}
ecore_event_evas_handlers[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
ecore_event_evas_key_down,
NULL);
ecore_event_evas_handlers[1] = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
ecore_event_evas_key_up,
NULL);
ecore_event_evas_handlers[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
ecore_event_evas_mouse_button_down,
NULL);
ecore_event_evas_handlers[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
ecore_event_evas_mouse_button_up,
NULL);
ecore_event_evas_handlers[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
ecore_event_evas_mouse_move,
NULL);
ecore_event_evas_handlers[5] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL,
ecore_event_evas_mouse_wheel,
NULL);
ecore_event_evas_handlers[6] = ecore_event_handler_add(ECORE_EVENT_MOUSE_IN,
ecore_event_evas_mouse_in,
NULL);
ecore_event_evas_handlers[7] = ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT,
ecore_event_evas_mouse_out,
NULL);
_window_hash = eina_hash_pointer_new(free);
return _ecore_event_evas_init_count;
shutdown_ecore:
ecore_shutdown();
return --_ecore_event_evas_init_count;
}
EAPI int
ecore_event_evas_shutdown(void)
{
int i;
if (--_ecore_event_evas_init_count != 0)
return _ecore_event_evas_init_count;
eina_hash_free(_window_hash);
_window_hash = NULL;
for (i = 0; i < sizeof(ecore_event_evas_handlers)/sizeof(Ecore_Event_Handler*); ++i)
{
ecore_event_handler_del(ecore_event_evas_handlers[i]);
ecore_event_evas_handlers[i] = NULL;
}
ecore_event_shutdown();
ecore_shutdown();
eina_log_domain_unregister(_ecore_input_evas_log_dom);
_ecore_input_evas_log_dom = -1;
return _ecore_event_evas_init_count;
}
typedef struct _Ecore_Event_Modifier_Match Ecore_Event_Modifier_Match;
struct _Ecore_Event_Modifier_Match
{
const char *key;
Ecore_Event_Modifier modifier;
unsigned int event_modifier;
};
static const Ecore_Event_Modifier_Match matchs[] = {
{ "Shift_L", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT },
{ "Shift_R", ECORE_SHIFT, ECORE_EVENT_MODIFIER_SHIFT },
{ "Alt_L", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT },
{ "Alt_R", ECORE_ALT, ECORE_EVENT_MODIFIER_ALT },
{ "Control_L", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL },
{ "Control_R", ECORE_CTRL, ECORE_EVENT_MODIFIER_CTRL },
{ "Caps_Lock", ECORE_CAPS, ECORE_EVENT_MODIFIER_CAPS },
{ "Super_L", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN },
{ "Super_R", ECORE_WIN, ECORE_EVENT_MODIFIER_WIN },
{ "Scroll_Lock", ECORE_SCROLL, ECORE_EVENT_MODIFIER_SCROLL }
};
EAPI unsigned int
ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
{
int i;
for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++)
if (matchs[i].modifier == modifier)
return matchs[i].event_modifier;
return 0;
}
EAPI Ecore_Event_Modifier
ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc)
{
int i;
for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++)
if (strcmp(matchs[i].key, key) == 0)
{
if (modifiers && matchs[i].modifier < modifiers->size)
modifiers->array[matchs[i].modifier] += inc;
return matchs[i].modifier;
}
return ECORE_NONE;
}

View File

@ -0,0 +1,37 @@
#ifndef _ECORE_INPUT_PRIVATE_H
#define _ECORE_INPUT_PRIVATE_H
extern int _ecore_input_evas_log_dom;
#ifdef ECORE_INPUT_EVAS_DEFAULT_LOG_COLOR
# undef ECORE_INPUT_EVAS_DEFAULT_LOG_COLOR
#endif
#define ECORE_INPUT_EVAS_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
#ifdef ERR
# undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_ecore_input_evas_log_dom, __VA_ARGS__)
#ifdef DBG
# undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_ecore_input_evas_log_dom, __VA_ARGS__)
#ifdef INF
# undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_ecore_input_evas_log_dom, __VA_ARGS__)
#ifdef WRN
# undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_ecore_input_evas_log_dom, __VA_ARGS__)
#ifdef CRIT
# undef CRIT
#endif
#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_input_evas_log_dom, __VA_ARGS__)
#endif