Merge remote-tracking branch 'origin/upstream'
authorMike McCormack <mj.mccormack@samsung.com>
Thu, 10 Nov 2011 02:40:27 +0000 (11:40 +0900)
committerMike McCormack <mj.mccormack@samsung.com>
Thu, 10 Nov 2011 02:40:27 +0000 (11:40 +0900)
Conflicts:
src/lib/ecore_file/ecore_file_download.c

57 files changed:
AUTHORS
ChangeLog
Makefile.am
README [moved from README.in with 99% similarity]
autogen.sh
configure.ac
ecore-psl1ght.pc.in [new file with mode: 0644]
src/examples/Makefile.am
src/examples/ecore_client_bench.c [moved from src/examples/client_bench.c with 98% similarity]
src/examples/ecore_server_bench.c [moved from src/examples/server_bench.c with 100% similarity]
src/lib/Makefile.am
src/lib/ecore/Makefile.am
src/lib/ecore/ecore_exe_ps3.c [new file with mode: 0644]
src/lib/ecore/ecore_pipe.c
src/lib/ecore_con/Ecore_Con.h
src/lib/ecore_con/Makefile.am
src/lib/ecore_con/ecore_con.c
src/lib/ecore_con/ecore_con_alloc.c [new file with mode: 0644]
src/lib/ecore_con/ecore_con_private.h
src/lib/ecore_con/ecore_con_ssl.c
src/lib/ecore_con/ecore_con_url.c
src/lib/ecore_evas/Ecore_Evas.h
src/lib/ecore_evas/Makefile.am
src/lib/ecore_evas/ecore_evas.c
src/lib/ecore_evas/ecore_evas_psl1ght.c [new file with mode: 0644]
src/lib/ecore_fb/ecore_fb_vt.c
src/lib/ecore_file/ecore_file_download.c
src/lib/ecore_file/ecore_file_private.h
src/lib/ecore_psl1ght/Ecore_Psl1ght.h [new file with mode: 0644]
src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h [new file with mode: 0644]
src/lib/ecore_psl1ght/Makefile.am [new file with mode: 0644]
src/lib/ecore_psl1ght/ecore_psl1ght.c [new file with mode: 0644]
src/lib/ecore_psl1ght/ecore_psl1ght_private.h [new file with mode: 0644]
src/lib/ecore_psl1ght/gemutil.c [new file with mode: 0644]
src/lib/ecore_psl1ght/gemutil.h [new file with mode: 0644]
src/lib/ecore_psl1ght/moveutil.c [new file with mode: 0644]
src/lib/ecore_psl1ght/moveutil.h [new file with mode: 0644]
src/lib/ecore_psl1ght/spursutil.c [new file with mode: 0644]
src/lib/ecore_psl1ght/spursutil.h [new file with mode: 0644]
src/lib/ecore_x/Ecore_X.h
src/lib/ecore_x/xcb/Makefile.am
src/lib/ecore_x/xcb/ecore_xcb.c
src/lib/ecore_x/xcb/ecore_xcb_events.c
src/lib/ecore_x/xcb/ecore_xcb_extensions.c
src/lib/ecore_x/xcb/ecore_xcb_gesture.c [new file with mode: 0644]
src/lib/ecore_x/xcb/ecore_xcb_netwm.c
src/lib/ecore_x/xcb/ecore_xcb_private.h
src/lib/ecore_x/xcb/ecore_xcb_randr.c
src/lib/ecore_x/xlib/Makefile.am
src/lib/ecore_x/xlib/ecore_x.c
src/lib/ecore_x/xlib/ecore_x_events.c
src/lib/ecore_x/xlib/ecore_x_gesture.c [new file with mode: 0644]
src/lib/ecore_x/xlib/ecore_x_netwm.c
src/lib/ecore_x/xlib/ecore_x_private.h
src/modules/immodules/xim/Makefile.am
src/modules/immodules/xim/ecore_imf_xim.c
src/tests/Makefile.am

diff --git a/AUTHORS b/AUTHORS
index 0ab54f1..059f801 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -45,3 +45,5 @@ ChunEon Park <hermet@hermet.pe.kr>
 xlopez@igalia.com
 Rafael Antognolli <antognolli@profusion.mobi>
 Kim Yunhan <spbear@gmail.com>
+Youness Alaoui <kakaroto@kakaroto.homelinux.net>
+Bluezery <ohpowel@gmail.com>
index 1eb472d..f8e48fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        * Add support ecore_cocoa_evas engine.
        * Fix ecore_cocoa code to correctly handle cocoa window.
+
+2011-11-02 Bluezery
+
+       * Fix return error handling in ecore_file_download when 
+        ecore_con_url_get() fails.
index 1e482f0..3de7673 100644 (file)
@@ -103,6 +103,7 @@ ecore-x.pc.in \
 ecore-win32.pc.in \
 ecore-sdl.pc.in \
 ecore-cocoa.pc.in \
+ecore-psl1ght.pc.in \
 ecore-input.pc.in \
 ecore-wince.pc.in \
 ecore.spec.in \
@@ -185,6 +186,10 @@ if BUILD_ECORE_COCOA
 pkgconfig_DATA += ecore-cocoa.pc
 endif
 
+if BUILD_ECORE_PSL1GHT
+pkgconfig_DATA += ecore-psl1ght.pc
+endif
+
 .PHONY: doc
 
 # Documentation
similarity index 99%
rename from README.in
rename to README
index 15ffc43..7a1deb0 100644 (file)
--- a/README.in
+++ b/README
@@ -1,4 +1,4 @@
-Ecore @VERSION@ BETA
+Ecore
 
 ******************************************************************************
 
index b814903..2a59cac 100755 (executable)
@@ -3,7 +3,6 @@
 rm -rf autom4te.cache
 rm -f aclocal.m4 ltmain.sh
 
-touch README
 touch ABOUT-NLS
 
 echo "Running autopoint..." ; autopoint -f || :
index b441a34..3721fb5 100644 (file)
@@ -129,6 +129,7 @@ want_ecore_x="no"
 want_ecore_win32="no"
 want_ecore_cocoa="no"
 want_ecore_sdl="no"
+want_ecore_psl1ght="no"
 want_ecore_fb="no"
 want_ecore_directfb="no"
 want_ecore_wince="no"
@@ -141,6 +142,7 @@ want_ecore_x_randr="yes"
 want_ecore_x_render="yes"
 want_ecore_x_screensaver="yes"
 want_ecore_x_shape="yes"
+want_ecore_x_gesture="no"
 want_ecore_x_sync="yes"
 want_ecore_x_xfixes="yes"
 want_ecore_x_xinerama="yes"
@@ -166,6 +168,7 @@ want_ecore_evas_software_16_ddraw="no"
 want_ecore_evas_software_sdl="no"
 want_ecore_evas_gl_sdl="no"
 want_ecore_evas_gl_cocoa="no"
+want_ecore_evas_psl1ght="no"
 want_ecore_evas_directfb="no"
 want_ecore_evas_fb="no"
 want_ecore_evas_software_16_wince="no"
@@ -254,6 +257,7 @@ requirements_ecore_input_evas=""
 requirements_ecore_ipc=""
 requirements_ecore_cocoa=""
 requirements_ecore_sdl=""
+requirements_ecore_psl1ght=""
 requirements_ecore_x=""
 requirements_ecore_win32=""
 requirements_ecore_wince=""
@@ -467,6 +471,25 @@ case "$host_os" in
       ;;
 esac
 
+have_ps3=""
+case "$host_vendor" in
+  ps3*)
+      have_ps3="yes"
+      PKG_CHECK_MODULES([ESCAPE], [escape])
+      CFLAGS="$CFLAGS $ESCAPE_CFLAGS"
+      AC_DEFINE(HAVE_ESCAPE, 1, [Set to 1 if Escape library is installed])
+      EFL_ECORE_PSL1GHT_BUILD="-DEFL_ECORE_PSL1GHT_BUILD"
+      requirements_ecore="escape ${requirements_ecore}"
+      requirements_ecore_evas="escape ${requirements_ecore_evas}"
+      requirements_ecore_file="escape ${requirements_ecore_file}"
+      requirements_ecore_imf="escape ${requirements_ecore_imf}"
+      requirements_ecore_imf_evas="escape ${requirements_ecore_imf_evas}"
+      requirements_ecore_sdl="escape ${requirements_ecore_sdl}"
+      want_ecore_psl1ght="yes"
+      want_ecore_evas_psl1ght="yes"
+      ;;
+esac
+
 AC_SUBST(EFL_ECORE_BUILD)
 AC_SUBST(EFL_ECORE_CON_BUILD)
 AC_SUBST(EFL_ECORE_EVAS_BUILD)
@@ -479,9 +502,11 @@ AC_SUBST(EFL_ECORE_IPC_BUILD)
 AC_SUBST(EFL_ECORE_WINCE_BUILD)
 AC_SUBST(EFL_ECORE_WIN32_BUILD)
 AC_SUBST(EFL_ECORE_SDL_BUILD)
+AC_SUBST(EFL_ECORE_PSL1GHT_BUILD)
 
 AM_CONDITIONAL(ECORE_HAVE_WINCE, test "x${have_wince}" = "xyes")
 AM_CONDITIONAL(ECORE_HAVE_WIN32, test "x${have_win32}" = "xyes")
+AM_CONDITIONAL(ECORE_HAVE_PS3, test "x${have_ps3}" = "xyes")
 
 WIN32_LIBS=""
 case "$host_os" in
@@ -531,6 +556,7 @@ requirements_ecore_input_evas="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore
 requirements_ecore_ipc="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore_ipc}"
 requirements_ecore_cocoa="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore_cocoa}"
 requirements_ecore_sdl="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore_sdl}"
+requirements_ecore_psl1ght="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore_sdl}"
 requirements_ecore_win32="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore_win32}"
 requirements_ecore_wince="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore_wince}"
 requirements_ecore_x="ecore >= 1.0.0 eina >= 1.0.0 ${requirements_ecore_x}"
@@ -656,6 +682,12 @@ AC_ARG_ENABLE(ecore-x-shape,
         @<:@default=detect@:>@])],
    [want_ecore_x_shape=$enableval])
 
