From b0a1a778a1816d99c56450a7c9836b5ba023b2b8 Mon Sep 17 00:00:00 2001 From: Sebastian Dransfeld Date: Thu, 7 Jan 2010 19:26:52 +0000 Subject: [PATCH] Split evas from ecore_input SVN revision: 44957 --- legacy/ecore/Makefile.am | 4 + legacy/ecore/configure.ac | 21 +- legacy/ecore/ecore-input-evas.pc.in | 11 + legacy/ecore/src/lib/Makefile.am | 1 + legacy/ecore/src/lib/ecore_evas/Makefile.am | 2 + .../src/lib/ecore_evas/ecore_evas_private.h | 1 + .../src/lib/ecore_evas/ecore_evas_quartz.c | 1 + .../ecore/src/lib/ecore_evas/ecore_evas_sdl.c | 1 + .../ecore/src/lib/ecore_evas/ecore_evas_x.c | 1 + .../ecore/src/lib/ecore_input/Ecore_Input.h | 26 -- legacy/ecore/src/lib/ecore_input/Makefile.am | 2 - .../ecore/src/lib/ecore_input/ecore_input.c | 313 -------------- .../lib/ecore_input_evas/Ecore_Input_Evas.h | 65 +++ .../src/lib/ecore_input_evas/Makefile.am | 30 ++ .../lib/ecore_input_evas/ecore_input_evas.c | 386 ++++++++++++++++++ .../ecore_input_evas_private.h | 37 ++ 16 files changed, 555 insertions(+), 347 deletions(-) create mode 100644 legacy/ecore/ecore-input-evas.pc.in create mode 100644 legacy/ecore/src/lib/ecore_input_evas/Ecore_Input_Evas.h create mode 100644 legacy/ecore/src/lib/ecore_input_evas/Makefile.am create mode 100644 legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c create mode 100644 legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas_private.h diff --git a/legacy/ecore/Makefile.am b/legacy/ecore/Makefile.am index 3a5596dd6e..5ce43f07dd 100644 --- a/legacy/ecore/Makefile.am +++ b/legacy/ecore/Makefile.am @@ -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 diff --git a/legacy/ecore/configure.ac b/legacy/ecore/configure.ac index 0e54d33026..8f04b6d4c5 100644 --- a/legacy/ecore/configure.ac +++ b/legacy/ecore/configure.ac @@ -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:" diff --git a/legacy/ecore/ecore-input-evas.pc.in b/legacy/ecore/ecore-input-evas.pc.in new file mode 100644 index 0000000000..148060a491 --- /dev/null +++ b/legacy/ecore/ecore-input-evas.pc.in @@ -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} diff --git a/legacy/ecore/src/lib/Makefile.am b/legacy/ecore/src/lib/Makefile.am index d69ef73691..f87751e10f 100644 --- a/legacy/ecore/src/lib/Makefile.am +++ b/legacy/ecore/src/lib/Makefile.am @@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in SUBDIRS = \ ecore \ ecore_input \ +ecore_input_evas \ ecore_job \ ecore_txt \ ecore_fb \ diff --git a/legacy/ecore/src/lib/ecore_evas/Makefile.am b/legacy/ecore/src/lib/ecore_evas/Makefile.am index 63e0cdcc28..4bdd59947f 100644 --- a/legacy/ecore/src/lib/ecore_evas/Makefile.am +++ b/legacy/ecore/src/lib/ecore_evas/Makefile.am @@ -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) \ diff --git a/legacy/ecore/src/lib/ecore_evas/ecore_evas_private.h b/legacy/ecore/src/lib/ecore_evas/ecore_evas_private.h index 0bbf36f313..c4404a1c5c 100644 --- a/legacy/ecore/src/lib/ecore_evas/ecore_evas_private.h +++ b/legacy/ecore/src/lib/ecore_evas/ecore_evas_private.h @@ -20,6 +20,7 @@ #include #include #include +#include #define ECORE_MAGIC_EVAS 0x76543211 diff --git a/legacy/ecore/src/lib/ecore_evas/ecore_evas_quartz.c b/legacy/ecore/src/lib/ecore_evas/ecore_evas_quartz.c index dcc43ebc59..799abdd517 100644 --- a/legacy/ecore/src/lib/ecore_evas/ecore_evas_quartz.c +++ b/legacy/ecore/src/lib/ecore_evas/ecore_evas_quartz.c @@ -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" diff --git a/legacy/ecore/src/lib/ecore_evas/ecore_evas_sdl.c b/legacy/ecore/src/lib/ecore_evas/ecore_evas_sdl.c index 19fedbfc25..b657ed2dd2 100644 --- a/legacy/ecore/src/lib/ecore_evas/ecore_evas_sdl.c +++ b/legacy/ecore/src/lib/ecore_evas/ecore_evas_sdl.c @@ -8,6 +8,7 @@ #include #include +#include #ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL #include #include diff --git a/legacy/ecore/src/lib/ecore_evas/ecore_evas_x.c b/legacy/ecore/src/lib/ecore_evas/ecore_evas_x.c index 3c7af16a52..a5d067f69b 100644 --- a/legacy/ecore/src/lib/ecore_evas/ecore_evas_x.c +++ b/legacy/ecore/src/lib/ecore_evas/ecore_evas_x.c @@ -10,6 +10,7 @@ #include #include +#include #ifdef BUILD_ECORE_EVAS_X11 # include # include diff --git a/legacy/ecore/src/lib/ecore_input/Ecore_Input.h b/legacy/ecore/src/lib/ecore_input/Ecore_Input.h index bfb32f8448..7efc8dcf25 100644 --- a/legacy/ecore/src/lib/ecore_input/Ecore_Input.h +++ b/legacy/ecore/src/lib/ecore_input/Ecore_Input.h @@ -6,8 +6,6 @@ #define _ECORE_INPUT_H -#include - #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 diff --git a/legacy/ecore/src/lib/ecore_input/Makefile.am b/legacy/ecore/src/lib/ecore_input/Makefile.am index 57cf219170..b27cea4773 100644 --- a/legacy/ecore/src/lib/ecore_input/Makefile.am +++ b/legacy/ecore/src/lib/ecore_input/Makefile.am @@ -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@ diff --git a/legacy/ecore/src/lib/ecore_input/ecore_input.c b/legacy/ecore/src/lib/ecore_input/ecore_input.c index 2a2d73ece8..5affbc1e50 100644 --- a/legacy/ecore/src/lib/ecore_input/ecore_input.c +++ b/legacy/ecore/src/lib/ecore_input/ecore_input.c @@ -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 { diff --git a/legacy/ecore/src/lib/ecore_input_evas/Ecore_Input_Evas.h b/legacy/ecore/src/lib/ecore_input_evas/Ecore_Input_Evas.h new file mode 100644 index 0000000000..fa13bd3ab6 --- /dev/null +++ b/legacy/ecore/src/lib/ecore_input_evas/Ecore_Input_Evas.h @@ -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 + +#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 diff --git a/legacy/ecore/src/lib/ecore_input_evas/Makefile.am b/legacy/ecore/src/lib/ecore_input_evas/Makefile.am new file mode 100644 index 0000000000..36e7c42d63 --- /dev/null +++ b/legacy/ecore/src/lib/ecore_input_evas/Makefile.am @@ -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 diff --git a/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c b/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c new file mode 100644 index 0000000000..efe74c6aa7 --- /dev/null +++ b/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas.c @@ -0,0 +1,386 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#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; +} diff --git a/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas_private.h b/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas_private.h new file mode 100644 index 0000000000..53b79b089a --- /dev/null +++ b/legacy/ecore/src/lib/ecore_input_evas/ecore_input_evas_private.h @@ -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