elput: Initial checkin of elput library
authorChris Michael <cpmichael@osg.samsung.com>
Thu, 24 Mar 2016 15:19:31 +0000 (11:19 -0400)
committerChris Michael <cpmichael@osg.samsung.com>
Wed, 13 Apr 2016 18:16:17 +0000 (14:16 -0400)
The elput library is an efl abstraction for the libinput library which
can be used by various other subsystems (ecore_fb, ecore_drm, etc) to
handle interfacing with libinput without having to duplicate the code
in each subsystem.

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
Makefile.am
configure.ac
pc/elput.pc.in [new file with mode: 0644]
src/Makefile.am
src/Makefile_Elput.am [new file with mode: 0644]
src/lib/elput/Elput.h [new file with mode: 0644]
src/lib/elput/elput.c [new file with mode: 0644]
src/lib/elput/elput_private.h [new file with mode: 0644]

index c2422db..564f332 100644 (file)
@@ -286,6 +286,10 @@ if HAVE_ECORE_BUFFER
 pkgconfig_DATA += pc/ecore-buffer.pc
 endif
 
+if HAVE_ELPUT
+pkgconfig_DATA += pc/elput.pc
+endif
+
 # Cmake configs:
 efl_cmakeconfigdir = $(libdir)/cmake/Efl/
 efl_cmakeconfig_DATA = \
index 44daa45..f34bac8 100644 (file)
@@ -1984,6 +1984,17 @@ AC_ARG_ENABLE([ecore-buffer],
    ],
    [want_ecore_buffer="no"])
 
+AC_ARG_ENABLE([elput],
+   [AS_HELP_STRING([--enable-elput],[enable elput library. @<:@default=disabled@:>@])],
+   [
+    if test "x${enableval}" = "xyes" ; then
+       want_elput="yes"
+    else
+       want_elput="no"
+    fi
+   ],
+   [want_elput="no"])
+
 # Image Loaders
 
 ARG_ENABLE_EVAS_IMAGE_LOADER(BMP, static)
@@ -3566,6 +3577,64 @@ EFL_LIB_END_OPTIONAL([Ecore_Drm])
 #### End of Ecore_Drm
 
 