+AC_ARG_ENABLE(ecore-x-gesture,
+   [AC_HELP_STRING([--enable-ecore-x-gesture],
+       [enable the ecore_x support for Xgesture extension.
+        @<:@default=detect@:>@])],
+   [want_ecore_x_gesture=$enableval])
+
 AC_ARG_ENABLE(ecore-x-sync,
    [AC_HELP_STRING([--disable-ecore-x-sync],
        [disable the ecore_x support for Xsync extension.
@@ -923,6 +955,17 @@ if test "x$want_ecore_x_xcb" = "xyes" ; then
       AC_MSG_NOTICE("shape extension explicitly disabled")
     fi
 
+    if test "x$want_ecore_x_gesture" != "xno"; then
+      PKG_CHECK_MODULES(XCB_XGESTURE, xcb-gesture,
+        [ have_ecore_x_xcb_gesture="yes"
+          requirements_ecore_x="xcb-gesture ${requirements_ecore_x}"
+          AC_DEFINE(ECORE_XCB_XGESTURE, 1, [Build support for XCB gesture]) ],
+        [ have_ecore_x_xcb_gesture="no" ])
+    else
+      have_ecore_x_xcb_gesture="no"
+      AC_MSG_NOTICE("gesture extension explicitly disabled")
+    fi
+
     if test "x$want_ecore_x_sync" != "xno"; then
       PKG_CHECK_MODULES(XCB_SYNC, xcb-sync,
         [ have_ecore_x_xcb_sync="yes"
@@ -1093,12 +1136,13 @@ if ! test "x$have_ecore_x_xcb" = "xyes" ; then
     ECORE_CHECK_X_EXTENSION([Xinerama], [Xinerama.h], [Xinerama], [XineramaQueryScreens], [$want_ecore_x_xinerama])
     ECORE_CHECK_X_EXTENSION([Xprint], [Print.h], [Xp], [XpQueryScreens], [$want_ecore_x_xprint])
     ECORE_CHECK_X_EXTENSION([Xrandr], [Xrandr.h], [Xrandr], [XRRGetScreenResourcesCurrent], [$want_ecore_x_randr])
+    ECORE_CHECK_X_EXTENSION([Xgesture], [gesture.h], [Xgesture], [XGestureQueryExtension], [$want_ecore_x_gesture])
     ECORE_CHECK_X_EXTENSION([Xrender], [Xrender.h], [Xrender], [XRenderFindVisualFormat], [$want_ecore_x_render])
     ECORE_CHECK_X_EXTENSION([Xtest], [XTest.h], [Xtst], [XTestFakeKeyEvent], [$want_ecore_x_xtest])
     ECORE_CHECK_X_EXTENSION([Xss], [scrnsaver.h], [Xss], [XScreenSaverSelectInput], [$want_ecore_x_screensaver])
     ECORE_CHECK_X_EXTENSION([Xi2], [XInput2.h], [Xi], [XIQueryDevice], [$want_ecore_x_input])
 
-    ecore_x_libs_private="${Xcursor_libs} ${XKB_LIBS} ${XCOMPOSITE_LIBS} ${XDAMAGE_LIBS} ${XDPMS_LIBS} ${XFIXES_LIBS} ${XINERAMA_LIBS} ${XPRINT_LIBS} ${XRANDR_LIBS} ${XRENDER_LIBS} ${XTEST_LIBS} ${XSS_LIBS} ${XI2_LIBS}"
+    ecore_x_libs_private="${Xcursor_libs} ${XKB_LIBS} ${XCOMPOSITE_LIBS} ${XGESTURE_LIBS} ${XDAMAGE_LIBS} ${XDPMS_LIBS} ${XFIXES_LIBS} ${XINERAMA_LIBS} ${XPRINT_LIBS} ${XRANDR_LIBS} ${XRENDER_LIBS} ${XTEST_LIBS} ${XSS_LIBS} ${XI2_LIBS}"
 
     AC_DEFINE(HAVE_ECORE_X_XLIB, 1, [Defined to 1 if Xlib is enabled.])
     have_x="yes"
@@ -1250,7 +1294,7 @@ AC_CHECK_SIZEOF(long, 4)
 
 
 ### Checks for compiler characteristics
-AM_PROG_CC_STDC
+AC_PROG_CC_STDC
 AC_C_CONST
 AC_C_BIGENDIAN
 AC_HEADER_STDC
@@ -1543,6 +1587,9 @@ fi
 ECORE_CHECK_MODULE([sdl], [${want_ecore_sdl}], [Sdl], [${ecore_sdl_deps}],
    [requirements_ecore_sdl="ecore-input >= 1.0.0 ${requirements_ecore_sdl}"])
 
+ECORE_CHECK_MODULE([psl1ght], [${want_ecore_psl1ght}], [psl1ght], [${ecore_psl1ght_deps}],
+   [requirements_ecore_psl1ght="ecore-input >= 1.0.0 ${requirements_ecore_psl1ght}"])
+
 # ecore_fb
 ECORE_CHECK_MODULE([fb], [${want_ecore_fb}], [FB], [$have_fb])
 
@@ -1759,6 +1806,14 @@ ECORE_EVAS_CHECK_MODULE_FULL([ews], [software-buffer],
    [Ecore Evas Single Process Windowing System],
    [yes], [])
 
+# ecore_evas_psl1ght
+
+ECORE_EVAS_CHECK_MODULE([psl1ght],
+   [${want_ecore_evas_psl1ght}],
+   [PSL1GHT],
+   [${have_ecore_psl1ght}],
+   [requirements_ecore_evas="ecore-psl1ght >= 1.0.0 ${requirements_ecore_evas}"])
+
 ### install and build examples
 
 EFL_CHECK_BUILD_EXAMPLES([enable_build_examples="yes"], [enable_build_examples="no"])
@@ -1780,6 +1835,7 @@ AC_SUBST(requirements_ecore_input_evas)
 AC_SUBST(requirements_ecore_ipc)
 AC_SUBST(requirements_ecore_cocoa)
 AC_SUBST(requirements_ecore_sdl)
+AC_SUBST(requirements_ecore_psl1ght)
 AC_SUBST(requirements_ecore_x)
 AC_SUBST(requirements_ecore_win32)
 AC_SUBST(requirements_ecore_wince)
@@ -1802,6 +1858,7 @@ ecore-input-evas.pc
 ecore-win32.pc
 ecore-sdl.pc
 ecore-cocoa.pc
+ecore-psl1ght.pc
 ecore-wince.pc
 ecore.pc
 doc/ecore.dox
@@ -1820,6 +1877,7 @@ src/lib/ecore_fb/Makefile
 src/lib/ecore_file/Makefile
 src/lib/ecore_cocoa/Makefile
 src/lib/ecore_sdl/Makefile
+src/lib/ecore_psl1ght/Makefile
 src/lib/ecore_imf/Makefile
 src/lib/ecore_imf_evas/Makefile
 src/lib/ecore_input/Makefile
@@ -1835,7 +1893,6 @@ src/tests/Makefile
 src/modules/Makefile
 src/modules/immodules/Makefile
 src/modules/immodules/xim/Makefile
-README
 ecore.spec
 $po_makefile_in
 ])
@@ -1910,6 +1967,7 @@ if test "x$have_ecore_x" = "xyes" ; then
     echo "    Xrandr.....................: $have_ecore_x_xcb_randr"
     echo "    Xscreensaver...............: $have_ecore_x_xcb_screensaver"
     echo "    Xshape.....................: $have_ecore_x_xcb_shape"
+    echo "    Xgesture...................: $have_ecore_x_xcb_gesture"
     echo "    Xsync......................: $have_ecore_x_xcb_sync"
     echo "    Xrender....................: $have_ecore_x_xcb_render"
     echo "    Xcomposite.................: $have_ecore_x_xcb_composite"
@@ -1924,6 +1982,7 @@ if test "x$have_ecore_x" = "xyes" ; then
     echo "    Xprint.....................: $use_xprint"
     echo "    Xinerama...................: $use_xinerama"
     echo "    Xrandr.....................: $use_xrandr"
+    echo "    Xgesture...................: $use_xgesture"
     echo "    Xscreensaver...............: $use_xss"
     echo "    Xrender....................: $use_xrender"
     echo "    Xcomposite.................: $use_xcomposite"
@@ -1946,6 +2005,7 @@ if test "x${have_ecore_fb}" = "xyes" ; then
 fi
 echo "  Ecore_DirectFB...............: $have_ecore_directfb"
 echo "  Ecore_WinCE..................: $have_ecore_wince"
+echo "  Ecore_PSL1GHT................: $have_ecore_psl1ght"
 
 echo
 echo " Ecore Evas:"
@@ -1972,6 +2032,7 @@ if test "x${have_ecore_evas}" = "xyes" ; then
   echo "    OpenGL SDL.................: $have_ecore_evas_opengl_sdl"
   echo "    OpenGL Cocoa...............: $have_ecore_evas_opengl_cocoa"
   echo "    DirectFB...................: $have_ecore_evas_directfb"
+  echo "    PSL1GHT....................: $have_ecore_evas_psl1ght"
   echo "    Software Framebuffer.......: $have_ecore_evas_fb"
   echo "    Software 8bit grayscale XCB: $have_ecore_evas_software_8_x11"
   echo "    Software 16bit X11.........: $have_ecore_evas_software_16_x11"
diff --git a/ecore-psl1ght.pc.in b/ecore-psl1ght.pc.in
new file mode 100644 (file)
index 0000000..e81f4e8
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ecore-psl1ght
+Description: E core library, PSL1GHT module
+@pkgconfig_requires_private@: @requirements_ecore_psl1ght@
+Version: @VERSION@
+Libs: -L${libdir} -lecore_psl1ght
+Libs.private: -lio -lsysutil -lgem -lcamera -lspurs
+Cflags: -I${includedir}/ecore-@VMAJ@
index 282adce..63748a5 100644 (file)
@@ -39,8 +39,8 @@ SRCS = \
        ecore_con_server_simple_example.c \
        ecore_con_server_http_example.c \
        ecore_con_client_simple_example.c \
-       client_bench.c \
-       server_bench.c \
+       ecore_client_bench.c \
+       ecore_server_bench.c \
        ecore_con_client_example.c \
        ecore_con_server_example.c \
        ecore_fd_handler_gnutls_example.c \
@@ -91,7 +91,9 @@ pkglib_PROGRAMS += \
        ecore_evas_basics_example \
        ecore_evas_buffer_example_01 \
        ecore_evas_buffer_example_02 \
-       ecore_evas_ews_example
+       ecore_evas_ews_example \
+       ecore_client_bench \
+       ecore_server_bench
 
 ecore_con_lookup_example_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
 ecore_con_url_headers_example_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
@@ -103,5 +105,7 @@ ecore_con_client_simple_example_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/li
 ecore_evas_window_sizes_example_LDADD = $(ECOREBASELDADD) @EVAS_LIBS@ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la
 ecore_evas_buffer_example_01_LDADD = $(ECOREBASELDADD) @EVAS_LIBS@ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la
 ecore_evas_buffer_example_02_LDADD = $(ECOREBASELDADD) @EVAS_LIBS@ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la
+ecore_client_bench_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
+ecore_server_bench_LDADD = $(ECOREBASELDADD) $(top_builddir)/src/lib/ecore_con/libecore_con.la
 
 endif
similarity index 98%
rename from src/examples/client_bench.c
rename to src/examples/ecore_client_bench.c
index 93a0fb1..2a58dcf 100644 (file)
@@ -6,7 +6,7 @@
  * 2010 Mike Blumenkrantz
  */
 
-#define NUM_CLIENTS 10000
+#define NUM_CLIENTS 30000
 
 static Eina_Counter *counter;
 static int add = 0;
index aeee3d8..b13bc18 100644 (file)
@@ -38,6 +38,10 @@ if BUILD_ECORE_SDL
 SUBDIRS += ecore_sdl
 endif
 
+if BUILD_ECORE_PSL1GHT
+SUBDIRS += ecore_psl1ght
+endif
+
 if BUILD_ECORE_COCOA
 SUBDIRS += ecore_cocoa
 endif
index 5319602..2fb6a0a 100644 (file)
@@ -40,12 +40,20 @@ libecore_la_SOURCES += ecore_exe_wince.c
 
 else
 
+if ECORE_HAVE_PS3
+
+libecore_la_SOURCES += ecore_exe_ps3.c
+
+else
+
 libecore_la_SOURCES += ecore_signal.c ecore_exe.c
 
 endif
 
 endif
 
+endif
+
 libecore_la_LIBADD = @dlopen_libs@ @EINA_LIBS@ @EVIL_LIBS@ @GLIB_LIBS@ @WIN32_LIBS@ @LTLIBINTL@ @EFL_PTHREAD_LIBS@ @rt_libs@ -lm
 libecore_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ @EFL_PTHREAD_LIBS@
 
diff --git a/src/lib/ecore/ecore_exe_ps3.c b/src/lib/ecore/ecore_exe_ps3.c
new file mode 100644 (file)
index 0000000..1ef1e81
--- /dev/null
@@ -0,0 +1,20 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_ESCAPE
+# include <Escape.h>
+#endif
+
+#include "Ecore.h"
+#include "ecore_private.h"
+
+void
+_ecore_exe_init(void)
+{
+}
+
+void
+_ecore_exe_shutdown(void)
+{
+}
index 2512090..8447d18 100644 (file)
 # include <Evil.h>
 #endif
 
+#ifdef HAVE_ESCAPE
+# include <Escape.h>
+#endif
+
 #include "Ecore.h"
 #include "ecore_private.h"
 
index ebf91f7..e3b68c4 100644 (file)
@@ -1014,6 +1014,7 @@ EAPI double            ecore_con_server_timeout_get(Ecore_Con_Server *svr);
  * This function returns the fd which is used by the underlying server connection.
  * It should not be tampered with unless you REALLY know what you are doing.
  * @note This function is only valid for servers created with ecore_con_server_connect()
+ * @warning Seriously. Don't use this unless you know what you are doing.
  * @since 1.1
  */
 EAPI int               ecore_con_server_fd_get(Ecore_Con_Server *svr);
index 128c47c..300586d 100644 (file)
@@ -20,7 +20,8 @@ includesdir = $(includedir)/ecore-@VMAJ@
 libecore_con_la_SOURCES = \
 ecore_con.c \
 ecore_con_ssl.c \
-ecore_con_url.c
+ecore_con_url.c \
+ecore_con_alloc.c
 
 if ECORE_HAVE_WIN32
 libecore_con_la_SOURCES += ecore_con_local_win32.c
index aca8ee5..b5e6f3f 100644 (file)
@@ -143,6 +143,8 @@ ecore_con_init(void)
         return --_ecore_con_init_count;
      }
 
+   ecore_con_mempool_init();
+
    ECORE_CON_EVENT_CLIENT_ADD = ecore_event_type_new();
    ECORE_CON_EVENT_CLIENT_DEL = ecore_event_type_new();
    ECORE_CON_EVENT_SERVER_ADD = ecore_event_type_new();
@@ -178,6 +180,8 @@ ecore_con_shutdown(void)
    EINA_LIST_FOREACH_SAFE(servers, l, l2, svr)
      _ecore_con_server_free(svr);
 
+   ecore_con_mempool_shutdown();
+
    ecore_con_info_shutdown();
    ecore_con_ssl_shutdown();
    eina_log_domain_unregister(_ecore_con_log_dom);
@@ -932,7 +936,7 @@ ecore_con_event_server_add(Ecore_Con_Server *svr)
     Ecore_Con_Event_Server_Add *e;
     int ev = ECORE_CON_EVENT_SERVER_ADD;
 
-    e = calloc(1, sizeof(Ecore_Con_Event_Server_Add));
+    e = ecore_con_event_server_add_alloc();
     EINA_SAFETY_ON_NULL_RETURN(e);
 
     svr->event_count++;
@@ -948,7 +952,7 @@ ecore_con_event_server_del(Ecore_Con_Server *svr)
 {
     Ecore_Con_Event_Server_Del *e;
 
-    e = calloc(1, sizeof(Ecore_Con_Event_Server_Del));
+    e = ecore_con_event_server_del_alloc();
     EINA_SAFETY_ON_NULL_RETURN(e);
 
     svr->event_count++;
@@ -963,7 +967,7 @@ ecore_con_event_server_write(Ecore_Con_Server *svr, int num)
 {
    Ecore_Con_Event_Server_Write *e;
 
-   e = malloc(sizeof(Ecore_Con_Event_Server_Write));
+   e = ecore_con_event_server_write_alloc();
    EINA_SAFETY_ON_NULL_RETURN(e);
 
    svr->event_count++;
@@ -979,7 +983,7 @@ ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num,
 {
    Ecore_Con_Event_Server_Data *e;
 
-   e = malloc(sizeof(Ecore_Con_Event_Server_Data));
+   e = ecore_con_event_server_data_alloc();
    EINA_SAFETY_ON_NULL_RETURN(e);
 
    svr->event_count++;
@@ -990,8 +994,8 @@ ecore_con_event_server_data(Ecore_Con_Server *svr, unsigned char *buf, int num,
         e->data = malloc(num);
         if (!e->data)
           {
-             ERR("alloc!");
-             free(e);
+             ERR("server data allocation failure !");
+             _ecore_con_event_server_data_free(NULL, e);
              return;
           }
         memcpy(e->data, buf, num);
@@ -1009,7 +1013,7 @@ ecore_con_event_client_add(Ecore_Con_Client *cl)
    Ecore_Con_Event_Client_Add *e;
    int ev = ECORE_CON_EVENT_CLIENT_ADD;
 
-   e = calloc(1, sizeof(Ecore_Con_Event_Client_Add));
+   e = ecore_con_event_client_add_alloc();
    EINA_SAFETY_ON_NULL_RETURN(e);
 
    cl->event_count++;
@@ -1027,15 +1031,13 @@ ecore_con_event_client_del(Ecore_Con_Client *cl)
 {
     Ecore_Con_Event_Client_Del *e;
 
-    e = calloc(1, sizeof(Ecore_Con_Event_Client_Del));
+    if (!cl) return;
+    e = ecore_con_event_client_del_alloc();
     EINA_SAFETY_ON_NULL_RETURN(e);
 
-    if (cl)
-      {
-         cl->event_count++;
-         cl->host_server->event_count++;
-         _ecore_con_cl_timer_update(cl);
-      }
+    cl->event_count++;
+    cl->host_server->event_count++;
+    _ecore_con_cl_timer_update(cl);
     e->client = cl;
     ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
                     (Ecore_End_Cb)_ecore_con_event_client_del_free, cl->host_server);
@@ -1045,7 +1047,8 @@ void
 ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
 {
    Ecore_Con_Event_Client_Write *e;
-   e = malloc(sizeof(Ecore_Con_Event_Client_Write));
+
+   e = ecore_con_event_client_write_alloc();
    EINA_SAFETY_ON_NULL_RETURN(e);
 
    cl->host_server->event_count++;
@@ -1060,7 +1063,8 @@ void
 ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, Eina_Bool duplicate)
 {
    Ecore_Con_Event_Client_Data *e;
-   e = malloc(sizeof(Ecore_Con_Event_Client_Data));
+
+   e = ecore_con_event_client_data_alloc();
    EINA_SAFETY_ON_NULL_RETURN(e);
 
    cl->host_server->event_count++;
@@ -1072,8 +1076,8 @@ ecore_con_event_client_data(Ecore_Con_Client *cl, unsigned char *buf, int num, E
         e->data = malloc(num);
         if (!e->data)
           {
-             free(cl->client_addr);
-             free(cl);
+             ERR("client data allocation failure !");
+             _ecore_con_event_client_data_free(cl->host_server, e);
              return;
           }
         memcpy(e->data, buf, num);
@@ -1097,7 +1101,7 @@ ecore_con_event_server_error(Ecore_Con_Server *svr, const char *error)
 {
    Ecore_Con_Event_Server_Error *e;
 
-   e = calloc(1, sizeof(Ecore_Con_Event_Server_Error));
+   e = ecore_con_event_server_error_alloc();
    EINA_SAFETY_ON_NULL_RETURN(e);
 
    e->server = svr;
@@ -1112,7 +1116,7 @@ ecore_con_event_client_error(Ecore_Con_Client *cl, const char *error)
 {
    Ecore_Con_Event_Client_Error *e;
 
-   e = calloc(1, sizeof(Ecore_Con_Event_Client_Error));
+   e = ecore_con_event_client_error_alloc();
    EINA_SAFETY_ON_NULL_RETURN(e);
 
    e->client = cl;
@@ -2348,7 +2352,7 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *svr,
    if ((svr->event_count <= 0) && (svr->delete_me))
      _ecore_con_server_free(svr);
 
-   free(e);
+   ecore_con_event_client_add_free(e);
 }
 
 static void
@@ -2367,7 +2371,7 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
    if ((svr->event_count <= 0) && (svr->delete_me))
      _ecore_con_server_free(svr);
 
-   free(e);
+   ecore_con_event_client_del_free(e);
 }
 
 static void
@@ -2385,7 +2389,7 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *svr,
    if ((svr->event_count <= 0) && (svr->delete_me))
      _ecore_con_server_free(svr);
 
-   free(e);
+   ecore_con_event_client_write_free(e);
 }
 
 static void
@@ -2408,7 +2412,7 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *svr,
    if ((svr->event_count <= 0) && (svr->delete_me))
      _ecore_con_server_free(svr);
 
-   free(e);
+   ecore_con_event_client_data_free(e);
 }
 
 static void
@@ -2422,7 +2426,7 @@ _ecore_con_event_server_add_free(void *data __UNUSED__,
    if ((e->server->event_count <= 0) && (e->server->delete_me))
      _ecore_con_server_free(e->server);
 
-   free(e);
+   ecore_con_event_server_add_free(e);
 }
 
 static void
@@ -2436,7 +2440,7 @@ _ecore_con_event_server_del_free(void *data __UNUSED__,
    if ((e->server->event_count <= 0) && (e->server->delete_me))
      _ecore_con_server_free(e->server);
 
-   free(e);
+   ecore_con_event_server_del_free(e);
 }
 
 static void
@@ -2448,7 +2452,7 @@ _ecore_con_event_server_write_free(void *data __UNUSED__,
    if ((e->server->event_count <= 0) && (e->server->delete_me))
      _ecore_con_server_free(e->server);
 
-   free(e);
+   ecore_con_event_server_write_free(e);
 }
 
 static void
@@ -2465,7 +2469,7 @@ _ecore_con_event_server_data_free(void *data __UNUSED__,
    if ((e->server->event_count <= 0) && (e->server->delete_me))
      _ecore_con_server_free(e->server);
 
-   free(e);
+   ecore_con_event_server_data_free(e);
 }
 
 
@@ -2476,7 +2480,8 @@ _ecore_con_event_server_error_free(void *data __UNUSED__, Ecore_Con_Event_Server
    if ((e->server->event_count <= 0) && (e->server->delete_me))
      _ecore_con_server_free(e->server);
    if (e->error) free(e->error);
-   free(e);
+
+   ecore_con_event_server_error_free(e);
 }
 
 static void
@@ -2489,8 +2494,8 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *svr, Ecore_Con_Event_Client
    if ((svr->event_count <= 0) && (svr->delete_me))
      _ecore_con_server_free(svr);
    if (e->error) free(e->error);
-   free(e);
 
+   ecore_con_event_client_error_free(e);
 }
 
 static void
diff --git a/src/lib/ecore_con/ecore_con_alloc.c b/src/lib/ecore_con/ecore_con_alloc.c
new file mode 100644 (file)
index 0000000..341c839
--- /dev/null
@@ -0,0 +1,99 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "Ecore.h"
+#include "ecore_private.h"
+#include "Ecore_Con.h"
+#include "ecore_con_private.h"
+
+typedef struct _Ecore_Con_Mempool Ecore_Con_Mempool;
+struct _Ecore_Con_Mempool
+{
+   const char *name;
+   Eina_Mempool *mp;
+   size_t size;
+};
+
+#define GENERIC_ALLOC_FREE(TYPE, Type)                                  \
+  Ecore_Con_Mempool Type##_mp = { #TYPE,  NULL, sizeof (TYPE) };        \
+                                                                        \
+  TYPE *                                                                \
+  Type##_alloc(void)                                                    \
+  {                                                                     \
+     return eina_mempool_malloc(Type##_mp.mp, sizeof (TYPE));           \
+  }                                                                     \
+                                                                        \
+  void                                                                  \
+  Type##_free(TYPE *e)                                                  \
+  {                                                                     \
+     eina_mempool_free(Type##_mp.mp, e);                                \
+  }
+
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Add, ecore_con_event_client_add);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Del, ecore_con_event_client_del);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Write, ecore_con_event_client_write);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Data, ecore_con_event_client_data);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Error, ecore_con_event_server_error);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Client_Error, ecore_con_event_client_error);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Add, ecore_con_event_server_add);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Del, ecore_con_event_server_del);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Write, ecore_con_event_server_write);
+GENERIC_ALLOC_FREE(Ecore_Con_Event_Server_Data, ecore_con_event_server_data);
+
+static Ecore_Con_Mempool *mempool_array[] = {
+  &ecore_con_event_client_add_mp,
+  &ecore_con_event_client_del_mp,
+  &ecore_con_event_client_write_mp,
+  &ecore_con_event_client_data_mp,
+  &ecore_con_event_server_error_mp,
+  &ecore_con_event_client_error_mp,
+  &ecore_con_event_server_add_mp,
+  &ecore_con_event_server_del_mp,
+  &ecore_con_event_server_write_mp,
+  &ecore_con_event_server_data_mp
+};
+
+void
+ecore_con_mempool_init(void)
+{
+   const char *choice;
+   unsigned int i;
+
+   choice = getenv("EINA_MEMPOOL");
+   if (!choice || choice[0])
+     choice = "chained_mempool";
+
+   for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
+     {
+     retry:
+        mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 64);
+        if (!mempool_array[i]->mp)
+          {
+             if (strcmp(choice, "pass_through") != 0)
+               {
+                  ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice);
+                  choice = "pass_through";
+                  goto retry;
+               }
+             else
+               {
+                  ERR("Impossible to allocate mempool '%s' !", choice);
+                  return ;
+               }
+          }
+     }
+}
+
+void
+ecore_con_mempool_shutdown(void)
+{
+   unsigned int i;
+
+   for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
+     {
+        eina_mempool_del(mempool_array[i]->mp);
+        mempool_array[i]->mp = NULL;
+     }
+}
+
index 908f279..0179992 100644 (file)
@@ -298,5 +298,24 @@ int                 ecore_con_info_get(Ecore_Con_Server *svr,
                                        struct addrinfo *hints);
 
 
+#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \
+  TYPE *Type##_alloc(void);                  \
+  void Type##_free(TYPE *e);
+
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Add, ecore_con_event_client_add);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Del, ecore_con_event_client_del);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Write, ecore_con_event_client_write);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Data, ecore_con_event_client_data);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Error, ecore_con_event_server_error);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Client_Error, ecore_con_event_client_error);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Add, ecore_con_event_server_add);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Del, ecore_con_event_server_del);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Write, ecore_con_event_server_write);
+GENERIC_ALLOC_FREE_HEADER(Ecore_Con_Event_Server_Data, ecore_con_event_server_data);
+
+void ecore_con_mempool_init(void);
+void ecore_con_mempool_shutdown(void);
+
+#undef GENERIC_ALLOC_FREE_HEADER
 
 #endif
index 3bc7f39..7bc71f8 100644 (file)
@@ -700,7 +700,6 @@ _ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr)
      return ECORE_CON_SSL_ERROR_NONE;
    if (svr->verify)
      {
-        ret = 0;
         /* use CRL/CA lists to verify */
         SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_certificate_verify_peers2(svr->session, &iter));
         if (iter & GNUTLS_CERT_INVALID)
@@ -1001,7 +1000,6 @@ _ecore_con_ssl_client_init_gnutls(Ecore_Con_Client *cl)
    if (!cl->host_server->verify)
      /* not verifying certificates, so we're done! */
      return ECORE_CON_SSL_ERROR_NONE;
-   ret = 0;
    /* use CRL/CA lists to verify */
    SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_certificate_verify_peers2(cl->session, &iter));
    if (iter & GNUTLS_CERT_INVALID)
index 56c2f0b..48628bc 100644 (file)
 # include <ws2tcpip.h>
 #endif
 
+#ifdef HAVE_ESCAPE
+# include <Escape.h>
+#endif
+
 #include "Ecore.h"
 #include "ecore_private.h"
 #include "Ecore_Con.h"
index acb0db5..256e57c 100644 (file)
@@ -80,6 +80,7 @@ extern "C" {
 #define HAVE_ECORE_EVAS_SDL 1
 #define HAVE_ECORE_EVAS_WINCE 1
 #define HAVE_ECORE_EVAS_EWS 1
+#define HAVE_ECORE_EVAS_PSL1GHT 1
 
 typedef enum _Ecore_Evas_Engine_Type
 {
@@ -102,7 +103,8 @@ typedef enum _Ecore_Evas_Engine_Type
    ECORE_EVAS_ENGINE_SOFTWARE_16_DDRAW,
    ECORE_EVAS_ENGINE_SOFTWARE_16_WINCE,
    ECORE_EVAS_ENGINE_OPENGL_SDL,
-   ECORE_EVAS_ENGINE_EWS
+   ECORE_EVAS_ENGINE_EWS,
+   ECORE_EVAS_ENGINE_PSL1GHT
 } Ecore_Evas_Engine_Type;
 
 typedef enum _Ecore_Evas_Avoid_Damage_Type
@@ -953,6 +955,9 @@ EAPI Ecore_Evas *ecore_evas_cocoa_new(Ecore_Cocoa_Window *parent,
                                      int w,
                                      int h);
 
+EAPI Ecore_Evas *ecore_evas_psl1ght_new(const char* name, int w, int h);
+
+
 /* generic manipulation calls */
 /**
  * @brief Get the engine name used by this Ecore_Evas(window).
index c867d98..fbb7190 100644 (file)
@@ -58,6 +58,14 @@ ECORE_WINCE_INC =
 ECORE_WINCE_LIB =
 endif
 
+if BUILD_ECORE_PSL1GHT
+ECORE_PSL1GHT_INC = -I$(top_srcdir)/src/lib/ecore_psl1ght
+ECORE_PSL1GHT_LIB = $(top_builddir)/src/lib/ecore_psl1ght/libecore_psl1ght.la
+else
+ECORE_PSL1GHT_INC =
+ECORE_PSL1GHT_LIB =
+endif
+
 AM_CPPFLAGS = \
 -I$(top_srcdir)/src/lib/ecore \
 -I$(top_srcdir)/src/lib/ecore_evas \
@@ -75,6 +83,7 @@ $(ECORE_WIN32_INC) \
 $(ECORE_SDL_INC) \
 $(ECORE_COCOA_INC) \
 $(ECORE_WINCE_INC) \
+$(ECORE_PSL1GHT_INC) \
 @EVAS_CFLAGS@ \
 @EINA_CFLAGS@ \
 @EVIL_CFLAGS@
@@ -96,7 +105,8 @@ ecore_evas_win32.c \
 ecore_evas_sdl.c \
 ecore_evas_cocoa.c \
 ecore_evas_wince.c \
-ecore_evas_ews.c
+ecore_evas_ews.c \
+ecore_evas_psl1ght.c
 
 libecore_evas_la_LIBADD = \
 $(ECORE_X_LIB) \
@@ -107,6 +117,7 @@ $(ECORE_SDL_LIB) \
 $(ECORE_SDL_LIBADD) \
 $(ECORE_COCOA_LIB) \
 $(ECORE_WINCE_LIB) \
+$(ECORE_PSL1GHT_LIB) \
 $(top_builddir)/src/lib/ecore_input/libecore_input.la \
 $(top_builddir)/src/lib/ecore_input_evas/libecore_input_evas.la \
 $(top_builddir)/src/lib/ecore/libecore.la \
index 3cb656e..dc42f92 100644 (file)
@@ -182,14 +182,18 @@ ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine)
 #else
         return EINA_FALSE;
 #endif
-
       case ECORE_EVAS_ENGINE_EWS:
 #ifdef BUILD_ECORE_EVAS_EWS
         return EINA_TRUE;
 #else
         return EINA_FALSE;
 #endif
-
+     case ECORE_EVAS_ENGINE_PSL1GHT:
+#ifdef BUILD_ECORE_EVAS_PSL1GHT
+        return EINA_TRUE;
+#else
+        return EINA_FALSE;
+#endif
       default:
         return EINA_FALSE;
      };
@@ -556,6 +560,23 @@ _ecore_evas_constructor_fb(int x __UNUSED__, int y __UNUSED__, int w, int h, con
 }
 #endif
 
+
+#ifdef BUILD_ECORE_EVAS_PSL1GHT
+static Ecore_Evas *
+_ecore_evas_constructor_psl1ght(int x __UNUSED__, int y __UNUSED__, int w, int h, const char *extra_options)
+{
+   Ecore_Evas *ee;
+   char *name = NULL;
+
+   _ecore_evas_parse_extra_options_str(extra_options, "name=", &name);
+   ee = ecore_evas_psl1ght_new(name, w, h);
+   free(name);
+
+   if (ee) ecore_evas_move(ee, x, y);
+   return ee;
+}
+#endif
+
 #ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI
 static Ecore_Evas *
 _ecore_evas_constructor_software_gdi(int x, int y, int w, int h, const char *extra_options)
@@ -688,6 +709,11 @@ static const struct ecore_evas_engine _engines[] = {
   {"opengl_cocoa", _ecore_evas_constructor_cocoa},
 #endif
 
+  /* PS3 support */
+#ifdef BUILD_ECORE_EVAS_PSL1GHT
+  {"psl1ght", _ecore_evas_constructor_psl1ght},
+#endif
+
   /* Last chance to have a window */
 #ifdef BUILD_ECORE_EVAS_OPENGL_SDL
   {"opengl_sdl", _ecore_evas_constructor_opengl_sdl},
diff --git a/src/lib/ecore_evas/ecore_evas_psl1ght.c b/src/lib/ecore_evas/ecore_evas_psl1ght.c
new file mode 100644 (file)
index 0000000..88fa974
--- /dev/null
@@ -0,0 +1,463 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <Ecore.h>
+#include <Ecore_Input.h>
+#include <Ecore_Input_Evas.h>
+
+#include "ecore_evas_private.h"
+#include "Ecore_Evas.h"
+
+#ifdef BUILD_ECORE_EVAS_PSL1GHT
+#include <Ecore_Psl1ght.h>
+#include <Evas_Engine_PSL1GHT.h>
+
+static int _ecore_evas_init_count = 0;
+
+static Ecore_Evas *psl1ght_ee = NULL;
+static Ecore_Event_Handler *ecore_evas_event_handlers[4] = {
+   NULL, NULL, NULL, NULL
+};
+
+static const char *ecore_evas_psl1ght_default = "EFL PSL1GHT";
+static int _ecore_evas_fps_debug = 0;
+static Ecore_Poller *ecore_evas_event;
+
+static unsigned int
+_ecore_evas_time_get()
+{
+   return (unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff;
+}
+
+static Ecore_Evas *
+_ecore_evas_psl1ght_match(void)
+{
+   return psl1ght_ee;
+}
+
+static Eina_Bool
+_ecore_evas_psl1ght_event_got_focus(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
+{
+   Ecore_Evas *ee;
+
+   ee = _ecore_evas_psl1ght_match();
+
+   if (!ee) return ECORE_CALLBACK_PASS_ON;
+   /* pass on event */
+   ee->prop.focused = 1;
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static Eina_Bool
+_ecore_evas_psl1ght_event_lost_focus(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
+{
+   Ecore_Evas *ee;
+
+   ee = _ecore_evas_psl1ght_match();
+
+   if (!ee) return ECORE_CALLBACK_PASS_ON;
+   /* pass on event */
+   ee->prop.focused = 0;
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static Eina_Bool
+_ecore_evas_psl1ght_event_video_expose(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
+{
+   Ecore_Evas *ee;
+   int w;
+   int h;
+
+   ee = _ecore_evas_psl1ght_match();
+
+   if (!ee) return ECORE_CALLBACK_PASS_ON;
+   evas_output_size_get(ee->evas, &w, &h);
+   evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static Eina_Bool
+_ecore_evas_psl1ght_event_key_modifiers(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+   Ecore_Evas *ee;
+   Ecore_Psl1ght_Event_Key_Modifiers *e = event;
+
+   ee = _ecore_evas_psl1ght_match();
+
+   if (!ee) return ECORE_CALLBACK_PASS_ON;
+   ecore_event_evas_modifier_lock_update(ee->evas, e->modifiers);
+
+   return ECORE_CALLBACK_DONE;
+}
+
+static int
+_ecore_evas_render(Ecore_Evas *ee)
+{
+   Eina_List *updates;
+
+   updates = evas_render_updates(ee->evas);
+   if (updates)
+     {
+        evas_render_updates_free(updates);
+        _ecore_evas_idle_timeout_update(ee);
+     }
+   return updates ? 1 : 0;
+}
+
+static int
+_ecore_evas_psl1ght_render(Ecore_Evas *ee)
+{
+   int rend = 0;
+
+#ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
+   Eina_List *ll;
+   Ecore_Evas *ee2;
+
+   EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2)
+     {
+        if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2);
+        rend |= _ecore_evas_buffer_render(ee2);
+        if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2);
+     }
+#endif
+
+   if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
+
+   if (ee->prop.avoid_damage) rend = _ecore_evas_render(ee);
+   else if ((ee->visible) ||
+            ((ee->should_be_visible) && (ee->prop.fullscreen)) ||
+            ((ee->should_be_visible) && (ee->prop.override)))
+     rend |= _ecore_evas_render(ee);
+   else
+     evas_norender(ee->evas);
+
+   if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
+   return rend;
+}
+
+static Eina_Bool
+_ecore_evas_psl1ght_event(void *data __UNUSED__)
+{
+   ecore_psl1ght_poll_events();
+   return ECORE_CALLBACK_RENEW;
+}
+
+static int
+_ecore_evas_psl1ght_init(int w __UNUSED__, int h __UNUSED__)
+{
+   _ecore_evas_init_count++;
+   if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
+
+   _ecore_evas_fps_debug = 1;
+
+   // this is pretty bad: poller? and set poll time? pol time is meant to be
+   // adjustable for things like polling battery state, or amoutn of spare
+   // memory etc.
+   //
+   ecore_evas_event = ecore_poller_add(ECORE_POLLER_CORE, 1, _ecore_evas_psl1ght_event, NULL);
+   ecore_poller_poll_interval_set(ECORE_POLLER_CORE, 0.006);
+
+   if (_ecore_evas_fps_debug)
+     _ecore_evas_fps_debug_init();
+
+   ecore_event_evas_init();
+
+   ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_PSL1GHT_EVENT_GOT_FOCUS, _ecore_evas_psl1ght_event_got_focus, NULL);
+   ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_PSL1GHT_EVENT_LOST_FOCUS, _ecore_evas_psl1ght_event_lost_focus, NULL);
+   ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_PSL1GHT_EVENT_EXPOSE, _ecore_evas_psl1ght_event_video_expose, NULL);
+   ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_PSL1GHT_EVENT_KEY_MODIFIERS, _ecore_evas_psl1ght_event_key_modifiers, NULL);
+
+   return _ecore_evas_init_count;
+}
+
+static int
+_ecore_evas_psl1ght_shutdown(void)
+{
+   _ecore_evas_init_count--;
+   if (_ecore_evas_init_count == 0)
+     {
+        unsigned int i;
+
+        for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler *); i++)
+          ecore_event_handler_del(ecore_evas_event_handlers[i]);
+        ecore_event_evas_shutdown();
+        ecore_poller_del(ecore_evas_event);
+        ecore_evas_event = NULL;
+        if (_ecore_evas_fps_debug)
+          _ecore_evas_fps_debug_shutdown();
+     }
+   if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
+   return _ecore_evas_init_count;
+}
+
+static void
+_ecore_evas_psl1ght_free(Ecore_Evas *ee)
+{
+   if (psl1ght_ee == ee) psl1ght_ee = NULL;
+
+   ecore_event_window_unregister(0);
+   _ecore_evas_psl1ght_shutdown();
+   ecore_psl1ght_shutdown();
+}
+
+static void
+_ecore_evas_screen_resized(Ecore_Evas *ee)
+{
+   int w, h;
+
+   /* Do not resize if the window is not fullscreen */
+   if (ee->prop.fullscreen == 0) return;
+
+   ecore_psl1ght_screen_resolution_get (&w, &h);
+
+   if (w != ee->w || h != ee->h)
+     {
+        ee->req.w = ee->w = w;
+        ee->req.h = ee->h = h;
+        evas_output_size_set(ee->evas, ee->w, ee->h);
+        evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
+        ecore_psl1ght_resolution_set (w, h);
+        evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+
+        _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y,
+                                       _ecore_evas_time_get());
+        if (ee->func.fn_resize) ee->func.fn_resize(ee);
+     }
+}
+
+static void
+_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
+{
+   if ((w == ee->w) && (h == ee->h)) return;
+   ee->w = w;
+   ee->h = h;
+
+   evas_output_size_set(ee->evas, ee->w, ee->h);
+
+   evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
+   evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+
+   ecore_psl1ght_resolution_set (w, h);
+
+   if (ee->func.fn_resize) ee->func.fn_resize(ee);
+
+   _ecore_evas_screen_resized (ee);
+}
+
+static void
+_ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h)
+{
+   _ecore_evas_resize (ee, w, h);
+}
+
+static void
+_ecore_evas_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h)
+{
+   if (x) *x = 0;
+   if (y) *y = 0;
+   ecore_psl1ght_screen_resolution_get (w, h);
+}
+
+static void
+_ecore_evas_object_cursor_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Ecore_Evas *ee;
+
+   ee = data;
+   if (ee)
+     ee->prop.cursor.object = NULL;
+}
+
+static void
+_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
+{
+   int x, y;
+
+   if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
+
+   if (!obj)
+     {
+        ee->prop.cursor.object = NULL;
+        ee->prop.cursor.layer = 0;
+        ee->prop.cursor.hot.x = 0;
+        ee->prop.cursor.hot.y = 0;
+        return;
+     }
+
+   ee->prop.cursor.object = obj;
+   ee->prop.cursor.layer = layer;
+   ee->prop.cursor.hot.x = hot_x;
+   ee->prop.cursor.hot.y = hot_y;
+   evas_pointer_output_xy_get(ee->evas, &x, &y);
+   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   evas_object_move(ee->prop.cursor.object,
+                    x - ee->prop.cursor.hot.x,
+                    y - ee->prop.cursor.hot.y);
+   evas_object_pass_events_set(ee->prop.cursor.object, 1);
+   if (evas_pointer_inside_get(ee->evas))
+     evas_object_show(ee->prop.cursor.object);
+
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+}
+
+static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func =
+{
+   _ecore_evas_psl1ght_free,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   _ecore_evas_resize,
+   _ecore_evas_move_resize,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   _ecore_evas_object_cursor_set,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL,
+   NULL, //transparent
+
+   NULL, // render
+   _ecore_evas_screen_geometry_get  // screen_geometry_get
+};
+
+EAPI Ecore_Evas *
+ecore_evas_psl1ght_new(const char *name, int w, int h)
+{
+   void *einfo;
+   Ecore_Evas *ee;
+
+   if (!name)
+     name = ecore_evas_psl1ght_default;
+
+   ee = calloc(1, sizeof(Ecore_Evas));
+   if (!ee) return NULL;
+
+   ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
+
+   ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_psl1ght_engine_func;
+
+   ee->driver = "psl1ght";
+   if (name) ee->name = strdup(name);
+
+   if (w < 1) w = 1;
+   if (h < 1) h = 1;
+   ee->visible = 1;
+   ee->w = w;
+   ee->h = h;
+
+   ee->prop.max.w = 0;
+   ee->prop.max.h = 0;
+   ee->prop.layer = 0;
+   ee->prop.focused = 1;
+   ee->prop.borderless = 1;
+   ee->prop.override = 1;
+   ee->prop.maximized = 1;
+   ee->prop.fullscreen = 0;
+   ee->prop.withdrawn = 0;
+   ee->prop.sticky = 0;
+   ee->prop.window = 0;
+
+   /* init evas here */
+   ee->evas = evas_new();
+   evas_data_attach_set(ee->evas, ee);
+   evas_output_method_set(ee->evas, evas_render_method_lookup("psl1ght"));
+
+   evas_output_size_set(ee->evas, w, h);
+   evas_output_viewport_set(ee->evas, 0, 0, w, h);
+
+   einfo = evas_engine_info_get(ee->evas);
+   if (einfo)
+     {
+        if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
+          {
+             ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
+             ecore_evas_free(ee);
+             return NULL;
+          }
+     }
+   else
+     {
+        ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver);
+        ecore_evas_free(ee);
+        return NULL;
+     }
+
+   if (!ecore_psl1ght_init(name))
+     {
+        evas_free(ee->evas);
+        if (ee->name) free(ee->name);
+        free(ee);
+        return NULL;
+     }
+   ecore_psl1ght_resolution_set (w, h);
+
+   _ecore_evas_psl1ght_init(w, h);
+
+   ecore_event_window_register(0, ee, ee->evas,
+                               (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
+                               (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
+                               (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
+                               (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
+
+   ee->engine.func->fn_render = _ecore_evas_psl1ght_render;
+   _ecore_evas_register(ee);
+
+   psl1ght_ee = ee;
+
+   evas_event_feed_mouse_in(ee->evas, _ecore_evas_time_get (), NULL);
+   evas_focus_in(ee->evas);
+   _ecore_evas_screen_resized (ee);
+
+   if (getenv("ECORE_EVAS_PSL1GHT_CURSOR_PATH"))
+     ecore_evas_cursor_set(ee, getenv("ECORE_EVAS_PSL1GHT_CURSOR_PATH"), EVAS_LAYER_MAX, 0, 0);
+
+   return ee;
+}
+
+#else /* BUILD_ECORE_EVAS_PSL1GHT */
+
+EAPI Ecore_Evas *
+ecore_evas_psl1ght_new(const char *name __UNUSED__, int w __UNUSED__, int h __UNUSED__)
+{
+   ERR("OUTCH !");
+   return NULL;
+}
+
+#endif /* BUILD_ECORE_EVAS_PSL1GHT */
index 5fdb21c..09e3f37 100644 (file)
@@ -29,13 +29,12 @@ static void *_ecore_fb_func_fb_gain_data = NULL;
 /* FIXME what is the filter for? */
 static Ecore_Event_Filter *_ecore_fb_filter_handler = NULL;
 
-static void *_ecore_fb_event_filter_start(void *data);
-static Eina_Bool   _ecore_fb_event_filter_filter(void *data, void *loop_data, int type, void *event);
-static void  _ecore_fb_event_filter_end(void *data, void *loop_data);
-
 /* prototypes */
 /* XXX: unused
 static void _ecore_fb_vt_switch(int vt);
+static void *_ecore_fb_event_filter_start(void *data);
+static Eina_Bool _ecore_fb_event_filter_filter(void *data, void *loop_data, int type, void *event);
+static void _ecore_fb_event_filter_end(void *data, void *loop_data);
 */
 
 static Eina_Bool
index bed6f8d..ca80665 100644 (file)
@@ -105,14 +105,14 @@ _ecore_file_download(const char *url,
 
    if (!ecore_file_is_dir(dir))
      {
-        EINA_LOG_ERR("%s is not a directory", dir);
+        ERR("%s is not a directory", dir);
         free(dir);
         return EINA_FALSE;
      }
    free(dir);
    if (ecore_file_exists(dst))
      {
-        EINA_LOG_ERR("%s already exists", dst);
+        WRN("%s already exists", dst);
         return EINA_FALSE;
      }
 
@@ -140,7 +140,7 @@ _ecore_file_download(const char *url,
           return EINA_TRUE;
         else
           {
-             EINA_LOG_ERR("no job returned\n");
+             ERR("no job returned\n");
              return EINA_FALSE;
           }
         return job ? EINA_TRUE : EINA_FALSE;
@@ -374,6 +374,7 @@ _ecore_file_download_curl(const char *url, const char *dst,
         ecore_con_url_free(job->url_con);
         _job_list = eina_list_remove(_job_list, job);
         fclose(job->file);
+        ecore_file_remove(job->dst);
         free(job->dst);
         free(job);
         return NULL;
index 9d798e4..60bbe5c 100644 (file)
 # include <Evil.h>
 #endif
 
+#ifdef HAVE_ESCAPE
+# include <Escape.h>
+#endif
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
diff --git a/src/lib/ecore_psl1ght/Ecore_Psl1ght.h b/src/lib/ecore_psl1ght/Ecore_Psl1ght.h
new file mode 100644 (file)
index 0000000..39331f7
--- /dev/null
@@ -0,0 +1,124 @@
+#ifndef _ECORE_PSL1GHT_H
+#define _ECORE_PSL1GHT_H
+
+#ifdef EAPI
+# undef EAPI
+#endif
+
+#ifdef __GNUC__
+# if __GNUC__ >= 4
+#  define EAPI __attribute__ ((visibility("default")))
+# else
+#  define EAPI
+# endif
+#else
+# define EAPI
+#endif
+
+/**
+ * @file
+ * @brief Ecore PSL1GHT system functions.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EAPI extern int ECORE_PSL1GHT_EVENT_KEY_MODIFIERS;
+EAPI extern int ECORE_PSL1GHT_EVENT_GOT_FOCUS;
+EAPI extern int ECORE_PSL1GHT_EVENT_LOST_FOCUS;
+EAPI extern int ECORE_PSL1GHT_EVENT_EXPOSE;
+
+typedef struct _Ecore_Psl1ght_Event_Key_Modifiers Ecore_Psl1ght_Event_Key_Modifiers;
+struct _Ecore_Psl1ght_Event_Key_Modifiers /** PSL1GHT Key Modifier event */
+{
+   unsigned int timestamp;
+   unsigned int modifiers;
+   int          shift_changed : 1;
+   int          shift : 1;
+   int          alt_changed : 1;
+   int          alt : 1;
+   int          ctrl_changed : 1;
+   int          ctrl : 1;
+   int          win_changed : 1;
+   int          win : 1;
+   int          num_lock_changed : 1;
+   int          num_lock : 1;
+   int          caps_lock_changed : 1;
+   int          caps_lock : 1;
+   int          scroll_lock_changed : 1;
+   int          scroll_lock : 1;
+};
+
+typedef struct _Ecore_Psl1ght_Event_Key_Down Ecore_Psl1ght_Event_Key_Down;
+struct _Ecore_Psl1ght_Event_Key_Down /** PSL1GHT Key Down event */
+{
+   const char  *keyname;     /**< The name of the key that was pressed */
+   const char  *keycompose;     /**< The UTF-8 string conversion if any */
+   unsigned int time;
+};
+
+typedef struct _Ecore_Psl1ght_Event_Key_Up Ecore_Psl1ght_Event_Key_Up;
+struct _Ecore_Psl1ght_Event_Key_Up /** PSL1GHT Key Up event */
+{
+   const char  *keyname;     /**< The name of the key that was released */
+   const char  *keycompose;     /**< The UTF-8 string conversion if any */
+   unsigned int time;
+};
+
+typedef struct _Ecore_Psl1ght_Event_Mouse_Button_Down Ecore_Psl1ght_Event_Mouse_Button_Down;
+struct _Ecore_Psl1ght_Event_Mouse_Button_Down /** PSL1GHT Mouse Down event */
+{
+   int          button;    /**< Mouse button that was pressed (1 - 32) */
+   int          x;    /**< Mouse co-ordinates when mouse button was pressed */
+   int          y;    /**< Mouse co-ordinates when mouse button was pressed */
+   int          double_click : 1;    /**< Set if click was a double click */
+   int          triple_click : 1;    /**< Set if click was a triple click  */
+   unsigned int time;
+};
+
+typedef struct _Ecore_Psl1ght_Event_Mouse_Button_Up Ecore_Psl1ght_Event_Mouse_Button_Up;
+struct _Ecore_Psl1ght_Event_Mouse_Button_Up /** PSL1GHT Mouse Up event */
+{
+   int          button;    /**< Mouse button that was released (1 - 32) */
+   int          x;    /**< Mouse co-ordinates when mouse button was raised */
+   int          y;    /**< Mouse co-ordinates when mouse button was raised */
+   int          double_click : 1;    /**< Set if click was a double click */
+   int          triple_click : 1;    /**< Set if click was a triple click  */
+   unsigned int time;
+};
+
+typedef struct _Ecore_Psl1ght_Event_Mouse_Move Ecore_Psl1ght_Event_Mouse_Move;
+struct _Ecore_Psl1ght_Event_Mouse_Move /** PSL1GHT Mouse Move event */
+{
+   int          x;    /**< Mouse co-ordinates where the mouse cursor moved to */
+   int          y;    /**< Mouse co-ordinates where the mouse cursor moved to */
+   unsigned int time;
+};
+
+typedef struct _Ecore_Psl1ght_Event_Mouse_Wheel Ecore_Psl1ght_Event_Mouse_Wheel;
+struct _Ecore_Psl1ght_Event_Mouse_Wheel /** PSL1GHT Mouse Wheel event */
+{
+   int          x, y;
+   int          direction;    /* 0 = vertical, 1 = horizontal */
+   int          wheel;    /* value 1 (left/up), -1 (right/down) */
+   unsigned int time;
+};
+
+EAPI int
+          ecore_psl1ght_init(const char *name);
+EAPI int
+          ecore_psl1ght_shutdown(void);
+EAPI void
+          ecore_psl1ght_resolution_set(int width, int height);
+EAPI void
+          ecore_psl1ght_poll_events(void);
+
+EAPI void ecore_psl1ght_screen_resolution_get(int *w, int *h);
+EAPI void ecore_psl1ght_optimal_screen_resolution_get(int *w, int *h);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h b/src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h
new file mode 100644 (file)
index 0000000..e385af8
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef         ECORE_PSL1GHT_KEYS_H__
+# define        ECORE_PSL1GHT_KEYS_H__
+
+struct _ecore_psl1ght_keys_s
+{
+   int         code;
+   const char *name;
+   const char *compose;
+};
+
+static const struct _ecore_psl1ght_keys_s keystable[] =
+{
+   { KB_RAWKEY_NO_EVENT, "0x00", "" },
+   { KB_RAWKEY_BS, "BackSpace", "\010" },
+   { KB_RAWKEY_TAB, "Tab", "\011" },
+   { KB_RAWKEY_ENTER, "Return", "\015" },
+   { KB_RAWKEY_PAUSE, "Pause", "Pause" },
+   { KB_RAWKEY_ESCAPE, "Escape", "\033" },
+   { KB_RAWKEY_SPACE, "space", " " },
+
+   /* Skip uppercase letters */
+   { KB_RAWKEY_LEFT_BRACKET_101, "bracketleft", "[" },
+   { KB_RAWKEY_BACKSLASH_101, "backslash", "\\" },
+   { KB_RAWKEY_RIGHT_BRACKET_101, "bracketright", "]" },
+   { KB_RAWKEY_ACCENT_CIRCONFLEX_106, "asciicircumm", "^" },
+   { KB_RAWKEY_DELETE, "Delete", "\177" },
+   /* End of ASCII mapped keysyms */
+
+   /* Numeric keypad */
+   { KB_RAWKEY_KPAD_0, "KP0", "0" },
+   { KB_RAWKEY_KPAD_1, "KP1", "1" },
+   { KB_RAWKEY_KPAD_2, "KP2", "2" },
+   { KB_RAWKEY_KPAD_3, "KP3", "3" },
+   { KB_RAWKEY_KPAD_4, "KP4", "4" },
+   { KB_RAWKEY_KPAD_5, "KP5", "5" },
+   { KB_RAWKEY_KPAD_6, "KP6", "6" },
+   { KB_RAWKEY_KPAD_7, "KP7", "7" },
+   { KB_RAWKEY_KPAD_8, "KP8", "8" },
+   { KB_RAWKEY_KPAD_9, "KP9", "9" },
+   { KB_RAWKEY_KPAD_PERIOD, "period", "." },
+   { KB_RAWKEY_KPAD_SLASH, "KP_Divide", "/" },
+   { KB_RAWKEY_KPAD_ASTERISK, "KP_Multiply", "*" },
+   { KB_RAWKEY_KPAD_MINUS, "KP_Minus", "-" },
+   { KB_RAWKEY_KPAD_PLUS, "KP_Plus", "+" },
+   { KB_RAWKEY_KPAD_ENTER, "KP_Enter", "\015" },
+
+   /* Arrows + Home/End pad */
+   { KB_RAWKEY_UP_ARROW, "Up", "Up" },
+   { KB_RAWKEY_DOWN_ARROW, "Down", "Down" },
+   { KB_RAWKEY_RIGHT_ARROW, "Right", "Right" },
+   { KB_RAWKEY_LEFT_ARROW, "Left", "Left" },
+   { KB_RAWKEY_INSERT, "Insert", "Insert" },
+   { KB_RAWKEY_HOME, "Home", "Home" },
+   { KB_RAWKEY_END, "End", "End" },
+   { KB_RAWKEY_PAGE_UP, "Page_Up", "Page_Up" },
+   { KB_RAWKEY_PAGE_DOWN, "Page_Down", "Page_Down" },
+
+   /* Function keys */
+   { KB_RAWKEY_F1, "F1", "F1" },
+   { KB_RAWKEY_F2, "F2", "F2" },
+   { KB_RAWKEY_F3, "F3", "F3" },
+   { KB_RAWKEY_F4, "F4", "F4" },
+   { KB_RAWKEY_F5, "F5", "F5" },
+   { KB_RAWKEY_F6, "F6", "F6" },
+   { KB_RAWKEY_F7, "F7", "F7" },
+   { KB_RAWKEY_F8, "F8", "F8" },
+   { KB_RAWKEY_F9, "F9", "F9" },
+   { KB_RAWKEY_F10, "F10", "F10" },
+   { KB_RAWKEY_F11, "F11", "F11" },
+   { KB_RAWKEY_F12, "F12", "F12" },
+
+   /* Key state modifier keys */
+   { KB_RAWKEY_KPAD_NUMLOCK, "Num_Lock", "Num_Lock" },
+   { KB_RAWKEY_CAPS_LOCK, "Caps_Lock", "Caps_Lock" },
+   { KB_RAWKEY_SCROLL_LOCK, "Scroll_Lock", "Scroll_Lock" },
+};
+
+#endif  /* ECORE_PSL1GHT_KEYS_H__ */
diff --git a/src/lib/ecore_psl1ght/Makefile.am b/src/lib/ecore_psl1ght/Makefile.am
new file mode 100644 (file)
index 0000000..8e7328a
--- /dev/null
@@ -0,0 +1,30 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I$(top_srcdir)/src/lib/ecore \
+-I$(top_srcdir)/src/lib/ecore_evas \
+-I$(top_srcdir)/src/lib/ecore_input \
+-I$(top_builddir)/src/lib/ecore \
+-I$(top_builddir)/src/lib/ecore_evas \
+-I$(top_builddir)/src/lib/ecore_input \
+@EFL_ECORE_PSL1GHT_BUILD@ \
+@EVAS_CFLAGS@ \
+@EINA_CFLAGS@
+
+lib_LTLIBRARIES = libecore_psl1ght.la
+includes_HEADERS = Ecore_Psl1ght.h
+includesdir = $(includedir)/ecore-@VMAJ@
+
+libecore_psl1ght_la_SOURCES = \
+ecore_psl1ght.c \
+moveutil.c \
+spursutil.c
+
+libecore_psl1ght_la_LIBADD = \
+$(top_builddir)/src/lib/ecore/libecore.la \
+$(top_builddir)/src/lib/ecore_input/libecore_input.la \
+@EINA_LIBS@
+
+libecore_psl1ght_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
+
+EXTRA_DIST = Ecore_Psl1ght_Keys.h ecore_psl1ght_private.h
diff --git a/src/lib/ecore_psl1ght/ecore_psl1ght.c b/src/lib/ecore_psl1ght/ecore_psl1ght.c
new file mode 100644 (file)
index 0000000..64cef9f
--- /dev/null
@@ -0,0 +1,804 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sysutil/video.h>
+#include <sysutil/sysutil.h>
+#include <sysmodule/sysmodule.h>
+#include <io/pad.h>
+#include <io/mouse.h>
+#include <io/kb.h>
+#include <io/camera.h>
+#include <io/move.h>
+#include <sys/process.h>
+
+#include "moveutil.h"
+
+#include "Eina.h"
+#include "Ecore_Psl1ght.h"
+#include "Ecore_Input.h"
+#include "Ecore.h"
+#include "ecore_psl1ght_private.h"
+#include "ecore_private.h"
+#include "Ecore_Psl1ght_Keys.h"
+
+/* Allocate 1MB stack to avoid overflows */
+SYS_PROCESS_PARAM(1001, 0x100000);
+
+int _ecore_psl1ght_log_dom = -1;
+
+EAPI int ECORE_PSL1GHT_EVENT_KEY_MODIFIERS = 0;
+EAPI int ECORE_PSL1GHT_EVENT_GOT_FOCUS = 0;
+EAPI int ECORE_PSL1GHT_EVENT_LOST_FOCUS = 0;
+EAPI int ECORE_PSL1GHT_EVENT_EXPOSE = 0;
+
+static int _ecore_psl1ght_init_count = 0;
+static int window_width = 0;
+static int window_height = 0;
+/* Mouse support */
+static int mouse_connected = FALSE;
+static u8 mouse_buttons = 0;
+static int mouse_x = 0;
+static int mouse_y = 0;
+/* Keyboard support */
+static int keyboard_connected = FALSE;
+static KbLed keyboard_leds = {{0}};
+static KbMkey keyboard_mods = {{0}};
+static u16 keyboard_old_key = 0;
+/* Pad support */
+static padData pad_data;
+static int pad_old_x = 0;
+static int pad_old_o = 0;
+/* Move support */
+static int move_connected = FALSE;
+static moveContext *move_context = NULL;
+u16 move_buttons = 0;
+
+static void xmb_event_handler(u64 status, u64 param, void *user_data);
+
+/**
+ * @defgroup Ecore_Psl1ght_Library_Group PSL1GHT Library Functions
+ *
+ * Functions used to set up and shut down the Ecore_Psl1ght functions.
+ */
+
+/**
+ * Sets up the Ecore_Psl1ght library.
+ * @param   name device target name
+ * @return  @c 0 on failure.  Otherwise, the number of times the library has
+ *          been initialised without being shut down.
+ * @ingroup Ecore_PSL1GHT_Library_Group
+ */
+EAPI int
+ecore_psl1ght_init(const char *name __UNUSED__)
+{
+   videoState state;
+   videoResolution resolution;
+   int ret, camera_loaded, gem_loaded;
+
+   if (++_ecore_psl1ght_init_count != 1)
+     return _ecore_psl1ght_init_count;
+   _ecore_psl1ght_log_dom = eina_log_domain_register
+       ("ecore_psl1ght", ECORE_PSL1GHT_DEFAULT_LOG_COLOR);
+   if (_ecore_psl1ght_log_dom < 0)
+     {
+        EINA_LOG_ERR("Impossible to create a log domain for the Ecore PSL1GHT module.");
+        return --_ecore_psl1ght_init_count;
+     }
+   if (!ecore_event_init())
+     {
+        eina_log_domain_unregister(_ecore_psl1ght_log_dom);
+        _ecore_psl1ght_log_dom = -1;
+        return --_ecore_psl1ght_init_count;
+     }
+
+   if (videoGetState (0, 0, &state) == 0 &&
+       videoGetResolution (state.displayMode.resolution, &resolution) == 0)
+     {
+        ecore_psl1ght_resolution_set (resolution.width, resolution.height);
+     }
+   else
+     {
+        ecore_event_shutdown();
+        eina_log_domain_unregister(_ecore_psl1ght_log_dom);
+        _ecore_psl1ght_log_dom = -1;
+        return --_ecore_psl1ght_init_count;
+     }
+
+   /* Pad support */
+   ioPadInit (7);
+   /* Mouse support */
+   ioMouseInit(2);
+   mouse_buttons = 0;
+   mouse_x = 0;
+   mouse_y = 0;
+
+   /* Keyboard support */
+   ioKbInit(2);
+   keyboard_leds._KbLedU.leds = 0;
+   keyboard_mods._KbMkeyU.mkeys = 0;
+
+   /* Initialize Move */
+   move_context = NULL;
+   move_buttons = 0;
+
+   camera_loaded = !sysModuleIsLoaded (SYSMODULE_CAMERA);
+   if (!camera_loaded)
+     ret = sysModuleLoad (SYSMODULE_CAMERA);
+   else
+     ret = 0;
+   if (ret == 0)
+     {
+        gem_loaded = !sysModuleIsLoaded (SYSMODULE_GEM);
+        if (!gem_loaded)
+          ret = sysModuleLoad (SYSMODULE_GEM);
+        if (ret == 0)
+          {
+             move_context = initMove ();
+          }
+        else {
+             if (gem_loaded)
+               sysModuleUnload (SYSMODULE_CAMERA);
+          }
+     }
+
+   sysUtilRegisterCallback (SYSUTIL_EVENT_SLOT0, xmb_event_handler, NULL);
+
+   ECORE_PSL1GHT_EVENT_GOT_FOCUS = ecore_event_type_new();
+   ECORE_PSL1GHT_EVENT_LOST_FOCUS = ecore_event_type_new();
+   ECORE_PSL1GHT_EVENT_EXPOSE = ecore_event_type_new();
+   ECORE_PSL1GHT_EVENT_KEY_MODIFIERS = ecore_event_type_new();
+
+   mouse_x = 0;
+   mouse_y = 0;
+
+   return _ecore_psl1ght_init_count;
+}
+
+/**
+ * Shuts down the Ecore_Psl1ght library.
+ * @return  @c The number of times the system has been initialised without
+ *             being shut down.
+ * @ingroup Ecore_PSL1GHT_Library_Group
+ */
+EAPI int
+ecore_psl1ght_shutdown(void)
+{
+   if (--_ecore_psl1ght_init_count != 0)
+     return _ecore_psl1ght_init_count;
+
+   ecore_event_shutdown();
+   eina_log_domain_unregister(_ecore_psl1ght_log_dom);
+   _ecore_psl1ght_log_dom = -1;
+
+   ECORE_PSL1GHT_EVENT_GOT_FOCUS = 0;
+   ECORE_PSL1GHT_EVENT_LOST_FOCUS = 0;
+   ECORE_PSL1GHT_EVENT_EXPOSE = 0;
+   ECORE_PSL1GHT_EVENT_KEY_MODIFIERS = 0;
+
+   ioPadEnd();
+   ioMouseEnd();
+   ioKbEnd();
+
+   if (move_context)
+     {
+        endMove (move_context);
+        move_context = NULL;
+        sysModuleUnload (SYSMODULE_CAMERA);
+        sysModuleUnload (SYSMODULE_GEM);
+     }
+
+   sysUtilUnregisterCallback(SYSUTIL_EVENT_SLOT0);
+
+   return _ecore_psl1ght_init_count;
+}
+
+static unsigned int
+_ecore_psl1ght_get_time(void)
+{
+   return (unsigned int)((unsigned long long)
+                         (ecore_time_get() * 1000.0) & 0xffffffff);
+}
+
+static unsigned int
+_ecore_psl1ght_get_modifiers(void)
+{
+   unsigned int modifiers = 0;
+
+   if (keyboard_mods._KbMkeyU._KbMkeyS.r_shift ||
+       keyboard_mods._KbMkeyU._KbMkeyS.l_shift)
+     modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
+   if (keyboard_mods._KbMkeyU._KbMkeyS.r_ctrl ||
+       keyboard_mods._KbMkeyU._KbMkeyS.l_ctrl)
+     modifiers |= ECORE_EVENT_MODIFIER_CTRL;
+   if (keyboard_mods._KbMkeyU._KbMkeyS.r_alt ||
+       keyboard_mods._KbMkeyU._KbMkeyS.l_alt)
+     modifiers |= ECORE_EVENT_MODIFIER_ALT;
+   if (keyboard_mods._KbMkeyU._KbMkeyS.r_win ||
+       keyboard_mods._KbMkeyU._KbMkeyS.l_win)
+     modifiers |= ECORE_EVENT_MODIFIER_WIN;
+
+   if (keyboard_leds._KbLedU._KbLedS.num_lock)
+     modifiers |= ECORE_EVENT_LOCK_NUM;
+   if (keyboard_leds._KbLedU._KbLedS.caps_lock)
+     modifiers |= ECORE_EVENT_LOCK_CAPS;
+   if (keyboard_leds._KbLedU._KbLedS.scroll_lock)
+     modifiers |= ECORE_EVENT_LOCK_SCROLL;
+
+   return modifiers;
+}
+
+static void
+_ecore_psl1ght_key_modifiers(KbMkey *mods, KbLed *leds)
+{
+   Ecore_Psl1ght_Event_Key_Modifiers *ev;
+   Eina_Bool emit = EINA_FALSE;
+
+   ev = malloc(sizeof(Ecore_Psl1ght_Event_Key_Modifiers));
+   if (!ev) return;
+
+   if (mods->_KbMkeyU._KbMkeyS.l_shift !=
+       keyboard_mods._KbMkeyU._KbMkeyS.l_shift ||
+       mods->_KbMkeyU._KbMkeyS.r_shift !=
+       keyboard_mods._KbMkeyU._KbMkeyS.r_shift)
+     {
+        emit = EINA_TRUE;
+        ev->shift_changed = EINA_TRUE;
+        ev->shift = mods->_KbMkeyU._KbMkeyS.r_shift |
+          mods->_KbMkeyU._KbMkeyS.l_shift;
+     }
+   if (mods->_KbMkeyU._KbMkeyS.l_ctrl !=
+       keyboard_mods._KbMkeyU._KbMkeyS.l_ctrl ||
+       mods->_KbMkeyU._KbMkeyS.r_ctrl !=
+       keyboard_mods._KbMkeyU._KbMkeyS.r_ctrl)
+     {
+        emit = EINA_TRUE;
+        ev->ctrl_changed = EINA_TRUE;
+        ev->ctrl = mods->_KbMkeyU._KbMkeyS.r_ctrl |
+          mods->_KbMkeyU._KbMkeyS.l_ctrl;
+     }
+   if (mods->_KbMkeyU._KbMkeyS.l_alt !=
+       keyboard_mods._KbMkeyU._KbMkeyS.l_alt ||
+       mods->_KbMkeyU._KbMkeyS.r_alt !=
+       keyboard_mods._KbMkeyU._KbMkeyS.r_alt)
+     {
+        emit = EINA_TRUE;
+        ev->alt_changed = EINA_TRUE;
+        ev->alt = mods->_KbMkeyU._KbMkeyS.r_alt |
+          mods->_KbMkeyU._KbMkeyS.l_alt;
+     }
+   if (mods->_KbMkeyU._KbMkeyS.l_win !=
+       keyboard_mods._KbMkeyU._KbMkeyS.l_win ||
+       mods->_KbMkeyU._KbMkeyS.r_win !=
+       keyboard_mods._KbMkeyU._KbMkeyS.r_win)
+     {
+        emit = EINA_TRUE;
+        ev->win_changed = EINA_TRUE;
+        ev->win = mods->_KbMkeyU._KbMkeyS.r_win |
+          mods->_KbMkeyU._KbMkeyS.l_win;
+     }
+   keyboard_mods = *mods;
+
+   if (leds->_KbLedU._KbLedS.num_lock !=
+       keyboard_leds._KbLedU._KbLedS.num_lock)
+     {
+        emit = EINA_TRUE;
+        ev->num_lock_changed = EINA_TRUE;
+        ev->num_lock = leds->_KbLedU._KbLedS.num_lock;
+     }
+   if (leds->_KbLedU._KbLedS.caps_lock !=
+       keyboard_leds._KbLedU._KbLedS.caps_lock)
+     {
+        emit = EINA_TRUE;
+        ev->caps_lock_changed = EINA_TRUE;
+        ev->caps_lock = leds->_KbLedU._KbLedS.caps_lock;
+     }
+   if (leds->_KbLedU._KbLedS.scroll_lock !=
+       keyboard_leds._KbLedU._KbLedS.scroll_lock)
+     {
+        emit = EINA_TRUE;
+        ev->scroll_lock_changed = EINA_TRUE;
+        ev->scroll_lock = leds->_KbLedU._KbLedS.scroll_lock;
+     }
+   keyboard_leds = *leds;
+
+   if (emit)
+     {
+        ev->timestamp = _ecore_psl1ght_get_time ();
+        ev->modifiers = _ecore_psl1ght_get_modifiers();
+        ecore_event_add(ECORE_PSL1GHT_EVENT_KEY_MODIFIERS, ev, NULL, NULL);
+     }
+   else
+     {
+        free(ev);
+     }
+}
+
+static void
+unicodeToUtf8(u16 w, char *utf8buf)
+{
+   unsigned char *utf8s = (unsigned char *)utf8buf;
+
+   if ( w < 0x0080 )
+     {
+        utf8s[0] = ( unsigned char )w;
+        utf8s[1] = 0;
+     }
+   else if ( w < 0x0800 )
+     {
+        utf8s[0] = 0xc0 | ((w) >> 6);
+        utf8s[1] = 0x80 | ((w) & 0x3f);
+        utf8s[2] = 0;
+     }
+   else {
+        utf8s[0] = 0xe0 | ((w) >> 12);
+        utf8s[1] = 0x80 | (((w) >> 6) & 0x3f);
+        utf8s[2] = 0x80 | ((w) & 0x3f);
+        utf8s[3] = 0;
+     }
+}
+
+static Ecore_Event_Key *
+_ecore_psl1ght_event_key(u16 key)
+{
+   Ecore_Event_Key *ev;
+   char utf8[4];
+   u16 utf16;
+   unsigned int i;
+
+   ev = malloc(sizeof(Ecore_Event_Key));
+   if (!ev) return NULL;
+
+   ev->timestamp = _ecore_psl1ght_get_time ();
+   ev->window = 0;
+   ev->event_window = 0;
+   ev->modifiers = _ecore_psl1ght_get_modifiers();
+
+   printf ("Key is %X\n", key);
+   key &= ~KB_KEYPAD;
+   for (i = 0; i < sizeof(keystable) / sizeof(struct _ecore_psl1ght_keys_s); ++i)
+     if (keystable[i].code == key)
+       {
+          ev->keyname = keystable[i].name;
+          ev->key = keystable[i].name;
+          ev->string = keystable[i].compose;
+          ev->compose = keystable[i].compose;
+
+          printf ("Found key '%s' in the table\n", ev->keyname);
+          return ev;
+       }
+
+   utf16 = ioKbCnvRawCode (KB_MAPPING_101, keyboard_mods, keyboard_leds, key);
+   unicodeToUtf8(utf16, utf8);
+   printf ("Converting to utf16 : %X - utf8 : %s\n", utf16, utf8);
+   ev->keyname = ev->key = ev->string = ev->compose = strdup (utf8);
+
+   return ev;
+}
+
+static void
+_ecore_psl1ght_mouse_move(s32 x_axis, s32 y_axis)
+{
+   Ecore_Event_Mouse_Move *ev;
+
+   ev = malloc(sizeof(Ecore_Event_Mouse_Move));
+   if (!ev) return;
+
+   mouse_x += x_axis;
+   mouse_y += y_axis;
+   if (mouse_x < 0) mouse_x = 0;
+   if (mouse_y < 0) mouse_y = 0;
+   if (mouse_x > window_width) mouse_x = window_width;
+   if (mouse_y > window_height) mouse_y = window_height;
+
+   ev->window = 0;
+   ev->root_window = 0;
+   ev->event_window = 0;
+   ev->same_screen = 0;
+   ev->timestamp = _ecore_psl1ght_get_time ();
+   ev->modifiers = _ecore_psl1ght_get_modifiers ();
+   ev->x = ev->root.x = mouse_x;
+   ev->y = ev->root.x = mouse_y;
+
+   ev->multi.device = 0;
+   ev->multi.radius = ev->multi.radius_x = ev->multi.radius_y = 0;
+   ev->multi.pressure = ev->multi.angle = 0;
+   ev->multi.x = ev->multi.y = ev->multi.root.x = ev->multi.root.y = 0;
+
+   ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
+}
+
+static void
+_ecore_psl1ght_mouse_button(int button, int pressed)
+{
+   Ecore_Event_Mouse_Button *ev;
+   static unsigned int previous_timestamp = 0;
+
+   ev = malloc(sizeof(Ecore_Event_Mouse_Button));
+   if (!ev) return;
+
+   ev->window = 0;
+   ev->root_window = 0;
+   ev->event_window = 0;
+   ev->same_screen = 0;
+   ev->timestamp = _ecore_psl1ght_get_time ();
+   ev->modifiers = _ecore_psl1ght_get_modifiers ();
+   ev->buttons = button;
+   if (ev->timestamp - previous_timestamp <= 500)
+     ev->double_click = 1;
+   ev->triple_click = 0;
+   previous_timestamp = ev->timestamp;
+
+   ev->x = ev->root.x = mouse_x;
+   ev->y = ev->root.y = mouse_y;
+   ev->multi.device = 0;
+   ev->multi.radius = ev->multi.radius_x = ev->multi.radius_y = 0;
+   ev->multi.pressure = ev->multi.angle = 0;
+   ev->multi.x = ev->multi.y = ev->multi.root.x = ev->multi.root.y = 0;
+
+   if (pressed)
+     ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
+   else
+     ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
+}
+
+static void
+_ecore_psl1ght_mouse_wheel(s8 wheel, s8 tilt)
+{
+   Ecore_Event_Mouse_Wheel *ev;
+
+   ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
+   if (!ev) return;
+
+   ev->timestamp = _ecore_psl1ght_get_time ();
+   ev->window = 0;
+   ev->event_window = 0;
+   ev->modifiers = _ecore_psl1ght_get_modifiers ();
+   ev->direction = 0;
+   ev->z = wheel;
+
+   ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
+}
+
+#define PAD_STICK_DEADZONE 0x20
+
+static void
+_ecore_psl1ght_poll_joypad(void)
+{
+   padInfo padinfo;
+   int i;
+
+   /**/
+   /* Check mouse events */
+   ioPadGetInfo (&padinfo);
+
+   for (i = 0; i < 4; i++) /* Ignore the move */
+     {
+        if (padinfo.status[i])
+          {
+             int analog_h, analog_v;
+
+             if (ioPadGetData (i, &pad_data) != 0)
+               continue;
+             analog_h = pad_data.ANA_L_H - 0x80;
+             analog_v = pad_data.ANA_L_V - 0x80;
+
+             if (analog_h > PAD_STICK_DEADZONE)
+               analog_h -= PAD_STICK_DEADZONE;
+             else if (analog_h < -PAD_STICK_DEADZONE)
+               analog_h += PAD_STICK_DEADZONE;
+             else
+               analog_h = 0;
+             analog_h /= 10;
+
+             if (analog_v > PAD_STICK_DEADZONE)
+               analog_v -= PAD_STICK_DEADZONE;
+             else if (analog_v < -PAD_STICK_DEADZONE)
+               analog_v += PAD_STICK_DEADZONE;
+             else
+               analog_v = 0;
+             analog_v /= 10;
+
+             if (analog_h != 0 || analog_v != 0)
+               _ecore_psl1ght_mouse_move (analog_h, analog_v);
+
+             if (pad_old_x != pad_data.BTN_CROSS)
+               _ecore_psl1ght_mouse_button (1, pad_data.BTN_CROSS);
+             if (pad_old_o != pad_data.BTN_CIRCLE)
+               _ecore_psl1ght_mouse_button (3, pad_data.BTN_CIRCLE);
+
+             pad_old_x = pad_data.BTN_CROSS;
+             pad_old_o = pad_data.BTN_CIRCLE;
+
+             //pad_buttons = paddata.buttons;
+          }
+     }
+}
+
+static void
+_ecore_psl1ght_poll_mouse(void)
+{
+   mouseInfo mouseinfo;
+   u32 i;
+
+   /**/
+   /* Check mouse events */
+   ioMouseGetInfo(&mouseinfo);
+
+   if (mouseinfo.status[0] == 1 && !mouse_connected) // Connected
+     {
+        mouse_connected = TRUE;
+        mouse_buttons = 0;
+
+        // Old events in the queue are discarded
+        ioMouseClearBuf(0);
+     }
+   else if (mouseinfo.status[0] != 1 && mouse_connected) // Disconnected
+     {
+        mouse_connected = FALSE;
+        mouse_buttons = 0;
+     }
+
+   if (mouse_connected)
+     {
+        mouseDataList datalist;
+
+        ioMouseGetDataList(0, &datalist);
+
+        for (i = 0; i < datalist.count; i++)
+          {
+             u8 old_left = mouse_buttons & 1;
+             u8 new_left = datalist.list[i].buttons & 1;
+             u8 old_right = mouse_buttons & 2;
+             u8 new_right = datalist.list[i].buttons & 2;
+             u8 old_middle = mouse_buttons & 4;
+             u8 new_middle = datalist.list[i].buttons & 4;
+
+             if (datalist.list[i].x_axis != 0 ||
+                 datalist.list[i].y_axis != 0)
+               _ecore_psl1ght_mouse_move (datalist.list[i].x_axis,
+                                          datalist.list[i].y_axis);
+
+             if (old_left != new_left)
+               _ecore_psl1ght_mouse_button (1, new_left);
+             if (old_middle != new_middle)
+               _ecore_psl1ght_mouse_button (2, new_middle);
+             if (old_right != new_right)
+               _ecore_psl1ght_mouse_button (3, new_right);
+
+             if (datalist.list[i].wheel != 0)
+               _ecore_psl1ght_mouse_wheel (datalist.list[i].wheel,
+                                           datalist.list[i].tilt);
+
+             mouse_buttons = datalist.list[i].buttons;
+          }
+     }
+}
+
+static void
+_ecore_psl1ght_poll_move(void)
+{
+   int i;
+   u16 new_buttons;
+   static int t_pressed = 0;
+   static int calibrated = 0;
+   static float prev_x = 0;
+   static float prev_y = 0;
+   static int gyro = 0;
+   float x, y, z;
+
+   /* Check move events */
+   processMove (move_context);
+   new_buttons = move_context->state.paddata.buttons & (~move_buttons);
+   move_buttons = move_context->state.paddata.buttons;
+
+   moveGet3DPosition (move_context, &x, &y, &z);
+   //printf ("Move 3D position is : %f, %f, %f\n", x,y,z);
+
+   switch (new_buttons) {
+      case 1:
+        gyro = !gyro;
+        break;
+
+      case 4:
+        // Move button
+        printf ("Calibrating\n");
+        gemCalibrate (0);
+        calibrated = 1;
+        break;
+
+      case 8:
+        // start button
+        _ecore_psl1ght_mouse_move ((window_width / 2) - mouse_x, (window_height / 2) - mouse_y);
+        break;
+     }
+
+   if (calibrated)
+     {
+        float x_axis, y_axis;
+
+        if (gyro)
+          {
+             gemInertialState gem_inert;
+
+             gemGetInertialState (0, 0, 0, &gem_inert);
+             x_axis = -vec_array (gem_inert.gyro, 1) * 25;
+             y_axis = -vec_array (gem_inert.gyro, 0) * 25;
+             if (abs (x_axis) > 2 || abs (y_axis) > 2)
+               _ecore_psl1ght_mouse_move (x_axis, y_axis);
+          }
+        else {
+             x_axis = (x - prev_x) * 2.5;
+             y_axis = -(y - prev_y) * 2.5;
+             prev_x = x;
+             prev_y = y;
+             _ecore_psl1ght_mouse_move (x_axis, y_axis);
+          }
+
+        if (!t_pressed && (move_buttons & 0x2))
+          _ecore_psl1ght_mouse_button (1, 1);
+        else if (t_pressed && (move_buttons & 0x2) == 0)
+          _ecore_psl1ght_mouse_button (1, 0);
+        t_pressed = move_buttons & 0x2;
+     }
+}
+
+static void
+_ecore_psl1ght_poll_keyboard(void)
+{
+   KbInfo kbInfo;
+   int i;
+
+   /* Check keyboard events */
+   ioKbGetInfo(&kbInfo);
+
+   if (kbInfo.status[0] == 1 && !keyboard_connected)
+     {
+        /* Connected */
+         keyboard_connected = true;
+
+         // Old events in the queue are discarded
+         ioKbClearBuf(0);
+         keyboard_leds._KbLedU.leds = 0;
+         keyboard_mods._KbMkeyU.mkeys = 0;
+         keyboard_old_key = 0;
+
+         // Set raw keyboard code types to get scan codes
+         ioKbSetCodeType(0, KB_CODETYPE_RAW);
+         ioKbSetReadMode(0, KB_RMODE_INPUTCHAR);
+     }
+   else if (kbInfo.status[0] != 1 && keyboard_connected)
+     {
+        /* Disconnected keyboard */
+         keyboard_connected = FALSE;
+     }
+
+   if (keyboard_connected)
+     {
+        KbData Keys;
+
+        // Read data from the keyboard buffer
+        if (ioKbRead(0, &Keys) == 0 && Keys.nb_keycode > 0)
+          {
+             Ecore_Event_Key *ev = NULL;
+
+             _ecore_psl1ght_key_modifiers (&Keys.mkey, &Keys.led);
+
+             if (Keys.nb_keycode == 0 && keyboard_old_key != 0)
+               {
+                  ev = _ecore_psl1ght_event_key (keyboard_old_key);
+                  if (ev) ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
+               }
+             for (i = 0; i < Keys.nb_keycode; i++)
+               {
+                  if (Keys.keycode[i] != keyboard_old_key)
+                    {
+                       if (Keys.keycode[i] != 0)
+                         {
+                            ev = _ecore_psl1ght_event_key (Keys.keycode[i]);
+                            if (ev)
+                              ecore_event_add(ECORE_EVENT_KEY_DOWN, ev,
+                                              NULL, NULL);
+                         }
+                       else
+                         {
+                            ev = _ecore_psl1ght_event_key (keyboard_old_key);
+                            if (ev)
+                              ecore_event_add(ECORE_EVENT_KEY_UP, ev,
+                                              NULL, NULL);
+                         }
+                       keyboard_old_key = Keys.keycode[0];
+                    }
+               }
+          }
+     }
+}
+
+static void
+xmb_event_handler(u64 status, u64 param, void *user_data)
+{
+   printf ("Received event %lX\n", status);
+   if (status == SYSUTIL_EXIT_GAME)
+     {
+        ecore_main_loop_quit();
+     }
+   else if (status == SYSUTIL_MENU_OPEN)
+     {
+     }
+   else if (status == SYSUTIL_MENU_CLOSE)
+     {
+     }
+   else if (status == SYSUTIL_DRAW_BEGIN)
+     {
+     }
+   else if (status == SYSUTIL_DRAW_END)
+     {
+     }
+}
+
+EAPI void
+ecore_psl1ght_poll_events(void)
+{
+   _ecore_psl1ght_poll_joypad ();
+   _ecore_psl1ght_poll_mouse ();
+   if (move_context)
+     _ecore_psl1ght_poll_move ();
+   _ecore_psl1ght_poll_keyboard ();
+
+   sysUtilCheckCallback ();
+}
+
+EAPI void
+ecore_psl1ght_resolution_set(int width, int height)
+{
+   window_width = width;
+   window_height = height;
+   if (mouse_x > window_width) mouse_x = window_width;
+   if (mouse_y > window_height) mouse_y = window_height;
+}
+
+EAPI void
+ecore_psl1ght_screen_resolution_get(int *w, int *h)
+{
+   videoState state;
+   videoResolution resolution;
+
+   /* Get the state of the display */
+   if (videoGetState (0, 0, &state) == 0 &&
+       videoGetResolution (state.displayMode.resolution, &resolution) == 0)
+     {
+        if (w) *w = resolution.width;
+        if (h) *h = resolution.height;
+     }
+   else {
+        if (w) *w = 0;
+        if (h) *h = 0;
+     }
+}
+
+EAPI void
+ecore_psl1ght_optimal_screen_resolution_get(int *w, int *h)
+{
+   videoDeviceInfo info;
+   videoResolution res;
+   int area = 720 * 480;
+   int mode_area;
+   int i;
+
+   if (w) *w = 720;
+   if (h) *h = 480;
+
+   videoGetDeviceInfo(0, 0, &info);
+
+   for (i = 0; i < info.availableModeCount; i++) {
+        videoGetResolution (info.availableModes[i].resolution, &res);
+        mode_area = res.width * res.height;
+        if (mode_area > area)
+          {
+             area = mode_area;
+             if (w) *w = res.width;
+             if (h) *h = res.height;
+          }
+     }
+}
+
diff --git a/src/lib/ecore_psl1ght/ecore_psl1ght_private.h b/src/lib/ecore_psl1ght/ecore_psl1ght_private.h
new file mode 100644 (file)
index 0000000..bd5a86e
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef _ECORE_PSL1GHT_PRIVATE_H
+# define _ECORE_PSL1GHT_PRIVATE_H
+
+extern int _ecore_psl1ght_log_dom;
+
+# ifdef ECORE_PSL1GHT_DEFAULT_LOG_COLOR
+#  undef ECORE_PSL1GHT_DEFAULT_LOG_COLOR
+# endif
+# define ECORE_PSL1GHT_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
+
+# ifdef ERR
+#  undef ERR
+# endif
+# define ERR(...) EINA_LOG_DOM_ERR(_ecore_psl1ght_log_dom, __VA_ARGS__)
+
+# ifdef DBG
+#  undef DBG
+# endif
+# define DBG(...) EINA_LOG_DOM_DBG(_ecore_psl1ght_log_dom, __VA_ARGS__)
+
+# ifdef INF
+#  undef INF
+# endif
+# define INF(...) EINA_LOG_DOM_INFO(_ecore_psl1ght_log_dom, __VA_ARGS__)
+
+# ifdef WRN
+#  undef WRN
+# endif
+# define WRN(...) EINA_LOG_DOM_WARN(_ecore_psl1ght_log_dom, __VA_ARGS__)
+
+# ifdef CRIT
+#  undef CRIT
+# endif
+# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_psl1ght_log_dom, __VA_ARGS__)
+
+#endif
diff --git a/src/lib/ecore_psl1ght/gemutil.c b/src/lib/ecore_psl1ght/gemutil.c
new file mode 100644 (file)
index 0000000..9ccfc1c
--- /dev/null
@@ -0,0 +1,281 @@
+#include <stdio.h>
+#include <io/move.h>
+#include <sys/memory.h>
+#include <ppu-types.h>
+#include <io/camera.h>
+#include <ppu-types.h>
+#include <spurs/spurs.h>
+#include <sys/spu.h>
+#include <sys/thread.h>
+#include <sys/systime.h>
+
+#define SPURS_DEFAULT_PREFIX_NAME "gem_spurs"
+
+u16 oldGemPad = 0;
+u16 newGemPad = 0;
+u16 newGemAnalogT = 0;
+extern cameraReadInfo camread;
+
+static inline float
+vec_array(vec_float4 vec, unsigned int idx)
+{
+   union {
+      vec_float4 vec;
+      float      array[4];
+   } v;
+
+   v.vec = vec;
+
+   if (idx > 3)
+     return -1;
+   return v.array[idx];
+}
+
+int
+initMove()
+{
+   Spurs *spurs;
+   gemAttribute gem_attr;
+   u8 gem_spu_priorities[8] = { 1, 0, 0, 0, 0, 0, 0, 0 };
+   int ret;
+   int i;
+
+   spurs = initSpurs (NULL);
+
+   if (spurs == NULL)
+     goto error;
+
+   printf ("preparing GemAttribute structure with spurs\n");
+
+   initAttributeGem (&gem_attr, 1, NULL, spurs, gem_spu_priorities);
+   gem_attr->version = 2;
+   gem_attr->max = 1;
+   gem_attr->spurs = spurs;
+   gem_attr->memory = NULL;
+   gem_attr->spu_priorities[0] = 1;
+   for (i = 1; i < 8; ++i)
+     gem_attr->spu_priorities[i] = 0;
+
+   printf ("calling GemInit with GemAttribute structure version=%d max_connect=%d spurs=%X\n",
+           gem_attr.version, gem_attr.max, gem_attr.spurs);
+   ret = gemInit (&gem_attr);
+   printf ("return from GemInit %X \n", ret);
+   if (ret)
+     goto error;
+
+   ret = gemPrepareCamera (128, 0.5);
+   printf ("GemPrepareCamera return %d exposure set to 128 and quality to 0.5\n",
+           ret);
+   if (ret)
+     goto error;
+   ret = gemReset (0);
+   printf ("GemReset return %X \n", ret);
+   if (ret)
+     goto error;
+   return ret;
+
+error:
+   if (spurs)
+     endSpurs (spurs);
+   return NULL;
+}
+
+int
+endMove()
+{
+   endSpurs (spurs);
+   gemEnd ();
+   return 0;
+}
+
+int
+proccessGem(int t)
+{
+   int ret;
+
+   switch (t) {
+      case 0:
+
+        ret = gemUpdateStart (camread.buffer, camread.timestamp);
+
+        if (ret != 0)
+          {
+             printf ("Return from gemUpdateStart %X\n", ret);
+          }
+        break;
+
+      case 2:
+
+        ret = gemUpdateFinish ();
+        if (ret != 0)
+          {
+             printf ("Return from gemUpdateFinish %X\n", ret);
+          }
+        break;
+
+      case 3:
+        ret = gemConvertVideoFinish ();
+        if (ret != 0)
+          {
+             printf ("Return from gemConvertVideoFinish %X\n", ret);
+          }
+        break;
+
+      default:
+        ret = -1;
+        break;
+     }
+   return ret;
+}
+
+void
+readGemPad(int num_gem)
+{
+   gemState gem_state;
+   int ret;
+   unsigned int hues[] = { 4 << 24, 4 << 24, 4 << 24, 4 << 24 };
+   ret = gemGetState (0, 0, -22000, &gem_state);
+
+   newGemPad = gem_state.paddata.buttons & (~oldGemPad);
+   newGemAnalogT = gem_state.paddata.ANA_T;
+   oldGemPad = gem_state.paddata.buttons;
+
+   switch (ret) {
+      case 2:
+        gemForceRGB (num_gem, 0.5, 0.5, 0.5);
+        break;
+
+      case 5:
+
+        gemTrackHues (hues, NULL);
+        break;
+
+      default:
+        break;
+     }
+}
+
+void
+readGemAccPosition(int num_gem)
+{
+   vec_float4 position;
+
+   gemGetAccelerometerPositionInDevice (num_gem, &position);
+
+   printf (" accelerometer device coordinates [%f,%f,%f,%f]\n",
+           vec_array (position, 0), vec_array (position, 1), vec_array (position, 2),
+           vec_array (position, 3));
+}
+
+void
+readGemInertial(int num_gem)
+{
+   gemInertialState gem_inertial_state;
+   int ret;
+
+   ret = gemGetInertialState (num_gem, 0, -22000, &gem_inertial_state);
+   printf ("gemGetInertialState return %X\n", ret);
+   printf ("counter %d temperature %f\n", gem_inertial_state.counter,
+           gem_inertial_state.temperature);
+
+   printf (" accelerometer sensor   [%f,%f,%f,%f]\n",
+           vec_array (gem_inertial_state.accelerometer, 0),
+           vec_array (gem_inertial_state.accelerometer, 1),
+           vec_array (gem_inertial_state.accelerometer, 2),
+           vec_array (gem_inertial_state.accelerometer, 3));
+
+   printf (" accelerometer_bias sensor   [%f,%f,%f,%f]\n",
+           vec_array (gem_inertial_state.accelerometer_bias, 0),
+           vec_array (gem_inertial_state.accelerometer_bias, 1),
+           vec_array (gem_inertial_state.accelerometer_bias, 2),
+           vec_array (gem_inertial_state.accelerometer_bias, 3));
+
+   printf (" gyro sensor  [%f,%f,%f,%f]\n", vec_array (gem_inertial_state.gyro,
+                                                       0), vec_array (gem_inertial_state.gyro, 1),
+           vec_array (gem_inertial_state.gyro, 2),
+           vec_array (gem_inertial_state.gyro, 3));
+
+   printf (" gyro_bias sensor  [%f,%f,%f,%f]\n",
+           vec_array (gem_inertial_state.gyro_bias, 0),
+           vec_array (gem_inertial_state.gyro_bias, 1),
+           vec_array (gem_inertial_state.gyro_bias, 2),
+           vec_array (gem_inertial_state.gyro_bias, 3));
+}
+
+void
+readGem()
+{
+   gemState gem_state;
+   proccessGem (0);
+
+   proccessGem (2);
+
+   readGemPad (0); // This will read buttons from Move
+   switch (newGemPad) {
+      case 1:
+        printf ("Select pressed \n");
+        break;
+
+      case 2:
+        printf ("T pressed value %d\n", newGemAnalogT);
+        printf
+          ("Frame %d center of the sphere in world coordinates %f %f %f %f \n",
+          camread.frame, vec_array (gem_state.pos, 0), vec_array (gem_state.pos,
+                                                                  1), vec_array (gem_state.pos, 2), vec_array (gem_state.pos, 3));
+        break;
+
+      case 4:
+        printf ("Move pressed \n");
+        gemCalibrate (0);
+        break;
+
+      case 8:
+        printf ("Start pressed \n");
+        pos_x = 0;
+        pos_y = 0;
+        break;
+
+      case 16:
+        printf ("Triangle pressed \n");
+        getImageState ();
+        break;
+
+      case 32:
+        printf ("Circle pressed \n");
+        break;
+
+      case 64:
+        printf ("Cross pressed \n");
+        printf ("X,Y,Z position (mm) %f %f %f\n", vec_array (gem_state.pos, 0),
+                vec_array (gem_state.pos, 1), vec_array (gem_state.pos, 2));
+        readGemAccPosition (0);
+        break;
+
+      case 128:
+        printf ("Square pressed \n");
+        readGemInertial (0);
+        break;
+
+      default:
+        break;
+     }
+}
+
+void
+getImageState()
+{
+   int ret;
+
+   gemImageState imgState;
+
+   gemGetImageState (0, &imgState);
+   printf (" u  [%f]\n", imgState.u);
+   printf (" v  [%f]\n", imgState.v);
+   printf (" r  [%f]\n", imgState.r);
+   printf (" projectionx  [%f]\n", imgState.projectionx);
+   printf (" projectiony  [%f]\n", imgState.projectiony);
+   printf (" distance  [%f]\n", imgState.distance);
+   printf ("visible=%d r_valid=%d\n", imgState.visible, imgState.r_valid);
+   printf ("tiemestamp=%Ld\n", imgState.frame_time);
+}
+
diff --git a/src/lib/ecore_psl1ght/gemutil.h b/src/lib/ecore_psl1ght/gemutil.h
new file mode 100644 (file)
index 0000000..ce4b544
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) Antonio José Ramos Márquez (bigboss)
+ * Copyright (C) Youness Alaoui (KaKaRoTo)
+ */
+
+#ifndef __GEMUTIL_H__
+#define __GEMUTIL_H__
+
+#include <ppu-types.h>
+#include <spurs/spurs.h>
+#include <io/camera.h>
+#include <io/move.h>
+
+typedef struct
+{
+   Spurs *spurs;
+} moveContext;
+
+#endif /* __GEMUTIL_H__ */
diff --git a/src/lib/ecore_psl1ght/moveutil.c b/src/lib/ecore_psl1ght/moveutil.c
new file mode 100644 (file)
index 0000000..1dadfbc
--- /dev/null
@@ -0,0 +1,245 @@
+#include <stdio.h>
+#include <io/move.h>
+#include <sys/memory.h>
+#include <ppu-types.h>
+#include <io/camera.h>
+#include <ppu-types.h>
+#include <spurs/spurs.h>
+#include <sys/thread.h>
+#include <sys/systime.h>
+
+#include "spursutil.h"
+#include "moveutil.h"
+
+u16 oldGemPad = 0;
+u16 newGemPad = 0;
+u16 newGemAnalogT = 0;
+
+static void
+endCamera(moveContext *context)
+{
+   cameraStop (0);
+
+   cameraClose (0);
+   cameraEnd ();
+
+   sysMemContainerDestroy (context->camInfo.container);
+}
+
+static int
+initCamera(moveContext *context)
+{
+   int ret;
+
+   context->camInfo.container = NULL;
+
+   ret = cameraInit ();
+   printf ("cameraInit() returned %d\n", ret);
+   if (ret == 0)
+     {
+        cameraType type = CAM_TYPE_UNKNOWN;
+
+        ret = cameraGetType (0, &type);
+        if (ret == 0 && type == CAM_TYPE_PLAYSTATION_EYE)
+          {
+             context->camInfo.format = CAM_FORM_RAW8;
+             context->camInfo.framerate = 60;
+             context->camInfo.resolution = CAM_RESO_VGA;
+             context->camInfo.info_ver = 0x0101;
+             ret = sysMemContainerCreate (&context->camInfo.container, 0x200000);
+             printf ("sysMemContainerCreate() for camera container returned %d\n", ret);
+
+             ret = cameraOpenEx (0, &context->camInfo);
+             switch (ret) {
+                case 0:
+                  printf ("Found me an eye, arrr!\n");
+                  printf ("cameraOpenEx returned %08X\n", ret);
+                  printf ("Video dimensions: %dx%d\n", context->camInfo.width, context->camInfo.height);
+                  printf ("Buffer at %08X\n", context->camInfo.buffer);
+                  printf ("pbuf0 Buffer at %08X\n", context->camInfo.pbuf[0]);
+                  printf ("pbuf0 Buffer at %08X\n", context->camInfo.pbuf[1]);
+                  printf ("context->camInfo.info_ver %X\n", context->camInfo.info_ver);
+
+                  context->camRead.buffer = context->camInfo.buffer;
+                  context->camRead.version = 0x0100;
+                  printf ("Setting CameraReadEx %08X buffer to cameraInfoex buffer \n",
+                          context->camRead.buffer);
+                  break;
+
+                default:
+                  printf ("Error %X detected opening PlayStation Eye\n", ret);
+                  goto error;
+               }
+          }
+        else {
+             printf ("Device detected is not a PlayStation Eye and this sample need it\n");
+             goto error;
+          }
+     }
+   else {
+        goto error;
+     }
+   return ret;
+
+error:
+   if (context->camInfo.container)
+     sysMemContainerDestroy (context->camInfo.container);
+   return ret;
+}
+
+static int
+readCamera(moveContext *context)
+{
+   int ret;
+
+   ret = cameraReadEx (0, &context->camRead);
+   switch (ret) {
+      case CAMERA_ERRO_NEED_START:
+        cameraReset (0);
+        ret = gemPrepareCamera (128, 0.5);
+        printf ("GemPrepareCamera return %d exposure set to 128 and quality to 0.5 before cameraStart\n",
+                ret);
+        printf ("lets go!! It's time to look your face in Sony Bravia :P\n");
+        ret = cameraStart (0);
+        printf ("cameraStart return %d \n", ret);
+        printf ("*******************************************\n");
+        printf ("* Now make sure you have a Move connected\n");
+        printf ("* and point it towards the camera and press\n");
+        printf ("* the action button to calibrate\n");
+        printf ("*******************************************\n");
+        break;
+
+      case 0:
+        break;
+
+      default:
+        printf ("error %08X ", ret);
+        ret = 1;
+        break;
+     }
+   // printf("despues de start return %d \n",ret);
+   if (ret == 0 && context->camRead.readcount != 0)
+     {
+        return context->camRead.readcount;
+     }
+   else {
+        return 0;
+     }
+}
+
+moveContext *
+initMove()
+{
+   moveContext *context = NULL;
+   Spurs *spurs;
+   gemAttribute gem_attr;
+   int ret;
+   int i;
+
+   spurs = initSpurs ("gem_spurs");
+
+   if (spurs == NULL)
+     goto error;
+
+   printf ("preparing GemAttribute structure with spurs\n");
+
+   gem_attr.version = 2;
+   gem_attr.max = 1;
+   gem_attr.spurs = spurs;
+   gem_attr.memory = NULL;
+   gem_attr.spu_priorities[0] = 1;
+   for (i = 1; i < 8; ++i)
+     gem_attr.spu_priorities[i] = 0;
+
+   printf ("calling GemInit with GemAttribute structure version=%d max_connect=%d spurs=%X\n",
+           gem_attr.version, gem_attr.max, gem_attr.spurs);
+   ret = gemInit (&gem_attr);
+   printf ("return from GemInit %X \n", ret);
+   if (ret)
+     goto error;
+
+   ret = gemPrepareCamera (128, 0.5);
+   printf ("GemPrepareCamera return %d exposure set to 128 and quality to 0.5\n",
+           ret);
+   if (ret)
+     goto error;
+   ret = gemReset (0);
+   printf ("GemReset return %X \n", ret);
+   if (ret)
+     goto error;
+
+   context = (moveContext *)malloc (sizeof (moveContext));
+   context->spurs = spurs;
+   ret = initCamera (context);
+
+   if (ret == 0)
+     return context;
+
+error:
+   if (spurs)
+     endSpurs (spurs);
+   if (context)
+     free (context);
+   return NULL;
+}
+
+void
+endMove(moveContext *context)
+{
+   /* Stop Move */
+    gemEnd ();
+    /* Stop Camera */
+    endCamera (context);
+    /* Stop Spurs */
+    endSpurs (context->spurs);
+
+    free (context);
+}
+
+int
+processMove(moveContext *context)
+{
+   const unsigned int hues[] = { 4 << 24, 4 << 24, 4 << 24, 4 << 24 };
+   int ret = -1;
+
+   if (readCamera (context) > 0)
+     {
+        ret = gemUpdateStart (context->camRead.buffer, context->camRead.timestamp);
+        //printf ("Return from gemUpdateStart %X\n", ret);
+        if (ret == 0)
+          {
+             ret = gemUpdateFinish ();
+             //printf ("Return from gemUpdateFinish %X\n", ret);
+             if (ret == 0)
+               {
+                  ret = gemGetState (0, STATE_LATEST_IMAGE_TIME, 0, &context->state);
+                  switch (ret) {
+                     case 2:
+                       gemForceRGB (0, 0.5, 0.5, 0.5);
+                       break;
+
+                     case 5:
+                       gemTrackHues (hues, NULL);
+                       break;
+
+                     default:
+                       break;
+                    }
+               }
+          }
+     }
+
+   return ret;
+}
+
+void
+moveGet3DPosition(moveContext *context, float *x, float *y, float *z)
+{
+   if (x)
+     *x = vec_array (context->state.pos, 0);
+   if (y)
+     *y = vec_array (context->state.pos, 1);
+   if (z)
+     *z = vec_array (context->state.pos, 2);
+}
+
diff --git a/src/lib/ecore_psl1ght/moveutil.h b/src/lib/ecore_psl1ght/moveutil.h
new file mode 100644 (file)
index 0000000..bb4b22c
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) Antonio José Ramos Márquez (bigboss)
+ * Copyright (C) Youness Alaoui (KaKaRoTo)
+ */
+
+#ifndef __MOVEUTIL_H__
+#define __MOVEUTIL_H__
+
+#include <ppu-types.h>
+#include <spurs/spurs.h>
+#include <io/camera.h>
+#include <io/move.h>
+
+typedef struct
+{
+   Spurs         *spurs;
+   cameraInfoEx   camInfo;
+   cameraReadInfo camRead;
+   gemState       state;
+} moveContext;
+
+static inline float
+vec_array(vec_float4 vec, unsigned int idx)
+{
+   union {
+      vec_float4 vec;
+      float      array[4];
+   } v;
+
+   v.vec = vec;
+
+   if (idx > 3)
+     return -1;
+   return v.array[idx];
+}
+
+moveContext *initMove();
+void         endMove(moveContext *context);
+void         readGemState(moveContext *context);
+int          processMove(moveContext *context);
+void         moveGet3DPosition(moveContext *context, float *x, float *y, float *z);
+
+#endif /* __MOVEUTIL_H__ */
diff --git a/src/lib/ecore_psl1ght/spursutil.c b/src/lib/ecore_psl1ght/spursutil.c
new file mode 100644 (file)
index 0000000..27b5c1d
--- /dev/null
@@ -0,0 +1,62 @@
+#include "spursutil.h"
+#include <sys/spu.h>
+
+#define SPURS_DEFAULT_PREFIX_NAME "spursutil"
+
+Spurs *
+initSpurs(const char *prefix_name)
+{
+   Spurs *spurs = NULL;
+   SpursAttribute attributeSpurs;
+   int ret;
+   int i;
+
+   ret = sysSpuInitialize (6, 0);
+   printf ("sysSpuInitialize return %d\n", ret);
+
+   /* initialize spurs */
+   printf ("Initializing spurs\n");
+   spurs = (void *)memalign (SPURS_ALIGN, sizeof (Spurs));
+   printf ("Initializing spurs attribute\n");
+
+   ret = spursAttributeInitialize (&attributeSpurs, 5, 250, 1000, true);
+   if (ret)
+     {
+        printf ("error : spursAttributeInitialize failed  %x\n", ret);
+        goto error;
+     }
+
+   printf ("Setting name prefix\n");
+   if (!prefix_name)
+     prefix_name = SPURS_DEFAULT_PREFIX_NAME;
+   ret = spursAttributeSetNamePrefix (&attributeSpurs,
+                                      prefix_name, strlen (prefix_name));
+   if (ret)
+     {
+        printf ("error : spursAttributeInitialize failed %x\n", ret);
+        goto error;
+     }
+
+   printf ("Initializing with attribute\n");
+   ret = spursInitializeWithAttribute (spurs, &attributeSpurs);
+   if (ret)
+     {
+        printf ("error: spursInitializeWithAttribute failed  %x\n", ret);
+        goto error;
+     }
+
+   return spurs;
+
+error:
+   if (spurs)
+     free (spurs);
+   return NULL;
+}
+
+void
+endSpurs(Spurs *spurs)
+{
+   spursFinalize (spurs);
+   free (spurs);
+}
+
diff --git a/src/lib/ecore_psl1ght/spursutil.h b/src/lib/ecore_psl1ght/spursutil.h
new file mode 100644 (file)
index 0000000..0b35030
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) Antonio José Ramos Márquez (bigboss)
+ * Copyright (C) Youness Alaoui (KaKaRoTo)
+ */
+
+#ifndef __SPURSUTIL_H__
+#define __SPURSUTIL_H__
+
+#include <ppu-types.h>
+#include <spurs/spurs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Initialize spurs with a given name prefix (*/
+Spurs *initSpurs(const char *prefix_name);
+void   endSpurs(Spurs *spurs);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SPURSUTIL_H__ */
index 1b26534..dfbb62e 100644 (file)
@@ -385,6 +385,13 @@ typedef struct _Ecore_X_Event_Xdnd_Finished                Ecore_X_Event_Xdnd_Fi
 typedef struct _Ecore_X_Event_Client_Message               Ecore_X_Event_Client_Message;
 typedef struct _Ecore_X_Event_Window_Shape                 Ecore_X_Event_Window_Shape;
 typedef struct _Ecore_X_Event_Screensaver_Notify           Ecore_X_Event_Screensaver_Notify;
+typedef struct _Ecore_X_Event_Gesture_Notify_Flick         Ecore_X_Event_Gesture_Notify_Flick;
+typedef struct _Ecore_X_Event_Gesture_Notify_Pan           Ecore_X_Event_Gesture_Notify_Pan;
+typedef struct _Ecore_X_Event_Gesture_Notify_PinchRotation Ecore_X_Event_Gesture_Notify_PinchRotation;
+typedef struct _Ecore_X_Event_Gesture_Notify_Tap           Ecore_X_Event_Gesture_Notify_Tap;
+typedef struct _Ecore_X_Event_Gesture_Notify_TapNHold      Ecore_X_Event_Gesture_Notify_TapNHold;
+typedef struct _Ecore_X_Event_Gesture_Notify_Hold          Ecore_X_Event_Gesture_Notify_Hold;
+typedef struct _Ecore_X_Event_Gesture_Notify_Group         Ecore_X_Event_Gesture_Notify_Group;
 typedef struct _Ecore_X_Event_Sync_Counter                 Ecore_X_Event_Sync_Counter;
 typedef struct _Ecore_X_Event_Sync_Alarm                   Ecore_X_Event_Sync_Alarm;
 typedef struct _Ecore_X_Event_Screen_Change                Ecore_X_Event_Screen_Change;
@@ -978,6 +985,13 @@ EAPI extern int ECORE_X_EVENT_FIXES_SELECTION_NOTIFY;
 EAPI extern int ECORE_X_EVENT_CLIENT_MESSAGE;
 EAPI extern int ECORE_X_EVENT_WINDOW_SHAPE;
 EAPI extern int ECORE_X_EVENT_SCREENSAVER_NOTIFY;
+EAPI extern int ECORE_X_EVENT_GESTURE_NOTIFY_FLICK;
+EAPI extern int ECORE_X_EVENT_GESTURE_NOTIFY_PAN;
+EAPI extern int ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION;
+EAPI extern int ECORE_X_EVENT_GESTURE_NOTIFY_TAP;
+EAPI extern int ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD;
+EAPI extern int ECORE_X_EVENT_GESTURE_NOTIFY_HOLD;
+EAPI extern int ECORE_X_EVENT_GESTURE_NOTIFY_GROUP;
 EAPI extern int ECORE_X_EVENT_SYNC_COUNTER;
 EAPI extern int ECORE_X_EVENT_SYNC_ALARM;
 EAPI extern int ECORE_X_EVENT_SCREEN_CHANGE;
@@ -2088,6 +2102,9 @@ EAPI void
 ecore_x_netwm_desk_workareas_set(Ecore_X_Window root,
                                  unsigned int *areas,
                                  unsigned int n_desks);
+EAPI unsigned int *
+ecore_x_netwm_desk_workareas_get(Ecore_X_Window root,
+                                 unsigned int *n_desks);
 EAPI void
 ecore_x_netwm_desk_current_set(Ecore_X_Window root,
                                unsigned int desk);
@@ -3519,6 +3536,158 @@ ecore_x_input_multi_select(Ecore_X_Window win);
 EAPI Eina_Bool
 ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win);
 
+typedef enum _Ecore_X_Gesture_Event_Mask
+{
+   ECORE_X_GESTURE_EVENT_MASK_NONE = 0L,
+   ECORE_X_GESTURE_EVENT_MASK_FLICK = (1L << 0),
+   ECORE_X_GESTURE_EVENT_MASK_PAN = (1L << 1),
+   ECORE_X_GESTURE_EVENT_MASK_PINCHROTATION = (1L << 2),
+   ECORE_X_GESTURE_EVENT_MASK_TAP = (1L << 3),
+   ECORE_X_GESTURE_EVENT_MASK_TAPNHOLD = (1L << 4),
+   ECORE_X_GESTURE_EVENT_MASK_HOLD = (1L << 5),
+   ECORE_X_GESTURE_EVENT_MASK_GROUP = (1L << 6)
+} Ecore_X_Gesture_Event_Mask;
+
+typedef enum _Ecore_X_Gesture_Event_Type
+{
+   ECORE_X_GESTURE_EVENT_FLICK,
+   ECORE_X_GESTURE_EVENT_PAN,
+   ECORE_X_GESTURE_EVENT_PINCHROTATION,
+   ECORE_X_GESTURE_EVENT_TAP,
+   ECORE_X_GESTURE_EVENT_TAPNHOLD,
+   ECORE_X_GESTURE_EVENT_HOLD,
+   ECORE_X_GESTURE_EVENT_GROUP
+} Ecore_X_Gesture_Event_Type;
+
+typedef enum _Ecore_X_Gesture_Event_Subtype
+{
+   ECORE_X_GESTURE_END,
+   ECORE_X_GESTURE_BEGIN,
+   ECORE_X_GESTURE_UPDATE,
+   ECORE_X_GESTURE_DONE
+} Ecore_X_Gesture_Event_Subtype;
+
+typedef enum _Ecore_X_Gesture_Group_Subtype
+{
+   ECORE_X_GESTURE_GROUP_REMOVED,
+   ECORE_X_GESTURE_GROUP_ADDED,
+   ECORE_X_GESTURE_GROUP_CURRENT
+} Ecore_X_Gesture_Group_Subtype;
+
+typedef enum _Ecore_X_Gesture_Direction
+{
+   ECORE_X_GESTURE_NORTHWARD,
+   ECORE_X_GESTURE_NORTHEASTWARD,
+   ECORE_X_GESTURE_EASTWARD,
+   ECORE_X_GESTURE_SOUTHEASTWARD,
+   ECORE_X_GESTURE_SOUTHWARD,
+   ECORE_X_GESTURE_SOUTHWESTWARD,
+   ECORE_X_GESTURE_WESTWARD,
+   ECORE_X_GESTURE_NORTHWESTWARD
+} Ecore_X_Gesture_Direction;
+
+struct _Ecore_X_Event_Gesture_Notify_Flick
+{
+   Ecore_X_Window win;
+   Ecore_X_Time time;
+   Ecore_X_Gesture_Event_Subtype subtype;
+   int num_fingers;
+   int distance;
+   Ecore_X_Time duration;
+   Ecore_X_Gesture_Direction direction;
+   double angle;
+};
+   
+struct _Ecore_X_Event_Gesture_Notify_Pan
+{
+   Ecore_X_Window win;
+   Ecore_X_Time time;
+   Ecore_X_Gesture_Event_Subtype subtype;
+   int num_fingers;
+   int dx;
+   int dy;
+   int distance;
+   Ecore_X_Time duration;
+   Ecore_X_Gesture_Direction direction;
+};
+
+struct _Ecore_X_Event_Gesture_Notify_PinchRotation
+{
+   Ecore_X_Window win;
+   Ecore_X_Time time;
+   Ecore_X_Gesture_Event_Subtype subtype;
+   int num_fingers;
+   int distance;
+   int cx;
+   int cy;
+   double zoom;
+   double angle;
+};
+
+struct _Ecore_X_Event_Gesture_Notify_Tap
+{
+  Ecore_X_Window win;
+  Ecore_X_Time time;
+  Ecore_X_Gesture_Event_Subtype subtype;
+  int num_fingers;
+  int cx;
+  int cy;
+  int tap_repeat;
+  Ecore_X_Time interval;
+};
+
+struct _Ecore_X_Event_Gesture_Notify_TapNHold
+{
+  Ecore_X_Window win;
+  Ecore_X_Time time;
+  Ecore_X_Gesture_Event_Subtype subtype;
+  int num_fingers;
+  int cx;
+  int cy;
+  Ecore_X_Time interval;
+  Ecore_X_Time hold_time;
+};
+
+struct _Ecore_X_Event_Gesture_Notify_Hold
+{
+  Ecore_X_Window win;
+  Ecore_X_Time time;
+  Ecore_X_Gesture_Event_Subtype subtype;
+  int num_fingers;
+  int cx;
+  int cy;
+  Ecore_X_Time hold_time;
+};
+
+struct _Ecore_X_Event_Gesture_Notify_Group
+{
+   Ecore_X_Window win;
+   Ecore_X_Time time;
+   Ecore_X_Gesture_Group_Subtype subtype;
+   int num_groups;
+   int group_id;
+};
+
+EAPI Eina_Bool
+ecore_x_gesture_supported(void);
+
+EAPI Eina_Bool
+ecore_x_gesture_events_select(Ecore_X_Window win,
+                              Ecore_X_Gesture_Event_Mask mask);
+
+EAPI Ecore_X_Gesture_Event_Mask
+ecore_x_gesture_events_selected_get(Ecore_X_Window win);
+
+EAPI Eina_Bool
+ecore_x_gesture_event_grab(Ecore_X_Window win,
+                           Ecore_X_Gesture_Event_Type type,
+                           int num_fingers);
+
+EAPI Eina_Bool
+ecore_x_gesture_event_ungrab(Ecore_X_Window win,
+                             Ecore_X_Gesture_Event_Type type,
+                             int num_fingers);
+
 #ifdef __cplusplus
 }
 #endif // ifdef __cplusplus
index e9fb711..366ebfd 100644 (file)
@@ -17,6 +17,7 @@ AM_CPPFLAGS = \
   @XCB_XPRINT_CFLAGS@ \
   @XCB_XTEST_CFLAGS@ \
   @XCB_XINPUT_CFLAGS@ \
+  @XCB_XGESTURE_CFLAGS@ \
   @XCB_CURSOR_CFLAGS@ \
   @ECORE_XCB_CFLAGS@ \
   @PIXMAN_CFLAGS@ \
@@ -50,6 +51,7 @@ libecore_x_xcb_la_SOURCES = \
   ecore_xcb_gc.c \
   ecore_xcb_image.c \
   ecore_xcb_input.c \
+  ecore_xcb_gesture.c \
   ecore_xcb_mwm.c \
   ecore_xcb_pixmap.c \
   ecore_xcb_region.c \
@@ -83,6 +85,7 @@ libecore_x_xcb_la_LIBADD = \
   @XCB_XPRINT_LIBS@ \
   @XCB_XTEST_LIBS@ \
   @XCB_XINPUT_LIBS@ \
+  @XCB_XGESTURE_LIBS@ \
   @XCB_CURSOR_LIBS@ \
   @ECORE_XCB_LIBS@ \
   @PIXMAN_LIBS@ \
index 7851d3f..ca7e798 100644 (file)
@@ -1362,6 +1362,9 @@ _ecore_xcb_shutdown(Eina_Bool close_display)
    /* shutdown input extension */
    _ecore_xcb_input_shutdown();
 
+   /* shutdown gesture extension */
+   _ecore_xcb_gesture_shutdown();
+
    /* shutdown selection */
    _ecore_xcb_selection_shutdown();
 
index b1edca1..beb4cf2 100644 (file)
@@ -18,6 +18,9 @@
 # ifdef ECORE_XCB_XFIXES
 #  include <xcb/xfixes.h>
 # endif
+# ifdef ECORE_XCB_XGESTURE
+#  include <xcb/gesture.h>
+# endif
 
 #ifndef CODESET
 # define CODESET "INVALID"
@@ -78,6 +81,15 @@ static void                     _ecore_xcb_event_handle_randr_crtc_change(xcb_ge
 static void                     _ecore_xcb_event_handle_randr_output_change(xcb_generic_event_t *event);
 static void                     _ecore_xcb_event_handle_randr_output_property_change(xcb_generic_event_t *event);
 static void                     _ecore_xcb_event_handle_screensaver_notify(xcb_generic_event_t *event);
+#ifdef ECORE_XCB_XGESTURE
+static void                     _ecore_xcb_event_handle_gesture_notify_flick(xcb_generic_event_t *event);
+static void                     _ecore_xcb_event_handle_gesture_notify_pan(xcb_generic_event_t *event);
+static void                     _ecore_xcb_event_handle_gesture_notify_pinchrotation(xcb_generic_event_t *event);
+static void                     _ecore_xcb_event_handle_gesture_notify_tap(xcb_generic_event_t *event);
+static void                     _ecore_xcb_event_handle_gesture_notify_tapnhold(xcb_generic_event_t *event);
+static void                     _ecore_xcb_event_handle_gesture_notify_hold(xcb_generic_event_t *event);
+static void                     _ecore_xcb_event_handle_gesture_notify_group(xcb_generic_event_t *event);
+#endif
 #ifdef ECORE_XCB_SHAPE
 static void                     _ecore_xcb_event_handle_shape_change(xcb_generic_event_t *event);
 #endif
@@ -145,6 +157,13 @@ EAPI int ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = 0;
 EAPI int ECORE_X_EVENT_CLIENT_MESSAGE = 0;
 EAPI int ECORE_X_EVENT_WINDOW_SHAPE = 0;
 EAPI int ECORE_X_EVENT_SCREENSAVER_NOTIFY = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_FLICK = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PAN = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAP = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_HOLD = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_GROUP = 0;
 EAPI int ECORE_X_EVENT_SYNC_COUNTER = 0;
 EAPI int ECORE_X_EVENT_SYNC_ALARM = 0;
 EAPI int ECORE_X_EVENT_SCREEN_CHANGE = 0;
@@ -201,6 +220,13 @@ _ecore_xcb_events_init(void)
         ECORE_X_EVENT_CLIENT_MESSAGE = ecore_event_type_new();
         ECORE_X_EVENT_WINDOW_SHAPE = ecore_event_type_new();
         ECORE_X_EVENT_SCREENSAVER_NOTIFY = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_FLICK = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_PAN = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_TAP = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_HOLD = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_GROUP = ecore_event_type_new();
         ECORE_X_EVENT_SYNC_COUNTER = ecore_event_type_new();
         ECORE_X_EVENT_SYNC_ALARM = ecore_event_type_new();
         ECORE_X_EVENT_SCREEN_CHANGE = ecore_event_type_new();
@@ -401,6 +427,36 @@ _ecore_xcb_events_handle(xcb_generic_event_t *ev)
              _ecore_xcb_event_screensaver + XCB_SCREENSAVER_NOTIFY))
      _ecore_xcb_event_handle_screensaver_notify(ev);
 #endif
+#ifdef ECORE_XCB_XGESTURE
+   else if ((_ecore_xcb_event_gesture >= 0) && 
+            (response == 
+                _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_FLICK))
+     _ecore_xcb_event_handle_gesture_notify_flick(ev);
+   else if ((_ecore_xcb_event_gesture >= 0) && 
+            (response == 
+                _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_PAN))
+     _ecore_xcb_event_handle_gesture_notify_pan(ev);
+   else if ((_ecore_xcb_event_gesture >= 0) && 
+            (response == 
+                _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_PINCH_ROTATION))
+     _ecore_xcb_event_handle_gesture_notify_pinchrotation(ev);
+   else if ((_ecore_xcb_event_gesture >= 0) && 
+            (response == 
+                _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_TAP))
+     _ecore_xcb_event_handle_gesture_notify_tap(ev);
+   else if ((_ecore_xcb_event_gesture >= 0) && 
+            (response == 
+                _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_TAP_N_HOLD))
+     _ecore_xcb_event_handle_gesture_notify_tapnhold(ev);
+   else if ((_ecore_xcb_event_gesture >= 0) && 
+            (response == 
+                _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_HOLD))
+     _ecore_xcb_event_handle_gesture_notify_hold(ev);
+   else if ((_ecore_xcb_event_gesture >= 0) && 
+            (response == 
+                _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_GROUP))
+     _ecore_xcb_event_handle_gesture_notify_group(ev);
+#endif
 #ifdef ECORE_XCB_SHAPE
    else if ((_ecore_xcb_event_shape >= 0) &&
             (response == (_ecore_xcb_event_shape + XCB_SHAPE_NOTIFY)))
@@ -1932,6 +1988,181 @@ _ecore_xcb_event_handle_screensaver_notify(xcb_generic_event_t *event)
 #endif
 }
 