+#### Elput
+have_libinput_new="no"
+EFL_LIB_START_OPTIONAL([Elput], [test "${want_elput}" = "yes"])
+
+### Additional options to configure
+SUID_CFLAGS=-fPIE
+SUID_LDFLAGS=-pie
+AC_SUBST([SUID_CFLAGS])
+AC_SUBST([SUID_LDFLAGS])
+
+### Default values
+
+### Checks for programs
+
+### Checks for libraries
+EFL_INTERNAL_DEPEND_PKG([ELPUT], [ecore])
+EFL_INTERNAL_DEPEND_PKG([ELPUT], [ecore-input])
+EFL_INTERNAL_DEPEND_PKG([ELPUT], [eldbus])
+EFL_INTERNAL_DEPEND_PKG([ELPUT], [eeze])
+EFL_INTERNAL_DEPEND_PKG([ELPUT], [eo])
+EFL_INTERNAL_DEPEND_PKG([ELPUT], [eina])
+
+EFL_DEPEND_PKG([ELPUT], [LIBINPUT], [libinput >= 0.6.0 xkbcommon >= 0.3.0])
+
+EFL_ADD_LIBS([ELPUT], [-lm])
+
+# API change from 0.7 to 0.8. So we define this to support both for now.
+PKG_CHECK_EXISTS([libinput >= 0.8.0],
+                 [have_libinput_new="yes"],
+                 [have_libinput_new="no"])
+AC_MSG_CHECKING([Use new libinput API (newer than 0.8.0)])
+AC_MSG_RESULT([${have_libinput_new}])
+if test "x${have_libinput_new}" = "xyes";then
+  AC_DEFINE_UNQUOTED([LIBINPUT_HIGHER_08], [1], [libinput version >= 0.8])
+fi
+if test "x${have_libinput_new}" = "xno";then
+  AC_DEFINE_UNQUOTED([LIBINPUT_HIGHER_08], [0], [libinput version >= 0.8])
+fi
+
+
+EFL_EVAL_PKGS([ELPUT])
+
+### Checks for header files
+
+### Checks for types
+
+### Checks for structures
+
+### Checks for compiler characteristics
+
+### Checks for linker characteristics
+
+### Checks for library functions
+
+EFL_LIB_END_OPTIONAL([Elput])
+#### End of Ecore_Drm
+
+
 #### Ecore_Audio
 
 AC_ARG_ENABLE([audio],
@@ -5512,6 +5581,7 @@ pc/elocation.pc
 pc/elua.pc
 pc/elementary.pc
 pc/elementary-cxx.pc
+pc/elput.pc
 dbus-services/org.enlightenment.Ethumb.service
 systemd-services/ethumb.service
 $po_makefile_in
@@ -5680,6 +5750,7 @@ fi
 echo "Ecore_Audio.....: ${efl_lib_optional_ecore_audio} (${features_ecore_audio})"
 echo "Ecore_Avahi.....: yes (${features_ecore_avahi})"
 echo "Ecore_Evas......: yes (${features_ecore_evas})"
+echo "Elput...........: $want_elput"
 echo "Ector...........: yes"
 echo "Eeze............: ${efl_lib_optional_eeze} (${features_eeze})"
 echo "EPhysics........: ${efl_lib_optional_ephysics}"
diff --git a/pc/elput.pc.in b/pc/elput.pc.in
new file mode 100644 (file)
index 0000000..c345022
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: elput
+Description: E core library, libinput module
+Requires.private: @requirements_pc_elput@
+Version: @VERSION@
+Libs: -L${libdir} -lelput
+Libs.private: @requirements_libs_elput@
+Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/elput-@VMAJ@
index 3aaa2ce..c08d77c 100644 (file)
@@ -70,6 +70,7 @@ include Makefile_Ethumb.am
 include Makefile_Ethumb_Client.am
 include Makefile_Elocation.am
 include Makefile_Elementary.am
+include Makefile_Elput.am
 
 include Makefile_Eina_Cxx.am
 include Makefile_Ecore_Cxx.am
diff --git a/src/Makefile_Elput.am b/src/Makefile_Elput.am
new file mode 100644 (file)
index 0000000..73fe8f9
--- /dev/null
@@ -0,0 +1,28 @@
+if HAVE_ELPUT
+
+### Library
+
+lib_LTLIBRARIES += lib/elput/libelput.la
+
+installed_elputmainheadersdir = $(includedir)/elput-@VMAJ@
+dist_installed_elputmainheaders_DATA = \
+  lib/elput/Elput.h
+
+lib_elput_libelput_la_SOURCES = \
+lib/elput/elput.c \
+lib/elput/elput_private.h
+
+lib_elput_libelput_la_CPPFLAGS = \
+  -I$(top_builddir)/src/lib/efl \
+  @ELPUT_CFLAGS@ @EFL_CFLAGS@ \
+  -DPACKAGE_LIB_DIR=\"$(libdir)\" \
+  -DMODULE_ARCH=\"$(MODULE_ARCH)\"
+
+lib_elput_libelput_la_LIBADD = @ELPUT_LIBS@
+if HAVE_SYSTEMD
+lib_elput_libelput_la_LIBADD += @SYSTEMD_LIBS@
+endif
+lib_elput_libelput_la_DEPENDENCIES = @ELPUT_INTERNAL_LIBS@
+lib_elput_libelput_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
+
+endif
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h
new file mode 100644 (file)
index 0000000..7c88e4b
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef _ELPUT_H
+# define _ELPUT_H
+
+# ifdef EAPI
+#  undef EAPI
+# endif
+
+# ifdef _MSC_VER
+#  ifdef BUILDING_DLL
+#   define EAPI __declspec(dllexport)
+#  else // ifdef BUILDING_DLL
+#   define EAPI __declspec(dllimport)
+#  endif // ifdef BUILDING_DLL
+# else // ifdef _MSC_VER
+#  ifdef __GNUC__
+#   if __GNUC__ >= 4
+#    define EAPI __attribute__ ((visibility("default")))
+#   else // if __GNUC__ >= 4
+#    define EAPI
+#   endif // if __GNUC__ >= 4
+#  else // ifdef __GNUC__
+#   define EAPI
+#  endif // ifdef __GNUC__
+# endif // ifdef _MSC_VER
+
+# ifdef EFL_BETA_API_SUPPORT
+
+/**
+ * @file
+ * @brief Ecore functions for dealing with libinput
+ *
+ * @defgroup Elput_Group Elput - libinput integration
+ * @ingrup Ecore
+ *
+ * Elput provides a wrapper and functions for using libinput
+ *
+ * @li @ref Elput_Init_Group
+ *
+ */
+
+/**
+ * @defgroup Elput_Init_Group Library Init and Shutdown functions
+ *
+ * Functions that start and shutdown the Elput library
+ */
+
+/**
+ * Initialize the Elput library
+ *
+ * @return The number of times the library has been initialized without being
+ *         shutdown. 0 is returned if an error occurs.
+ *
+ * @ingroup Elput_Init_Group
+ * @since 1.18
+ */
+EAPI int elput_init(void);
+
+/**
+ * Shutdown the Elput library
+ *
+ * @return The number of times the library has been initialized without being
+ *         shutdown. 0 is returned if an error occurs.
+ *
+ * @ingroup Elput_Init_Group
+ * @since 1.18
+ */
+EAPI int elput_shutdown(void);
+
+# endif
+
+# undef EAPI
+# define EAPI
+
+#endif
diff --git a/src/lib/elput/elput.c b/src/lib/elput/elput.c
new file mode 100644 (file)
index 0000000..1b5613f
--- /dev/null
@@ -0,0 +1,55 @@
+#include "elput_private.h"
+
+/* local variables */
+static int _elput_init_count = 0;
+
+/* external variables */
+int _elput_log_dom = -1;
+
+EAPI int
+elput_init(void)
+{
+   if (++_elput_init_count != 1) return _elput_init_count;
+
+   if (!eina_init()) goto eina_err;
+   if (!ecore_init()) goto ecore_err;
+   if (!ecore_event_init()) goto ecore_event_err;
+   if (!eeze_init()) goto eeze_err;
+
+   _elput_log_dom = eina_log_domain_register("elput", ELPUT_DEFAULT_LOG_COLOR);
+   if (!_elput_log_dom)
+     {
+        EINA_LOG_ERR("Could not create logging domain for Elput");
+        goto log_err;
+     }
+
+   return _elput_init_count;
+
+log_err:
+   eeze_shutdown();
+eeze_err:
+   ecore_event_shutdown();
+ecore_event_err:
+   ecore_shutdown();
+ecore_err:
+   eina_shutdown();
+eina_err:
+   return --_elput_init_count;
+}
+
+EAPI int
+elput_shutdown(void)
+{
+   if (_elput_init_count < 1) return 0;
+   if (--_elput_init_count != 0) return _elput_init_count;
+
+   eina_log_domain_unregister(_elput_log_dom);
+   _elput_log_dom = -1;
+
+   eeze_shutdown();
+   ecore_event_shutdown();
+   ecore_shutdown();
+   eina_shutdown();
+
+   return _elput_init_count;
+}
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
new file mode 100644 (file)
index 0000000..62b7395
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef _ELPUT_PRIVATE_H
+# define _ELPUT_PRIVATE_H
+
+# ifdef HAVE_CONFIG_H
+#  include "config.h"
+# endif
+
+# include "Ecore.h"
+# include "ecore_private.h"
+# include "Ecore_Input.h"
+# include "Eeze.h"
+# include "Eldbus.h"
+# include <Elput.h>
+
+# include <linux/vt.h>
+# include <linux/kd.h>
+# include <linux/major.h>
+# include <linux/input.h>
+# include <libinput.h>
+
+# ifdef HAVE_SYSTEMD
+#  include <systemd/sd-login.h>
+# endif
+
+# ifdef ELPUT_DEFAULT_LOG_COLOR
+#  undef ELPUT_DEFAULT_LOG_COLOR
+# endif
+# define ELPUT_DEFAULT_LOG_COLOR EINA_COLOR_GREEN
+
+extern int _elput_log_dom;
+
+# ifdef ERR
+#  undef ERR
+# endif
+# define ERR(...) EINA_LOG_DOM_ERR(_elput_log_dom, __VA_ARGS__)
+
+# ifdef DBG
+#  undef DBG
+# endif
+# define DBG(...) EINA_LOG_DOM_DBG(_elput_log_dom, __VA_ARGS__)
+
+# ifdef INF
+#  undef INF
+# endif
+# define INF(...) EINA_LOG_DOM_INFO(_elput_log_dom, __VA_ARGS__)
+
+# ifdef WRN
+#  undef WRN
+# endif
+# define WRN(...) EINA_LOG_DOM_WARN(_elput_log_dom, __VA_ARGS__)
+
+# ifdef CRIT
+#  undef CRIT
+# endif
+# define CRIT(...) EINA_LOG_DOM_CRIT(_elput_log_dom, __VA_ARGS__)
+
+#endif