+#ifdef ECORE_XCB_XGESTURE
+static void
+_ecore_xcb_event_handle_gesture_notify_flick(xcb_generic_event_t *event)
+{
+   xcb_gesture_notify_flick_event_t *ev;
+   Ecore_X_Event_Gesture_Notify_Flick *e;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_xcb_event_last_mouse_move = EINA_FALSE;
+   fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__);
+
+   ev = (xcb_gesture_notify_flick_event_t *)event;
+   if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Flick)))) return;
+
+   e->win = ev->window;
+   e->time = ev->time;
+   e->subtype = ev->kind;
+   e->num_fingers = ev->num_finger;
+   e->distance = ev->distance;
+   e->duration = ev->duration;
+   e->direction = ev->direction;
+   e->angle = XFixedToDouble(ev->angle);
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_FLICK, e, NULL, NULL);
+}
+
+static void
+_ecore_xcb_event_handle_gesture_notify_pan(xcb_generic_event_t *event)
+{
+   xcb_gesture_notify_pan_event_t *ev;
+   Ecore_X_Event_Gesture_Notify_Pan *e;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_xcb_event_last_mouse_move = EINA_FALSE;
+   fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__);
+
+   ev = (xcb_gesture_notify_pan_event_t *)event;
+   if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Pan)))) return;
+
+   e->win = ev->window;
+   e->time = ev->time;
+   e->subtype = ev->kind;
+   e->num_fingers = ev->num_finger;
+   e->dx = ev->dx;
+   e->dy = ev->dy;
+   e->distance = ev->distance;
+   e->duration = ev->duration;
+   e->direction = ev->direction;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PAN, e, NULL, NULL);
+}
+
+static void
+_ecore_xcb_event_handle_gesture_notify_pinchrotation(xcb_generic_event_t *event)
+{
+   xcb_gesture_notify_pinch_rotation_event_t *ev;
+   Ecore_X_Event_Gesture_Notify_PinchRotation *e;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_xcb_event_last_mouse_move = EINA_FALSE;
+   fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__);
+
+   ev = (xcb_gesture_notify_pinch_rotation_event_t *)event;
+   if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_PinchRotation)))) return;
+
+   e->win = ev->window;
+   e->time = ev->time;
+   e->subtype = ev->kind;
+   e->num_fingers = ev->num_finger;
+   e->distance = ev->distance;
+   e->cx = ev->cx;
+   e->cy = ev->cy;
+   e->zoom = XFixedToDouble(ev->zoom);
+   e->angle = XFixedToDouble(ev->angle);
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION, e, NULL, NULL);
+}
+
+static void
+_ecore_xcb_event_handle_gesture_notify_tap(xcb_generic_event_t *event)
+{
+   xcb_gesture_notify_tap_event_t *ev;
+   Ecore_X_Event_Gesture_Notify_Tap *e;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_xcb_event_last_mouse_move = EINA_FALSE;
+   fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__);
+
+   ev = (xcb_gesture_notify_tap_event_t *)event;
+   if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Tap)))) return;
+
+   e->win = ev->window;
+   e->time = ev->time;
+   e->subtype = ev->kind;
+   e->num_fingers = ev->num_finger;
+   e->cx = ev->cx;
+   e->cy = ev->cy;
+   e->tap_repeat = ev->tap_repeat;
+   e->interval = ev->interval;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAP, e, NULL, NULL);
+}
+
+static void
+_ecore_xcb_event_handle_gesture_notify_tapnhold(xcb_generic_event_t *event)
+{
+   xcb_gesture_notify_tap_n_hold_event_t *ev;
+   Ecore_X_Event_Gesture_Notify_TapNHold *e;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_xcb_event_last_mouse_move = EINA_FALSE;
+   fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__);
+
+   ev = (xcb_gesture_notify_tap_n_hold_event_t *)event;
+   if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_TapNHold)))) return;
+
+   e->win = ev->window;
+   e->time = ev->time;
+   e->subtype = ev->kind;
+   e->num_fingers = ev->num_finger;
+   e->cx = ev->cx;
+   e->cy = ev->cy;
+   e->interval = ev->interval;
+   e->hold_time = ev->holdtime;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD, e, NULL, NULL);
+}
+
+static void
+ _ecore_xcb_event_handle_gesture_notify_hold(xcb_generic_event_t *event)
+{
+   xcb_gesture_notify_hold_event_t *ev;
+   Ecore_X_Event_Gesture_Notify_Hold *e;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_xcb_event_last_mouse_move = EINA_FALSE;
+   fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__);
+
+   ev = (xcb_gesture_notify_hold_event_t *)event;
+   if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Hold)))) return;
+
+   e->win = ev->window;
+   e->time = ev->time;
+   e->subtype = ev->kind;
+   e->num_fingers = ev->num_finger;
+   e->cx = ev->cx;
+   e->cy = ev->cy;
+   e->hold_time = ev->holdtime;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD, e, NULL, NULL);
+}
+
+static void
+ _ecore_xcb_event_handle_gesture_notify_group(xcb_generic_event_t *event)
+{
+   xcb_gesture_notify_group_event_t *ev;
+   Ecore_X_Event_Gesture_Notify_Group *e;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   _ecore_xcb_event_last_mouse_move = EINA_FALSE;
+   fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__);
+
+   ev = (xcb_gesture_notify_group_event_t *)event;
+   if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Group)))) return;
+
+   e->win = ev->window;
+   e->time = ev->time;
+   e->subtype = ev->kind;
+   e->num_groups = ev->num_group;
+   e->group_id = ev->groupid;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_GROUP, e, NULL, NULL);
+}
+#endif
+
 #ifdef ECORE_XCB_SHAPE
 static void
 _ecore_xcb_event_handle_shape_change(xcb_generic_event_t *event)
index 511a591..40c10ac 100644 (file)
@@ -60,6 +60,10 @@ _ecore_xcb_extensions_init(void)
    _ecore_xcb_input_init();
 #endif
 
+#ifdef ECORE_XCB_GESTURE
+   _ecore_xcb_gesture_init();
+#endif
+
 /* #ifdef ECORE_XCB_DRI */
 /*    _ecore_xcb_dri_init(); */
 /* #endif */
@@ -127,6 +131,10 @@ _ecore_xcb_extensions_finalize(void)
    _ecore_xcb_input_finalize();
 #endif
 
+#ifdef ECORE_XCB_GESTURE
+   _ecore_xcb_gesture_finalize();
+#endif
+
 /* #ifdef ECORE_XCB_DRI */
 /*    _ecore_xcb_dri_finalize(); */
 /* #endif */
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_gesture.c b/src/lib/ecore_x/xcb/ecore_xcb_gesture.c
new file mode 100644 (file)
index 0000000..263dade
--- /dev/null
@@ -0,0 +1,203 @@
+#include "ecore_xcb_private.h"
+#ifdef ECORE_XCB_XGESTURE
+# include <xcb/gesture.h>
+# include <xcb/xcb_event.h>
+#endif
+
+/* local variables */
+static Eina_Bool _gesture_available = EINA_FALSE;
+
+/* external variables */
+int _ecore_xcb_event_gesture = -1;
+
+void 
+_ecore_xcb_gesture_init(void) 
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+#ifdef ECORE_XCB_XGESTURE
+   xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_gesture_id);
+#endif
+}
+
+void 
+_ecore_xcb_gesture_finalize(void) 
+{
+#ifdef ECORE_XCB_XGESTURE
+   xcb_gesture_query_version_cookie_t cookie;
+   xcb_gesture_query_version_reply_t *reply;
+#endif
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+#ifdef ECORE_XCB_XGESTURE
+   cookie = 
+     xcb_gesture_query_version_unchecked(_ecore_xcb_conn);
+   reply = 
+     xcb_gesture_query_version_reply(_ecore_xcb_conn, cookie, NULL);
+   if (reply) 
+     {
+        _gesture_available = EINA_TRUE;
+        free(reply);
+     }
+
+   if (_gesture_available) 
+     {
+        const xcb_query_extension_reply_t *ext_reply;
+
+        ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_gesture_id);
+        if (ext_reply) 
+          _ecore_xcb_event_gesture = ext_reply->first_event;
+     }
+#endif
+}
+
+void 
+_ecore_xcb_gesture_shutdown(void) 
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+}
+
+EAPI Eina_Bool
+ecore_x_gesture_supported(void)
+{
+   return _gesture_available;
+}
+
+#ifdef ECORE_XCB_XGESTURE
+EAPI Eina_Bool
+ecore_x_gesture_events_select(Ecore_X_Window win,
+                              Ecore_X_Gesture_Event_Mask mask)
+#else
+EAPI Eina_Bool
+ecore_x_gesture_events_select(Ecore_X_Window win __UNUSED__,
+                              Ecore_X_Gesture_Event_Mask mask __UNUSED__)
+#endif
+
+{
+#ifdef ECORE_XCB_XGESTURE
+   if (!_gesture_available) return EINA_FALSE;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   CHECK_XCB_CONN
+
+   xcb_gesture_select_events(_ecore_xcb_conn, win, mask);
+
+   return EINA_TRUE;
+#else
+   return EINA_FALSE;
+#endif
+}
+
+#ifdef ECORE_XCB_XGESTURE
+EAPI Ecore_X_Gesture_Event_Mask
+ecore_x_gesture_events_selected_get(Ecore_X_Window win)
+#else
+EAPI Ecore_X_Gesture_Event_Mask
+ecore_x_gesture_events_selected_get(Ecore_X_Window win __UNUSED__)
+#endif
+{
+#ifdef ECORE_XCB_XGESTURE
+   xcb_gesture_get_selected_events_cookie_t ecookie;
+   xcb_gesture_get_selected_events_reply_t *ereply;
+   Ecore_X_Gesture_Event_Mask mask = ECORE_X_GESTURE_EVENT_MASK_NONE;
+
+   if (!_gesture_available) return mask;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   CHECK_XCB_CONN
+
+   ecookie = xcb_gesture_get_selected_events(_ecore_xcb_conn, win);
+   ereply = 
+     xcb_gesture_get_selected_events_reply(_ecore_xcb_conn, ecookie, NULL);
+   if (ereply)
+     {
+        mask = ereply->mask;
+        free(ereply);
+     }
+
+   return mask;
+#else
+   return ECORE_X_GESTURE_EVENT_MASK_NONE;
+#endif
+}
+
+#ifdef ECORE_XCB_XGESTURE
+EAPI Eina_Bool
+ecore_x_gesture_event_grab(Ecore_X_Window win,
+                           Ecore_X_Gesture_Event_Type type,
+                           int num_fingers)
+#else
+EAPI Eina_Bool
+ecore_x_gesture_event_grab(Ecore_X_Window win __UNUSED__,
+                           Ecore_X_Gesture_Event_Type type __UNUSED__,
+                           int num_fingers __UNUSED__)
+#endif
+{
+#ifdef ECORE_XCB_XGESTURE
+   Eina_Bool status = EINA_TRUE;
+   xcb_gesture_grab_event_cookie_t ecookie;
+   xcb_gesture_grab_event_reply_t *ereply;
+
+   if (!_gesture_available) return EINA_FALSE;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   CHECK_XCB_CONN
+
+   ecookie = 
+     xcb_gesture_grab_event(_ecore_xcb_conn, win, type, num_fingers, 0L);
+   ereply = xcb_gesture_grab_event_reply(_ecore_xcb_conn, ecookie, NULL);
+
+   if (ereply)
+     {
+        if (ereply->status) status = EINA_FALSE;
+        free(ereply);
+     }
+   else
+     status = EINA_FALSE;
+
+   return status;
+#else
+   return EINA_FALSE;
+#endif
+}
+
+#ifdef ECORE_XCB_XGESTURE
+EAPI Eina_Bool
+ecore_x_gesture_event_ungrab(Ecore_X_Window win,
+                             Ecore_X_Gesture_Event_Type type,
+                             int num_fingers)
+#else
+EAPI Eina_Bool
+ecore_x_gesture_event_ungrab(Ecore_X_Window win __UNUSED__,
+                             Ecore_X_Gesture_Event_Type type __UNUSED__,
+                             int num_fingers __UNUSED__)
+#endif
+{
+#ifdef ECORE_XCB_XGESTURE
+   Eina_Bool status = EINA_TRUE;
+   xcb_gesture_ungrab_event_cookie_t ecookie;
+   xcb_gesture_ungrab_event_reply_t *ereply;
+
+   if (!_gesture_available) return EINA_FALSE;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   CHECK_XCB_CONN
+
+  ecookie = 
+     xcb_gesture_ungrab_event(_ecore_xcb_conn, win, type, num_fingers, 0L);
+  ereply = xcb_gesture_ungrab_event_reply(_ecore_xcb_conn, ecookie, NULL);
+
+   if (ereply)
+     {
+        if (ereply->status) status = EINA_FALSE;
+        free(ereply);
+     }
+   else
+     status = EINA_FALSE;
+
+   return status;
+#else
+   return EINA_FALSE;
+#endif
+}
index 1d041d3..0a523b9 100644 (file)
@@ -358,6 +358,25 @@ ecore_x_netwm_desk_workareas_set(Ecore_X_Window root,
                                   4 * n_desks);
 }
 
+EAPI unsigned int *
+ecore_x_netwm_desk_workareas_get(Ecore_X_Window root, unsigned int *n_desks)
+{
+   int ret;
+   unsigned int *areas = NULL;
+   
+   if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
+   
+   ret = ecore_x_window_prop_card32_list_get(root, ECORE_X_ATOM_NET_WORKAREA,
+                                             &areas);
+   if (!areas)
+     {
+        if (n_desks) *n_desks = 0;
+        return 0;
+     }
+   if (n_desks) *n_desks = ret / 4;
+   return areas;
+}
+
 EAPI void
 ecore_x_netwm_desk_current_set(Ecore_X_Window root,
                                unsigned int   desk)
index 9d8c26b..cf8f3e5 100644 (file)
@@ -207,6 +207,7 @@ extern int _ecore_xcb_event_shape;
 extern int _ecore_xcb_event_sync;
 extern int _ecore_xcb_event_xfixes;
 extern int _ecore_xcb_event_input;
+extern int _ecore_xcb_event_gesture;
 
 extern int ECORE_X_MODIFIER_SHIFT;
 extern int ECORE_X_MODIFIER_CTRL;
@@ -263,6 +264,10 @@ Ecore_X_Visual     *_ecore_xcb_render_visual_get(int visual_id);
 void                _ecore_xcb_randr_init(void);
 void                _ecore_xcb_randr_finalize(void);
 
+void _ecore_xcb_gesture_init(void);
+void _ecore_xcb_gesture_finalize(void);
+void _ecore_xcb_gesture_shutdown(void);
+
 void                _ecore_xcb_xfixes_init(void);
 void                _ecore_xcb_xfixes_finalize(void);
 Eina_Bool           _ecore_xcb_xfixes_avail_get(void);
index e767a5a..510da49 100644 (file)
@@ -3,11 +3,9 @@
  * ecore_x_randr_crtc_clone_set
  * ecore_x_randr_output_size_mm_get
  * ecore_x_randr_output_crtc_set
- * ecore_x_randr_edid_valid_header
  * ecore_x_randr_edid_version_get
  * ecore_x_randr_edid_info_has_valid_checksum
  * ecore_x_randr_edid_manufacturer_name_get
- * ecore_x_randr_edid_display_name_get
  * ecore_x_randr_edid_display_ascii_get
  * ecore_x_randr_edid_display_serial_get
  * ecore_x_randr_edid_model_get
 #define RANDR_CHECK_1_2_RET(ret) if (_randr_version < RANDR_1_2) return ret
 #define RANDR_CHECK_1_3_RET(ret) if (_randr_version < RANDR_1_3) return ret
 
+#define ECORE_X_RANDR_EDID_VERSION_13 ((1 << 8) | 3)
+#define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR 0x12
+#define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR 0x13
+#define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK 0x36
+#define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE 3
+#define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT 5
+#define _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX 13
+
+#define _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block) \
+  for (block = edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK; block <= (edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK + (3 * 18)); block += 18)
+
+#define _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block) \
+  _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block)                 \
+  if ((block[0] == 0) && (block[1] == 0))
+
 /* local function prototypes */
 static Eina_Bool                                       _ecore_xcb_randr_output_validate(Ecore_X_Window       root,
                                                                                         Ecore_X_Randr_Output output);
@@ -2436,6 +2449,64 @@ ecore_x_randr_output_backlight_level_set(Ecore_X_Window       root,
    return EINA_FALSE;
 }
 
+EAPI int
+ecore_x_randr_edid_version_get(unsigned char *edid, unsigned long edid_length)
+{
+   if ((edid_length > _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR) &&
+       (ecore_x_randr_edid_has_valid_header(edid, edid_length)))
+     return (edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR] << 8) |
+            edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR];
+   return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
+}
+
+EAPI char *
+ecore_x_randr_edid_display_name_get(unsigned char *edid, unsigned long edid_length) 
+{
+   unsigned char *block = NULL;
+   int version = 0;
+
+   version = ecore_x_randr_edid_version_get(edid, edid_length);
+   if (version < ECORE_X_RANDR_EDID_VERSION_13) return NULL;
+
+   _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
+     {
+        if (block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfc)
+          {
+             char *name, *p;
+             const char *edid_name;
+
+             edid_name = (const char *)block + 
+               _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT;
+             name = 
+               malloc(sizeof(char) * 
+                      _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX);
+             if (!name) return NULL;
+
+             strncpy(name, edid_name, 
+                     (_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX - 1));
+             name[_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX] = 0;
+             for (p = name; *p; p++)
+               if ((*p < ' ') || (*p > '~')) *p = 0;
+
+             return name;
+          }
+     }
+   return NULL;
+}
+
+EAPI Eina_Bool
+ecore_x_randr_edid_has_valid_header(unsigned char *edid, unsigned long edid_length)
+{
+   const unsigned char header[] =
+     { 
+        0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 
+     };
+
+   if ((!edid) || (edid_length < 8)) return EINA_FALSE;
+   if (!memcmp(edid, header, 8)) return EINA_TRUE;
+   return EINA_FALSE;
+}
+
 /* local functions */
 static Eina_Bool
 _ecore_xcb_randr_output_validate(Ecore_X_Window       root,
index 1668c34..3c7364c 100644 (file)
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
 @XKB_CFLAGS@ \
 @XDAMAGE_CFLAGS@ \
 @XCOMPOSITE_CFLAGS@ \
+@XGESTURE_CFLAGS@ \
 @XDPMS_CFLAGS@ \
 @XFIXES_CFLAGS@ \
 @XI2_CFLAGS@ \
@@ -64,13 +65,15 @@ ecore_x_region.c \
 ecore_x_image.c \
 ecore_x_xi2.c \
 ecore_x_vsync.c \
-ecore_x_randr.h
+ecore_x_randr.h \
+ecore_x_gesture.c
 
 libecore_x_xlib_la_LIBADD = \
 @Xcursor_libs@ \
 @XKB_LIBS@ \
 @XDAMAGE_LIBS@ \
 @XCOMPOSITE_LIBS@ \
+@XGESTURE_LIBS@ \
 @XDPMS_LIBS@ \
 @XFIXES_LIBS@ \
 @XI2_LIBS@ \
index 36606b9..844ab04 100644 (file)
@@ -47,6 +47,9 @@ static int _ecore_x_event_fixes_selection_id = 0;
 #ifdef ECORE_XDAMAGE
 static int _ecore_x_event_damage_id = 0;
 #endif /* ifdef ECORE_XDAMAGE */
+#ifdef ECORE_XGESTURE
+static int _ecore_x_event_gesture_id = 0;
+#endif /* ifdef ECORE_XGESTURE */
 static int _ecore_x_event_handlers_num = 0;
 static void (**_ecore_x_event_handlers) (XEvent * event) = NULL;
 
@@ -96,6 +99,13 @@ EAPI int ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = 0;
 EAPI int ECORE_X_EVENT_CLIENT_MESSAGE = 0;
 EAPI int ECORE_X_EVENT_WINDOW_SHAPE = 0;
 EAPI int ECORE_X_EVENT_SCREENSAVER_NOTIFY = 0;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_FLICK;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PAN;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAP;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_HOLD;
+EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_GROUP;
 EAPI int ECORE_X_EVENT_SYNC_COUNTER = 0;
 EAPI int ECORE_X_EVENT_SYNC_ALARM = 0;
 EAPI int ECORE_X_EVENT_SCREEN_CHANGE = 0;
@@ -274,6 +284,10 @@ ecore_x_init(const char *name)
    int damage_base = 0;
    int damage_err_base = 0;
 #endif /* ifdef ECORE_XDAMAGE */
+#ifdef ECORE_XGESTURE
+   int gesture_base = 0;
+   int gesture_err_base = 0;
+#endif /* ifdef ECORE_XGESTURE */
 
    if (++_ecore_x_init_count != 1)
      return _ecore_x_init_count;
@@ -359,6 +373,13 @@ ecore_x_init(const char *name)
    ECORE_X_EVENT_HANDLERS_GROW(damage_base, XDamageNumberEvents);
 #endif /* ifdef ECORE_XDAMAGE */
 
+#ifdef ECORE_XGESTURE
+   if (XGestureQueryExtension(_ecore_x_disp, &gesture_base, &gesture_err_base))
+      _ecore_x_event_gesture_id = gesture_base;
+
+   ECORE_X_EVENT_HANDLERS_GROW(gesture_base, GestureNumberEvents);
+#endif /* ifdef ECORE_XGESTURE */
+
    _ecore_x_event_handlers = calloc(_ecore_x_event_handlers_num, sizeof(void *));
    if (!_ecore_x_event_handlers)
      goto close_display;
@@ -473,6 +494,27 @@ ecore_x_init(const char *name)
    while (0);
 #endif /* ifdef ECORE_XKB */
 
+#ifdef ECORE_XGESTURE
+   if (_ecore_x_event_gesture_id)
+     {
+      _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyFlick] =
+         _ecore_x_event_handle_gesture_notify_flick;
+      _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyPan] =
+         _ecore_x_event_handle_gesture_notify_pan;
+      _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyPinchRotation] =
+         _ecore_x_event_handle_gesture_notify_pinchrotation;
+      _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyTap] =
+         _ecore_x_event_handle_gesture_notify_tap;
+      _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyTapNHold] =
+         _ecore_x_event_handle_gesture_notify_tapnhold;
+      _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyHold] =
+         _ecore_x_event_handle_gesture_notify_hold;
+      _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyGroup] =
+         _ecore_x_event_handle_gesture_notify_group;
+     }
+
+#endif /* ifdef ECORE_XGESTURE */
+
    if (!ECORE_X_EVENT_ANY)
      {
         ECORE_X_EVENT_ANY = ecore_event_type_new();
@@ -505,6 +547,13 @@ ecore_x_init(const char *name)
         ECORE_X_EVENT_CLIENT_MESSAGE = ecore_event_type_new();
         ECORE_X_EVENT_WINDOW_SHAPE = ecore_event_type_new();
         ECORE_X_EVENT_SCREENSAVER_NOTIFY = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_FLICK = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_PAN = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_TAP = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_HOLD = ecore_event_type_new();
+        ECORE_X_EVENT_GESTURE_NOTIFY_GROUP = ecore_event_type_new();
         ECORE_X_EVENT_SYNC_COUNTER = ecore_event_type_new();
         ECORE_X_EVENT_SYNC_ALARM = ecore_event_type_new();
         ECORE_X_EVENT_SCREEN_CHANGE = ecore_event_type_new();
@@ -567,6 +616,7 @@ ecore_x_init(const char *name)
    _ecore_x_composite_init();
    _ecore_x_dpms_init();
    _ecore_x_randr_init();
+   _ecore_x_gesture_init();
    _ecore_x_input_init();
    _ecore_x_events_init();
 
index a0e22d3..54d3a85 100644 (file)
@@ -2299,3 +2299,185 @@ _ecore_x_event_handle_generic_event(XEvent *event)
 #endif /* ifdef ECORE_XI2 */
 } /* _ecore_x_event_handle_generic_event */
 
+#ifdef ECORE_XGESTURE
+void
+_ecore_x_event_handle_gesture_notify_flick(XEvent *xevent)
+{
+   XGestureNotifyFlickEvent *xfe;
+   Ecore_X_Event_Gesture_Notify_Flick *e;
+
+   _ecore_x_last_event_mouse_move = 0;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   xfe = (XGestureNotifyFlickEvent *)xevent;
+   e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Flick));
+   if (!e)
+      return;
+
+   e->win = xfe->window;
+   e->time = xfe->time;
+   e->subtype = xfe->kind;
+   e->num_fingers = xfe->num_finger;
+   e->distance = xfe->distance;
+   e->duration = xfe->duration;
+   e->direction = xfe->direction;
+   e->angle = XFixedToDouble(xfe->angle);
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_FLICK, e, NULL, NULL);
+}
+
+void
+_ecore_x_event_handle_gesture_notify_pan(XEvent *xevent)
+{
+   XGestureNotifyPanEvent *xpe;
+   Ecore_X_Event_Gesture_Notify_Pan *e;
+
+   _ecore_x_last_event_mouse_move = 0;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   xpe = (XGestureNotifyPanEvent *)xevent;
+   e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Pan));
+   if (!e)
+      return;
+
+   e->win = xpe->window;
+   e->time = xpe->time;
+   e->subtype = xpe->kind;
+   e->num_fingers = xpe->num_finger;
+   e->dx = xpe->dx;
+   e->dy = xpe->dy;
+   e->distance = xpe->distance;
+   e->duration = xpe->duration;
+   e->direction = xpe->direction;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PAN, e, NULL, NULL);
+}
+
+void
+_ecore_x_event_handle_gesture_notify_pinchrotation(XEvent *xevent)
+{
+   XGestureNotifyPinchRotationEvent *xpre;
+   Ecore_X_Event_Gesture_Notify_PinchRotation *e;
+
+   _ecore_x_last_event_mouse_move = 0;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   xpre = (XGestureNotifyPinchRotationEvent *)xevent;
+   e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_PinchRotation));
+   if (!e)
+      return;
+
+   e->win = xpre->window;
+   e->time = xpre->time;
+   e->subtype = xpre->kind;
+   e->num_fingers = xpre->num_finger;
+   e->distance = xpre->distance;
+   e->cx = xpre->cx;
+   e->cy = xpre->cy;
+   e->zoom = XFixedToDouble(xpre->zoom);
+   e->angle = XFixedToDouble(xpre->angle);
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION, e, NULL, NULL);
+}
+
+void
+_ecore_x_event_handle_gesture_notify_tap(XEvent *xevent)
+{
+   XGestureNotifyTapEvent *xte;
+   Ecore_X_Event_Gesture_Notify_Tap *e;
+
+   _ecore_x_last_event_mouse_move = 0;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   xte = (XGestureNotifyTapEvent *)xevent;
+   e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Tap));
+   if (!e)
+      return;
+
+   e->win = xte->window;
+   e->time = xte->time;
+   e->subtype = xte->kind;
+   e->num_fingers = xte->num_finger;
+   e->cx = xte->cx;
+   e->cy = xte->cy;
+   e->tap_repeat = xte->tap_repeat;
+   e->interval = xte->interval;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAP, e, NULL, NULL);
+}
+
+void
+_ecore_x_event_handle_gesture_notify_tapnhold(XEvent *xevent)
+{
+   XGestureNotifyTapNHoldEvent *xthe;
+   Ecore_X_Event_Gesture_Notify_TapNHold *e;
+
+   _ecore_x_last_event_mouse_move = 0;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   xthe = (XGestureNotifyTapNHoldEvent *)xevent;
+   e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_TapNHold));
+   if (!e)
+      return;
+
+   e->win = xthe->window;
+   e->time = xthe->time;
+   e->subtype = xthe->kind;
+   e->num_fingers = xthe->num_finger;
+   e->cx = xthe->cx;
+   e->cy = xthe->cy;
+   e->interval = xthe->interval;
+   e->hold_time = xthe->holdtime;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD, e, NULL, NULL);
+}
+
+void
+ _ecore_x_event_handle_gesture_notify_hold(XEvent *xevent)
+{
+   XGestureNotifyHoldEvent *xhe;
+   Ecore_X_Event_Gesture_Notify_Hold *e;
+
+   _ecore_x_last_event_mouse_move = 0;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   xhe = (XGestureNotifyHoldEvent *)xevent;
+   e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Hold));
+   if (!e)
+      return;
+
+   e->win = xhe->window;
+   e->time = xhe->time;
+   e->subtype = xhe->kind;
+   e->num_fingers = xhe->num_finger;
+   e->cx = xhe->cx;
+   e->cy = xhe->cy;
+   e->hold_time = xhe->holdtime;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD, e, NULL, NULL);
+}
+
+void
+ _ecore_x_event_handle_gesture_notify_group(XEvent *xevent)
+{
+   XGestureNotifyGroupEvent *xge;
+   Ecore_X_Event_Gesture_Notify_Group *e;
+
+   _ecore_x_last_event_mouse_move = 0;
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   xge = (XGestureNotifyGroupEvent *)xevent;
+   e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Group));
+   if (!e)
+      return;
+
+   e->win = xge->window;
+   e->time = xge->time;
+   e->subtype = xge->kind;
+   e->num_groups = xge->num_group;
+   e->group_id = xge->groupid;
+
+   ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_GROUP, e, NULL, NULL);
+}
+#endif /* ifdef ECORE_XGESTURE */
+
diff --git a/src/lib/ecore_x/xlib/ecore_x_gesture.c b/src/lib/ecore_x/xlib/ecore_x_gesture.c
new file mode 100644 (file)
index 0000000..69e8a6e
--- /dev/null
@@ -0,0 +1,127 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* ifdef HAVE_CONFIG_H */
+
+#include "ecore_x_private.h"
+
+static Eina_Bool _gesture_available = EINA_FALSE;
+
+#ifdef ECORE_XGESTURE
+static int _gesture_major, _gesture_minor, _gesture_patch;
+int _gesture_version;
+#endif /* ifdef ECORE_XGESTURE */
+
+void
+_ecore_x_gesture_init(void)
+{
+#ifdef ECORE_XGESTURE
+   _gesture_major = 0;
+   _gesture_minor = 0;
+   _gesture_patch = 0;
+   _gesture_version = 0;
+
+   if (XGestureQueryVersion(_ecore_x_disp, &_gesture_major, &_gesture_minor, &_gesture_patch))
+     {
+        _gesture_version = (_gesture_major << 16) | _gesture_minor;
+        _gesture_available = EINA_TRUE;
+     }
+   else
+      _gesture_available = EINA_FALSE;
+#else /* ifdef ECORE_XGESTURE */
+   _gesture_available = EINA_FALSE;
+#endif /* ifdef ECORE_XGESTURE */
+}
+
+/*
+ * @brief query whether gesture is available or not
+ * @return EINA_TRUE, if extension is available, else EINA_FALSE
+ */
+EAPI Eina_Bool
+ecore_x_gesture_supported(void)
+{
+   return _gesture_available;
+}
+
+EAPI Eina_Bool
+ecore_x_gesture_events_select(Ecore_X_Window win,
+                              Ecore_X_Gesture_Event_Mask mask)
+{
+#ifdef ECORE_XGESTURE
+   if (!_gesture_available)
+       return EINA_FALSE;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   XGestureSelectEvents(_ecore_x_disp, win, mask);
+   
+   return EINA_TRUE;
+#else /* ifdef ECORE_XGESTURE */
+   return EINA_FALSE;
+#endif /* ifdef ECORE_XGESTURE */
+}
+
+EAPI Ecore_X_Gesture_Event_Mask
+ecore_x_gesture_events_selected_get(Ecore_X_Window win)
+{
+#ifdef ECORE_XGESTURE
+   Ecore_X_Gesture_Event_Mask mask;
+
+   if (!_gesture_available)
+       return ECORE_X_GESTURE_EVENT_MASK_NONE;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   if (GestureSuccess != XGestureGetSelectedEvents(_ecore_x_disp, win, &mask))
+     {
+        mask = ECORE_X_GESTURE_EVENT_MASK_NONE;
+        return mask;
+     }
+   
+   return mask;
+#else /* ifdef ECORE_XGESTURE */
+   return ECORE_X_GESTURE_EVENT_MASK_NONE;
+#endif /* ifdef ECORE_XGESTURE */
+}
+
+EAPI Eina_Bool
+ecore_x_gesture_event_grab(Ecore_X_Window win,
+                           Ecore_X_Gesture_Event_Type type,
+                           int num_fingers)
+{
+#ifdef ECORE_XGESTURE
+   if (!_gesture_available)
+       return EINA_FALSE;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   if (GestureGrabSuccess != XGestureGrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime))
+     {
+        return EINA_FALSE;
+     }
+   
+   return EINA_TRUE;
+#else /* ifdef ECORE_XGESTURE */
+   return EINA_FALSE;
+#endif /* ifdef ECORE_XGESTURE */
+}
+
+EAPI Eina_Bool
+ecore_x_gesture_event_ungrab(Ecore_X_Window win,
+                             Ecore_X_Gesture_Event_Type type,
+                             int num_fingers)
+{
+#ifdef ECORE_XGESTURE
+   Ecore_X_Gesture_Event_Mask mask;
+
+   if (!_gesture_available)
+       return EINA_FALSE;
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   if (GestureUngrabSuccess != XGestureUngrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime))
+     {
+        return EINA_FALSE;
+     }
+   
+   return EINA_TRUE;
+#else /* ifdef ECORE_XGESTURE */
+   return EINA_FALSE;
+#endif /* ifdef ECORE_XGESTURE */
+}
+
index 36b028d..1a6fc9a 100644 (file)
@@ -269,6 +269,25 @@ ecore_x_netwm_desk_workareas_set(Ecore_X_Window root,
                                   4 * n_desks);
 } /* ecore_x_netwm_desk_workareas_set */
 
+EAPI unsigned int *
+ecore_x_netwm_desk_workareas_get(Ecore_X_Window root, unsigned int *n_desks)
+{
+   int ret;
+   unsigned int *areas = NULL;
+   
+   if (!root) root = DefaultRootWindow(_ecore_x_disp);
+   
+   ret = ecore_x_window_prop_card32_list_get(root, ECORE_X_ATOM_NET_WORKAREA,
+                                             &areas);
+   if (!areas)
+     {
+        if (n_desks) *n_desks = 0;
+        return 0;
+     }
+   if (n_desks) *n_desks = ret / 4;
+   return areas;
+}
+
 EAPI void
 ecore_x_netwm_desk_current_set(Ecore_X_Window root,
                                unsigned int   desk)
index 9ff45ed..02a01f7 100644 (file)
 #ifdef ECORE_XDAMAGE
 #include <X11/extensions/Xdamage.h>
 #endif /* ifdef ECORE_XDAMAGE */
+#ifdef ECORE_XGESTURE
+#include <X11/extensions/gesture.h>
+#include <X11/extensions/gestureproto.h>
+#endif /* ifdef ECORE_XGESTURE */
 #ifdef ECORE_XDPMS
 #include <X11/extensions/dpms.h>
 #endif /* ifdef ECORE_XDPMS */
@@ -243,6 +247,15 @@ void _ecore_x_event_handle_client_message(XEvent *xevent);
 void _ecore_x_event_handle_mapping_notify(XEvent *xevent);
 void _ecore_x_event_handle_shape_change(XEvent *xevent);
 void _ecore_x_event_handle_screensaver_notify(XEvent *xevent);
+#ifdef ECORE_XGESTURE
+void _ecore_x_event_handle_gesture_notify_flick(XEvent *xevent);
+void _ecore_x_event_handle_gesture_notify_pan(XEvent *xevent);
+void _ecore_x_event_handle_gesture_notify_pinchrotation(XEvent *xevent);
+void _ecore_x_event_handle_gesture_notify_tap(XEvent *xevent);
+void _ecore_x_event_handle_gesture_notify_tapnhold(XEvent *xevent);
+void _ecore_x_event_handle_gesture_notify_hold(XEvent *xevent);
+void _ecore_x_event_handle_gesture_notify_group(XEvent *xevent);
+#endif /* ifdef ECORE_XGESTURE */
 void _ecore_x_event_handle_sync_counter(XEvent *xevent);
 void _ecore_x_event_handle_sync_alarm(XEvent *xevent);
 #ifdef ECORE_XRANDR
@@ -303,6 +316,7 @@ void _ecore_x_damage_init(void);
 void _ecore_x_composite_init(void);
 void _ecore_x_dpms_init(void);
 void _ecore_x_randr_init(void);
+void _ecore_x_gesture_init(void);
 
 void _ecore_x_atoms_init(void);
 
index 364fc11..57a9068 100644 (file)
@@ -13,7 +13,6 @@ AM_CPPFLAGS = \
 -DPACKAGE_LIB_DIR=\"$(libdir)\" \
 -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
 @x_cflags@ \
-@EVAS_CFLAGS@ \
 @EINA_CFLAGS@
 
 pkgdir = $(libdir)/ecore/immodules
index e9799b9..7c40606 100644 (file)
@@ -2,7 +2,6 @@
 #include <Ecore.h>
 #include <Ecore_Input.h>
 #include <Ecore_IMF.h>
-#include <Evas.h>
 #include <Ecore_X.h>
 #include <X11/Xlib.h>
 #include <X11/Xlocale.h>
index 4756e8c..bfd20d9 100644 (file)
@@ -22,6 +22,7 @@ ecore_suite.h
 
 ecore_suite_LDADD = \
 @CHECK_LIBS@ \
+@EINA_LIBS@ \
 $(top_builddir)/src/lib/ecore/libecore.la \
 $(top_builddir)/src/lib/ecore_con/libecore_con.la