damn you salizar! damn you!

errr. i mean. ecore moves to HEAD!


SVN revision: 7475
This commit is contained in:
Carsten Haitzler 2003-09-23 08:09:32 +00:00
parent cddaadb447
commit a5c2425084
112 changed files with 68736 additions and 0 deletions

7
legacy/ecore/AUTHORS Normal file
View File

@ -0,0 +1,7 @@
The Rasterman <raster@rasterman.com>
Tom Gilbert <tom@linuxbrit.co.uk>
Burra <burra@colorado.edu>
Chris Ross <chris@darkrock.co.uk>
Term <term@twistedpath.org>
Tilman Sauerbeck <tilman@code-monkey.de>
Yuri <da2001@hotmail.ru>

20
legacy/ecore/COPYING Normal file
View File

@ -0,0 +1,20 @@
Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies of the Software, its documentation and marketing & publicity
materials, and acknowledgment shall be given in the documentation, materials
and software packages that this Software was used.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0
legacy/ecore/ChangeLog Normal file
View File

145
legacy/ecore/Doxyfile Normal file
View File

@ -0,0 +1,145 @@
PROJECT_NAME = Ecore
PROJECT_NUMBER =
OUTPUT_DIRECTORY = doc
INPUT = ecore.c
IMAGE_PATH = doc/img
OUTPUT_LANGUAGE = English
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER = doc/head.html
HTML_FOOTER = doc/foot.html
HTML_STYLESHEET = doc/ecore.css
HTML_ALIGN_MEMBERS = YES
ENUM_VALUES_PER_LINE = 1
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
INTERNAL_DOCS = NO
STRIP_CODE_COMMENTS = YES
CASE_SENSE_NAMES = YES
SHORT_NAMES = NO
HIDE_SCOPE_NAMES = NO
VERBATIM_HEADERS = NO
SHOW_INCLUDE_FILES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 2
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SHOW_USED_FILES = NO
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 2
IGNORE_PREFIX =
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
GENERATE_MAN = YES
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = YES
GENERATE_XML = NO
XML_SCHEMA =
XML_DTD =
GENERATE_AUTOGEN_DEF = NO
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = NO
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = NO
COLLABORATION_GRAPH = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 512
MAX_DOT_GRAPH_HEIGHT = 512
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/bin/
EXT_DOC_PATHS =

0
legacy/ecore/INSTALL Normal file
View File

37
legacy/ecore/Makefile.am Normal file
View File

@ -0,0 +1,37 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = src debian
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
config.h.in config.sub configure install-sh \
ltconfig ltmain.sh missing mkinstalldirs \
stamp-h.in
install-data-local:
@$(NORMAL_INSTALL)
if test -d $(srcdir)/data; then \
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/data; \
for d in $(srcdir)/data/*; do \
cp -pR $$d $(DESTDIR)$(pkgdatadir)/data; \
done \
fi
dist-hook:
./gendoc; \
tar cvf ecore_docs.tar doc/html doc/latex doc/man; \
rm -f ecore_docs.tar.gz; \
gzip -9 ecore_docs.tar; \
if test -d data; then \
mkdir $(distdir)/data; \
for file in data/*; do \
cp -pR $$file $(distdir)/data; \
done \
fi
bin_SCRIPTS = ecore-config
EXTRA_DIST = README AUTHORS COPYING ecore.m4 ecore.spec ecore.c.in gendoc Doxyfile ecore_docs.tar.gz \
make_cross_compile_arm.sh conf-e-x11.sh
m4datadir = $(datadir)/aclocal
m4data_DATA = ecore.m4

0
legacy/ecore/NEWS Normal file
View File

46
legacy/ecore/README Normal file
View File

@ -0,0 +1,46 @@
-------------------------------------------------------------------------------
E C O R E - 1 . 0 . 0
-------------------------------------------------------------------------------
Fast:
How ot build and install Ecore from this tarball?
./configure \
--enable-ecore-x \
--enable-ecore-fb \
--enable-ecore-evas \
--enable-ecore-evas-gl \
--enable-ecore-job \
--enable-ecore-con \
--enable-ecore-ipc
make
su
<as root do:>
make install
from CVS:
./autogen.sh \
--enable-ecore-x \
--enable-ecore-fb \
--enable-ecore-evas \
--enable-ecore-evas-gl \
--enable-ecore-job \
--enable-ecore-con \
--enable-ecore-ipc
make
su
<as root do:>
make install
for ipaq cross-compile:
export CC=/skiff/local/bin/arm-linux-gcc
export CFLAGS="-O9"
./configure \
--enable-ecore-fb \
--enable-ecore-evas \
--enable-ecore-job \
--enable-ecore-con \
--enable-ecore-ipc \
--with-evas-config=/skiff/local/arm-linux/bin/evas-config
make CFLAGS="-O9 -I/skiff/local/include -I/skiff/local/arm-linux/include"

11
legacy/ecore/acconfig.h Normal file
View File

@ -0,0 +1,11 @@
#undef PACKAGE_LOCALE_DIR
#undef PACKAGE_DATA_DIR
#undef PACKAGE_SOURCE_DIR
#undef PACKAGE_BIN_DIR
#undef BUILD_ECORE_EVAS
#undef BUILD_ECORE_EVAS_GL
#undef BUILD_ECORE_FB
#undef BUILD_ECORE_JOB
#undef BUILD_ECORE_X
#undef BUILD_ECORE_CON
#undef BUILD_ECORE_IPC

148
legacy/ecore/autogen.sh Executable file
View File

@ -0,0 +1,148 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
PKG_NAME="libecore"
DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`autoconf' installed to."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed."
echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && {
grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
(gettext --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`gettext' installed."
echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
grep "^AM_GNOME_GETTEXT" $srcdir/configure.in >/dev/null && {
grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
(gettext --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`gettext' installed."
echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`automake' installed."
echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
NO_AUTOMAKE=yes
}
# if no automake, don't bother testing for aclocal
test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: Missing \`aclocal'. The version of \`automake'"
echo "installed doesn't appear recent enough."
echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
if test "$DIE" -eq 1; then
exit 1
fi
if test -z "$*"; then
echo "**Warning**: I am going to run \`configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
echo \`$0\'" command line."
echo
fi
case $CC in
xlc )
am_opt=--include-deps;;
esac
for coin in `find $srcdir -name configure.in -print`
do
dr=`dirname $coin`
if test -f $dr/NO-AUTO-GEN; then
echo skipping $dr -- flagged as no auto-gen
else
echo processing $dr
macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
( cd $dr
aclocalinclude="$ACLOCAL_FLAGS"
for k in $macrodirs; do
if test -d $k; then
aclocalinclude="$aclocalinclude -I $k"
##else
## echo "**Warning**: No such directory \`$k'. Ignored."
fi
done
if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then
if grep "sed.*POTFILES" configure.in >/dev/null; then
: do nothing -- we still have an old unmodified configure.in
else
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running gettextize... Ignore non-fatal messages."
echo "no" | gettextize --force --copy
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
fi
if grep "^AM_GNOME_GETTEXT" configure.in >/dev/null; then
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running gettextize... Ignore non-fatal messages."
echo "no" | gettextize --force --copy
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
echo "Running libtoolize..."
libtoolize --force --copy
fi
echo "Running aclocal $aclocalinclude ..."
aclocal $aclocalinclude
if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
echo "Running autoheader..."
autoheader
fi
echo "Running automake --gnu $am_opt ..."
automake --add-missing --gnu $am_opt
echo "Running autoconf ..."
autoconf
)
fi
done
#conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure $conf_flags "$@" \
&& echo Now type \`make\' to compile $PKG_NAME
else
echo Skipping configure process.
fi

12
legacy/ecore/conf-e-x11.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
cmake clean distclean
rm config.cache
./configure \
--enable-ecore-x \
--enable-ecore-evas \
--enable-ecore-evas-gl \
--enable-ecore-job \
--enable-ecore-con \
--enable-ecore-ipc \
$@

283
legacy/ecore/configure.in Normal file
View File

@ -0,0 +1,283 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(configure.in)
AC_ISC_POSIX
AM_INIT_AUTOMAKE(ecore, 1.0.0_pre4)
AM_CONFIG_HEADER(config.h)
AC_C_BIGENDIAN
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_C_CONST
AM_ENABLE_SHARED
AM_PROG_LIBTOOL
if test "x${exec_prefix}" = "xNONE"; then
if test "x${prefix}" = "xNONE"; then
bindir="${ac_default_prefix}/bin";
else
bindir="${prefix}/bin";
fi
else
if test "x${prefix}" = "xNONE"; then
bindir="${ac_default_prefix}/bin";
else
bindir="${prefix}/bin";
fi
fi
if test "x${exec_prefix}" = "xNONE"; then
if test "x${prefix}" = "xNONE"; then
libdir="${ac_default_prefix}/lib";
else
libdir="${prefix}/lib";
fi
else
if test "x${prefix}" = "xNONE"; then
libdir="${ac_default_prefix}/lib";
else
libdir="${prefix}/lib";
fi
fi
dnl Set PACKAGE_DATA_DIR in config.h.
if test "x${datadir}" = 'x${prefix}/share'; then
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}")
else
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}")
fi
else
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}")
fi
dnl Set PACKAGE_BIN_DIR in config.h.
if test "x${bindir}" = 'xNONE'; then
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin")
else
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin")
fi
else
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}")
fi
dnl Set PACKAGE_DATA_DIR in config.h.
if test "x${datadir}" = 'x${prefix}/share'; then
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}")
else
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}")
fi
else
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}")
fi
dnl Set PACKAGE_SOURCE_DIR in config.h.
packagesrcdir=`cd $srcdir && pwd`
AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}")
dnl Use -Wall if we have gcc.
changequote(,)dnl
if test "x$GCC" = "xyes"; then
case " $CFLAGS " in
*[\ \ ]-Wall[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -Wall" ;;
esac
fi
changequote([,])dnl
AC_MSG_CHECKING(whether ecore_x module is to be built)
ecore_x_cflags="";
ecore_x_libs="";
x_dir="";
x_includes="";
x_cflags="";
x_libs="";
x_ldflags="";
AC_ARG_ENABLE(ecore-x,
[ --enable-ecore-x enable the ecore_x module], [
AC_MSG_RESULT(yes)
AM_CONDITIONAL(BUILD_ECORE_X, test "$enableval" = "yes")
AC_DEFINE(BUILD_ECORE_X)
x_dir="/usr/X11R6";
x_includes="";
x_cflags="-I"$x_dir"/include"
x_libs="-L"$x_dir"/lib -lX11 -lXext"
x_ldflags="";
ecore_x_libs="-lecore_x";
], [
AC_MSG_RESULT(no)
AM_CONDITIONAL(BUILD_ECORE_X, false)
]
)
AC_SUBST(x_cflags)
AC_SUBST(x_includes)
AC_SUBST(x_ldflags)
AC_SUBST(x_libs)
AC_SUBST(ecore_x_cflags)
AC_SUBST(ecore_x_libs)
AC_MSG_CHECKING(whether ecore_job module is to be built)
ecore_job_cflags="";
ecore_job_libs="";
AC_ARG_ENABLE(ecore-job,
[ --enable-ecore-job enable the ecore_job module], [
AC_MSG_RESULT(yes)
AM_CONDITIONAL(BUILD_ECORE_JOB, test "$enableval" = "yes")
AC_DEFINE(BUILD_ECORE_JOB)
ecore_job_libs="-lecore_job";
], [
AC_MSG_RESULT(no)
AM_CONDITIONAL(BUILD_ECORE_JOB, false)
]
)
AC_SUBST(ecore_job_cflags)
AC_SUBST(ecore_job_libs)
ecore_fb_cflags="";
ecore_fb_libs="";
AC_MSG_CHECKING(whether ecore_fb module is to be built)
AC_ARG_ENABLE(ecore-fb,
[ --enable-ecore-fb enable the ecore_fb module], [
AC_MSG_RESULT(yes)
AM_CONDITIONAL(BUILD_ECORE_FB, test "$enableval" = "yes")
AC_DEFINE(BUILD_ECORE_FB)
ecore_fb_libs="-lecore_fb";
], [
AC_MSG_RESULT(no)
AM_CONDITIONAL(BUILD_ECORE_FB, false)
]
)
AC_SUBST(ecore_fb_cflags)
AC_SUBST(ecore_fb_libs)
ecore_evas_cflags="";
ecore_evas_libs="";
evas_cflags="";
evas_libs="";
AC_ARG_WITH(evas-config,
[ --with-evas-config=EVAS_CONFIG use evas-config specified ],
[
PROG_CONFIG=$withval;
echo "using "$PROG_CONFIG" for evas-config";
],[
PROG="evas-config";
AC_PATH_PROG(PROG_CONFIG, $PROG, "", $PATH)
])
EVAS_CONFIG=$PROG_CONFIG
AC_MSG_CHECKING(whether ecore_evas module is to be built)
AC_ARG_ENABLE(ecore-evas,
[ --enable-ecore-evas enable the ecore_evas module], [
AC_MSG_RESULT(yes)
AM_CONDITIONAL(BUILD_ECORE_EVAS, test "$enableval" = "yes")
AC_DEFINE(BUILD_ECORE_EVAS)
if [ test -z $EVAS_CONFIG ]; then
echo $PROG " is not in your \$PATH. Please ensure it is.";
echo "Read the manual page for you shell as to how to extend your path.";
echo "FATAL ERROR. ABORT.";
exit -1;
fi
evas_cflags=`$EVAS_CONFIG --cflags`
evas_libs=`$EVAS_CONFIG --libs`
ecore_evas_libs="-lecore_evas";
], [
AC_MSG_RESULT(no)
AM_CONDITIONAL(BUILD_ECORE_EVAS, false)
]
)
AC_SUBST(evas_cflags)
AC_SUBST(evas_libs)
AC_SUBST(ecore_evas_cflags)
AC_SUBST(ecore_evas_libs)
AC_MSG_CHECKING(whether ecore_evas gl support is to be built)
AC_ARG_ENABLE(ecore-evas-gl,
[ --enable-ecore-evas-gl enable gl in the ecore_evas module], [
AC_MSG_RESULT(yes)
AM_CONDITIONAL(BUILD_ECORE_EVAS_GL, test "$enableval" = "yes")
AC_DEFINE(BUILD_ECORE_EVAS_GL)
], [
AC_MSG_RESULT(no)
AM_CONDITIONAL(BUILD_ECORE_EVAS_GL, false)
]
)
AC_MSG_CHECKING(whether ecore_con module is to be built)
ecore_con_cflags="";
ecore_con_libs="";
AC_ARG_ENABLE(ecore-con,
[ --enable-ecore-con enable the ecore_con module], [
AC_MSG_RESULT(yes)
AM_CONDITIONAL(BUILD_ECORE_CON, test "$enableval" = "yes")
AC_DEFINE(BUILD_ECORE_CON)
ecore_con_libs="-lecore_con"
], [
AC_MSG_RESULT(no)
AM_CONDITIONAL(BUILD_ECORE_CON, false)
]
)
AC_SUBST(ecore_con_cflags)
AC_SUBST(ecore_con_libs)
AC_MSG_CHECKING(whether ecore_ipc module is to be built)
ecore_ipc_cflags="";
ecore_ipc_libs="";
AC_ARG_ENABLE(ecore-ipc,
[ --enable-ecore-ipc enable the ecore_ipc module], [
AC_MSG_RESULT(yes)
AM_CONDITIONAL(BUILD_ECORE_IPC, test "$enableval" = "yes")
AC_DEFINE(BUILD_ECORE_IPC)
ecore_ipc_libs="-lecore_ipc"
], [
AC_MSG_RESULT(no)
AM_CONDITIONAL(BUILD_ECORE_IPC, false)
]
)
AC_SUBST(ecore_ipc_cflags)
AC_SUBST(ecore_ipc_libs)
AC_OUTPUT([
Makefile
ecore-config
src/Makefile
src/bin/Makefile
src/lib/Makefile
src/lib/ecore/Makefile
src/lib/ecore_job/Makefile
src/lib/ecore_x/Makefile
src/lib/ecore_fb/Makefile
src/lib/ecore_evas/Makefile
src/lib/ecore_con/Makefile
src/lib/ecore_ipc/Makefile
debian/Makefile
], [
chmod +x ecore-config
]
)

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,8 @@
EXTRA_DIST = \
changelog \
control \
copyright \
ecore1-test.files \
libecore1.files \
libecore1-dev.files \
rules

View File

@ -0,0 +1,5 @@
ecore (1.0.0-pre3-0cvs20030821) unstable; urgency=low
* a CVS release
-- Sytse Wielinga <s.b.wielinga@student.utwente.nl> Thu, 21 Aug 2003 16:29:37 +0200

View File

@ -0,0 +1,35 @@
Source: ecore
Section: libs
Priority: optional
Maintainer: Sytse Wielinga <s.b.wielinga@student.utwente.nl>
Build-Depends: debhelper (>> 4.0.0)
Standards-Version: 3.6.1.0
Package: libecore1
Architecture: any
Section: libs
Depends: ${shlibs:Depends}
Description: Core abstraction layer for enlightenment DR 0.17
This is the core event abstraction layer and X abstraction layer that makes
doing selections, Xdnd, general X stuff, and event loops, timeouts and idle
handlers fast, optimized, and convenient. It's a separate library so anyone
can make use of the work put into Ecore to make this job easy for
applications.
Package: libecore1-dev
Architecture: any
Section: devel
Architecture: any
Depends: libecore1 (= ${Source-Version}), libc6-dev | libc-dev
Provides: libecore-dev
Conflicts: libecore-dev, libecore0-dev
Description: libecore1 headers, static libraries and documentation
Headers, static libraries and documentation for the Ecore library.
Package: ecore1-test
Architecture: any
Section: libs
Depends: ${shlibs:Depends}
Description: Test programs for libecore1
Programs for testing Ecore and demonstrating what it can do.

View File

@ -0,0 +1,32 @@
This package was debianized by Laurence J. Lane <ljlane@debian.org> on
Sat, 28 Oct 2000 17:56:46 -0400.
The source code is from the e17/libs/ecore module of the enlightenment CVS
tree. For more information, see:
http://www.enlightenment.org/cvs.html
Upstream Author: Carsten Haitzler <raster@rasterman.com>
Copyright:
Copyright (C) 2000 Carsten Haitzler and various contributors (see AUTHORS)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies of the Software, its documentation and marketing & publicity
materials, and acknowledgment shall be given in the documentation, materials
and software packages that this Software was used.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,2 @@
usr/bin/*test
usr/share/ecore/data/images/*.png

View File

@ -0,0 +1,7 @@
usr/include/*
usr/lib/lib*.a
usr/lib/lib*.so
usr/lib/pkgconfig/*
usr/lib/*.la
usr/share/aclocal/*
usr/bin/*-config

View File

@ -0,0 +1,3 @@
usr/lib/lib*.so.*
usr/share/ecore/data/fonts/*.ttf
usr/share/ecore/data/pointers/*.png

88
legacy/ecore/debian/rules Normal file
View File

@ -0,0 +1,88 @@
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This is the debhelper compatability version to use.
export DH_COMPAT=4
CFLAGS ?= -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
INSTALL=/usr/bin/install -p
CONFIGUREOPTS = --prefix=/usr --enable-ecore-x --enable-ecore-job --enable-ecore-evas --enable-ecore-con --enable-ecore-ipc --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
package=libecore1
configure: configure-stamp
configure-stamp:
dh_testdir
test -x autogen.sh && ./autogen.sh $(CONFIGUREOPTS) || ./configure $(CONFIGUREOPTS)
touch configure-stamp
build: configure build-stamp
build-stamp:
dh_testdir
$(MAKE)
touch build-stamp
clean:
dh_testdir
rm -f build-stamp configure-stamp
-$(MAKE) distclean
-rm -f configure-stamp build-stamp
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp/
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installdocs AUTHORS README
dh_installchangelogs
dh_movefiles
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_makeshlibs
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

178
legacy/ecore/doc/ecore.css Normal file
View File

@ -0,0 +1,178 @@
td.md {
background-color: #ffffff;
font-family: monospace;
text-align: left;
vertical-align: center;
font-size: 10;
padding-right : 1px;
padding-top : 1px;
padding-left : 1px;
padding-bottom : 1px;
margin-left : 1px;
margin-right : 1px;
margin-top : 1px;
margin-bottom : 1px
}
td.mdname {
font-family: monospace;
text-align: left;
vertical-align: center;
font-size: 10;
padding-right : 1px;
padding-top : 1px;
padding-left : 1px;
padding-bottom : 1px;
margin-left : 1px;
margin-right : 1px;
margin-top : 1px;
margin-bottom : 1px
}
h1
{
text-align: center;
color: #333333
}
h2
{
text-align: left;
color: #333333
}
h3
{
text-align: left;
color: #333333
}
a:link
{
text-decoration: none;
color: #444444;
font-weight: bold;
}
a:visited
{
text-decoration: none;
color: #666666;
font-weight: bold;
}
a:hover
{
text-decoration: none;
color: #000000;
font-weight: bold;
}
a.nav:link
{
text-decoration: none;
color: #444444;
font-weight: normal;
}
a.nav:visited
{
text-decoration: none;
color: #666666;
font-weight: normal;
}
a.nav:hover
{
text-decoration: none;
color: #000000;
font-weight: normal;
}
a.qindex:link
{
text-decoration: none;
color: #444444;
font-weight: normal;
}
a.qindex:visited
{
text-decoration: none;
color: #666666;
font-weight: normal;
}
a.qindex:hover
{
text-decoration: none;
color: #000000;
font-weight: normal;
}
p
{
color: #000000;
font-family: sans-serif;
font-size: 10;
}
body {
background-image: url("hilite.png");
background-repeat: no-repeat;
background-position: left top;
background-color: #dddddd;
color: #000000;
font-family: sans-serif;
padding: 8px;
margin: 0;
}
div.fragment
{
background-image: url("hilite.png");
background-repeat: no-repeat;
background-position: left top;
border: thin solid #888888;
background-color: #eeeeee;
padding: 4px;
text-align: left;
vertical-align: center;
font-size: 12;
}
hr
{
border: 0;
background-color: #000000;
width: 80%;
height: 1;
}
dl
{
background-image: url("hilite.png");
background-repeat: no-repeat;
background-position: left top;
border: thin solid #aaaaaa;
background-color: #eeeeee;
padding: 4px;
text-align: left;
vertical-align: center;
font-size: 12;
}
em
{
color: #334466;
font-family: courier;
font-size: 10;
font-style: normal;
}
div.nav
{
border: thin solid #000000;
background-color: #ffffff;
padding: 1px;
text-align: center;
vertical-align: center;
font-size: 12;
}
div.body
{
border: thin solid #000000;
background-color: #ffffff;
padding: 4px;
text-align: left;
font-size: 10;
}
div.diag
{
border: thin solid #888888;
background-color: #eeeeee;
padding: 4px;
text-align: center;
font-size: 8;
}

View File

@ -0,0 +1,2 @@
</body>
</html>

View File

@ -0,0 +1,19 @@
<html>
<head>
<title>$title</title>
<link href=ecore.css rel=stylesheet type=text/css>
</head>
<body>
<div class=nav>
<table border=0 align=center><tr>
<td width=16><img src=ecore_mini.png width=16 height=16 alt=E></td>
<td width=100% align=center>
E : C : O : R : E
</td>
<td width=16><img src=ecore_mini.png width=16 height=16 alt=E></td>
</tr></table>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -0,0 +1,59 @@
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
exec_prefix_set=no
usage="\
Usage: ecore-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]"
if test $# -eq 0; then
echo "${usage}" 1>&2
exit 1
fi
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
if test $exec_prefix_set = no ; then
exec_prefix=$optarg
fi
;;
--prefix)
echo $prefix
;;
--exec-prefix=*)
exec_prefix=$optarg
exec_prefix_set=yes
;;
--exec-prefix)
echo $exec_prefix
;;
--version)
echo @VERSION@
;;
--cflags)
if test @includedir@ != /usr/include ; then
includes=-I@includedir@
fi
echo $includes
;;
--libs)
libdirs=-L@libdir@
echo $libdirs -lecore @ecore_job_libs@ @ecore_x_libs@ @ecore_evas_libs@ @ecore_con_libs@ @ecore_ipc_libs@ @ecore_fb_libs@ -lm
;;
*)
echo "${usage}" 1>&2
exit 1
;;
esac
shift
done
exit 0

235
legacy/ecore/ecore.c.in Normal file
View File

@ -0,0 +1,235 @@
/**
@file
@brief Ecore Library Public API Calls
These routines are used for Ecore Library interaction
*/
/**
@mainpage Ecore
@image latex ecore_big.eps width=5cm
@image html ecore.png
@version 1.0.0
@author Carsten Haitzler <raster@rasterman.com>
@date 2000-2003
@section intro What is Ecore?
Ecore is a clean and tiny event loop library with many modules to do lots of
convenient things for a programmer, to save time and effort.
It's small and lean, designed to work on embedded systems all the way to
large and powerful multi-cpu workstations. It serialises all system signals,
events etc. into a single event queue, that is easily processed without
needing to worry about concurrency. A properly written, event-driven program
using this kind of programming doesn't need threads, nor has to worry about
concurrency. It turns a program into a state machine, and makes it very
robust and easy to follow.
Ecore gives you other handy primitives, such as timers to tick over for you
and call specified functions at particular times so the programmer can use
this to do things, like animate, or time out on connections or tasks that take
too long etc.
Idle handlers are provided too, as well as calls on entering an idle state
(often a very good time to update the state of the program). All events that
enter the system are passed to specific callback functions that the program
sets up to handle those events. Handling them is simple and other Ecore
modules produce more events on the queue, coming from other sources such as
file descriptors etc.
Ecore also lets you have functions called when file descriptors become active
for reading or writing, allowing for streamlined, non-blocking IO.
Here is an exmaple of a simple program and its basic event loop flow:
@image html prog_flow.png
@section work How does Ecore work?
Ecore is very easy to learn and use. All the function calls are designed to
be easy to remember, explicit in describing what they do, and heavily
name-spaced. Ecore programs can start and be very simple.
For example:
@code
#include <Ecore.h>
int main(int argc, const char **argv)
{
ecore_init();
ecore_app_args_set(argc, argv);
ecore_main_loop_begin();
ecore_shutdown();
return 0;
}
@endcode
This program is very simple and does't check for errors, but it does start up
and begin a main loop waiting for events or timers to tick off. This program
doesn't set up any, but now we can expand on this simple program a little
more by adding some event handlers and timers.
@code
#include <Ecore.h>
Ecore_Timer *timer1 = NULL;
Ecore_Event_Handler *handler1 = NULL;
double start_time = 0.0;
int timer_func(void *data)
{
printf("Tick timer. Sec: %3.2f\n", ecore_time_get() - start_time);
return 1;
}
int exit_func(int ev_type, void *ev, void *data)
{
Ecore_Event_Signal_Exit *e;
e = (Ecore_Event_Signal_Exit *)ev;
if (e->interrupt) printf("Exit: interrupt\n");
else if (e->quit) printf("Exit: quit\n");
else if (e->terminate) printf("Exit: terminate\n");
ecore_main_loop_quit();
return 1;
}
int main(int argc, const char **argv)
{
ecore_init();
ecore_app_args_set(argc, argv);
start_time = ecore_time_get();
handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL);
timer1 = ecore_timer_add(0.5, timer_func, NULL);
ecore_main_loop_begin();
ecore_shutdown();
return 0;
}
@endcode
In the previous example, we initialize our application and get the time at which
our program has started so we can calculate an offset. We set up a timer to
tick off in 0.5 seconds, and since it returns 1, will keep ticking off every
0.5 seconds until it returns 0, or is deleted by hand. An event handler is set
up to call a function - exit_func(), whenever an event of type
ECORE_EVENT_SIGNAL_EXIT is received (CTRL-C on the command line will cause
such an event to happen). If this event occurs it tells you what kind of
exit signal was received, and asks the main loop to quit when it is finished
by calling ecore_main_loop_quit().
The handles returned by ecore_timer_add() and ecore_event_handler_add() are
only stored here as an example. If you don't need to address the timer or
event handler again you don't need to store the result, so just call the
function, and don't assign the result to any variable.
This program looks slightly more complex than needed to do these simple
things, but in principle, programs don't get any more complex. You add more
event handlers, for more events, will have more timers and such, BUT it all
follows the same principles as shown in this example.
@section compiling How to compile using Ecore?
This section has to be documented. Below is just a quick line to handle all
Ecore modules at once.
@verbatim
gcc *.c \
-I/usr/local/include -I/usr/X11R6/include \
-L/usr/local/lib -L/usr/X11R6/lib \
-lecore -lecore_evas -lecore_x -lecore_fb -lecore_job \
`evas-config --cflags --libs`
@endverbatim
@section install How is it installed?
Suggested configure options for evas for a Linux desktop X display:
@verbatim
./configure \
--enable-ecore-x \
--enable-ecore-fb \
--enable-ecore-evas \
--enable-ecore-evas-gl \
--enable-ecore-job
make CFLAGS="-O9 -mpentiumpro -march=pentiumpro -mcpu=pentiumpro"
@endverbatim
@section tutorial Ecore Tutorial
You will find a more comprehensive @ref tut here, going through many examples
with tips and hints as to how best do some things.
@todo (1.0) Document API
*/
/** @page tut Ecore Tutorial
Here is a tutotial for using Ecore...
*/

198
legacy/ecore/ecore.m4 Normal file
View File

@ -0,0 +1,198 @@
# Configure paths for Ecore
# Conrad Parker 2001-01-24
# blatantly ripped from gtk.m4, Owen Taylor 97-11-3
dnl AM_PATH_ECORE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
dnl Test for Ecore, and define ECORE_CFLAGS and ECORE_LIBS
dnl
AC_DEFUN(AM_PATH_ECORE,
[dnl
dnl Get the cflags and libraries from the ecore-config script
dnl
AC_ARG_WITH(ecore-prefix,[ --with-ecore-prefix=PFX Prefix where Ecore is installed (optional)],
ecore_config_prefix="$withval", ecore_config_prefix="")
AC_ARG_WITH(ecore-exec-prefix,[ --with-ecore-exec-prefix=PFX Exec prefix where Ecore is installed (optional)],
ecore_config_exec_prefix="$withval", ecore_config_exec_prefix="")
AC_ARG_ENABLE(ecoretest, [ --disable-ecoretest Do not try to compile and run a test Ecore program],
, enable_ecoretest=yes)
if test x$ecore_config_exec_prefix != x ; then
ecore_config_args="$ecore_config_args --exec-prefix=$ecore_config_exec_prefix"
if test x${ECORE_CONFIG+set} != xset ; then
ECORE_CONFIG=$ecore_config_exec_prefix/bin/ecore-config
fi
fi
if test x$ecore_config_prefix != x ; then
ecore_config_args="$ecore_config_args --prefix=$ecore_config_prefix"
if test x${ECORE_CONFIG+set} != xset ; then
ECORE_CONFIG=$ecore_config_prefix/bin/ecore-config
fi
fi
AC_PATH_PROG(ECORE_CONFIG, ecore-config, no)
min_ecore_version=ifelse([$1], ,0.0.0,$1)
AC_MSG_CHECKING(for Ecore - version >= $min_ecore_version)
no_ecore=""
if test "$ECORE_CONFIG" = "no" ; then
no_ecore=yes
else
ECORE_CFLAGS=`$ECORE_CONFIG $ecore_config_args --cflags`
ECORE_LIBS=`$ECORE_CONFIG $ecore_config_args --libs`
ecore_config_major_version=`$ECORE_CONFIG $ecore_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
ecore_config_minor_version=`$ECORE_CONFIG $ecore_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
ecore_config_micro_version=`$ECORE_CONFIG $ecore_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
dnl **********************************************************************
dnl Ecore cannot currently report its own version ; version info is not
dnl given in Ecore.h
dnl Thus, the "enable_ecoretest" stuff is currently disabled, enable once
dnl you can determine the currently installed version by querying Ecore[.h]
dnl
dnl K. 2001-01-24
dnl **********************************************************************
dnl if test "x$enable_ecoretest" = "xyes" ; then
dnl ac_save_CFLAGS="$CFLAGS"
dnl ac_save_LIBS="$LIBS"
dnl CFLAGS="$CFLAGS $ECORE_CFLAGS"
dnl LIBS="$ECORE_LIBS $LIBS"
dnl dnl
dnl dnl Now check if the installed Ecore is sufficiently new. (Also sanity
dnl dnl checks the results of ecore-config to some extent
dnl dnl
dnl rm -f conf.ecoretest
dnl AC_TRY_RUN([
dnl #include <Ecore.h>
dnl #include <stdio.h>
dnl #include <stdlib.h>
dnl
dnl int
dnl main ()
dnl {
dnl int major, minor, micro;
dnl char *tmp_version;
dnl
dnl system ("touch conf.ecoretest");
dnl
dnl /* HP/UX 9 (%@#!) writes to sscanf strings */
dnl tmp_version = g_strdup("$min_ecore_version");
dnl if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
dnl printf("%s, bad version string\n", "$min_ecore_version");
dnl exit(1);
dnl }
dnl
dnl if ((ecore_major_version != $ecore_config_major_version) ||
dnl (ecore_minor_version != $ecore_config_minor_version) ||
dnl (ecore_micro_version != $ecore_config_micro_version))
dnl {
dnl printf("\n*** 'ecore-config --version' returned %d.%d.%d, but Ecore (%d.%d.%d)\n",
dnl $ecore_config_major_version, $ecore_config_minor_version, $ecore_config_micro_version,
dnl ecore_major_version, ecore_minor_version, ecore_micro_version);
dnl printf ("*** was found! If ecore-config was correct, then it is best\n");
dnl printf ("*** to remove the old version of Ecore. You may also be able to fix the error\n");
dnl printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
dnl printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
dnl printf("*** required on your system.\n");
dnl printf("*** If ecore-config was wrong, set the environment variable ECORE_CONFIG\n");
dnl printf("*** to point to the correct copy of ecore-config, and remove the file config.cache\n");
dnl printf("*** before re-running configure\n");
dnl }
dnl #if defined (ECORE_MAJOR_VERSION) && defined (ECORE_MINOR_VERSION) && defined (ECORE_MICRO_VERSION)
dnl else if ((ecore_major_version != ECORE_MAJOR_VERSION) ||
dnl (ecore_minor_version != ECORE_MINOR_VERSION) ||
dnl (ecore_micro_version != ECORE_MICRO_VERSION))
dnl {
dnl printf("*** Ecore header files (version %d.%d.%d) do not match\n",
dnl ECORE_MAJOR_VERSION, ECORE_MINOR_VERSION, ECORE_MICRO_VERSION);
dnl printf("*** library (version %d.%d.%d)\n",
dnl ecore_major_version, ecore_minor_version, ecore_micro_version);
dnl }
dnl #endif /* defined (ECORE_MAJOR_VERSION) ... */
dnl else
dnl {
dnl if ((ecore_major_version > major) ||
dnl ((ecore_major_version == major) && (ecore_minor_version > minor)) ||
dnl ((ecore_major_version == major) && (ecore_minor_version == minor) && (ecore_micro_version >= micro)))
dnl {
dnl return 0;
dnl }
dnl else
dnl {
dnl printf("\n*** An old version of Ecore (%d.%d.%d) was found.\n",
dnl ecore_major_version, ecore_minor_version, ecore_micro_version);
dnl printf("*** You need a version of Ecore newer than %d.%d.%d. The latest version of\n",
dnl major, minor, micro);
dnl printf("*** Ecore is always available from ftp://ftp.enlightenment.org.\n");
dnl printf("***\n");
dnl printf("*** If you have already installed a sufficiently new version, this error\n");
dnl printf("*** probably means that the wrong copy of the ecore-config shell script is\n");
dnl printf("*** being found. The easiest way to fix this is to remove the old version\n");
dnl printf("*** of Ecore, but you can also set the ECORE_CONFIG environment to point to the\n");
dnl printf("*** correct copy of ecore-config. (In this case, you will have to\n");
dnl printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
dnl printf("*** so that the correct libraries are found at run-time))\n");
dnl }
dnl }
dnl return 1;
dnl }
dnl ],, no_ecore=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
dnl CFLAGS="$ac_save_CFLAGS"
dnl LIBS="$ac_save_LIBS"
dnl fi
dnl **********************************************************************
fi
if test "x$no_ecore" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$ECORE_CONFIG" = "no" ; then
echo "*** The ecore-config script installed by Ecore could not be found"
echo "*** If Ecore was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the ECORE_CONFIG environment variable to the"
echo "*** full path to ecore-config."
else
if test -f conf.ecoretest ; then
:
else
echo "*** Could not run Ecore test program, checking why..."
CFLAGS="$CFLAGS $ECORE_CFLAGS"
LIBS="$LIBS $ECORE_LIBS"
AC_TRY_LINK([
#include <Ecore.h>
#include <stdio.h>
], [ return ((ecore_major_version) || (ecore_minor_version) || (ecore_micro_version)); ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding Ecore or finding the wrong"
echo "*** version of Ecore. If it is not finding Ecore, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
echo "***"
echo "*** If you have a RedHat 5.0 system, you should remove the Ecore package that"
echo "*** came with the system with the command"
echo "***"
echo "*** rpm --erase --nodeps ecore ecore-devel" ],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means Ecore was incorrectly installed"
echo "*** or that you have moved Ecore since it was installed. In the latter case, you"
echo "*** may want to edit the ecore-config script: $ECORE_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
ECORE_CFLAGS=""
ECORE_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(ECORE_CFLAGS)
AC_SUBST(ECORE_LIBS)
rm -f conf.ecoretest
])

72
legacy/ecore/ecore.spec Normal file
View File

@ -0,0 +1,72 @@
# this is NOT relocatable, unless you alter the patch!
%define name ecore
%define ver 1.0.0_pre4
%define rel 1
%define prefix /usr
Summary: Enlightened Core X interface library
Name: %{name}
Version: %{ver}
Release: %{rel}
Copyright: BSD
Group: User Interface/X
URL: http://www.enlightenment.org/efm.html
Packager: The Rasterman <raster@rasterman.com> Term <term@twistedpath.org>
Vendor: The Enlightenment Development Team <e-develop@enlightenment.org>
Source: ftp://ftp.enlightenment.org/enlightenment/%{name}-%{ver}.tar.gz
BuildRoot: /var/tmp/%{name}-root
%description
Ecore is brub.
%package devel
Summary: Ecore headers and development libraries.
Group: Development/Libraries
Requires: %{name} = %{ver}
%description devel
Ecore development files
%prep
%setup -q
%build
./configure \
--prefix=%{prefix} \
--enable-ecore-x \
--enable-ecore-evas \
--enable-ecore-job \
--enable-ecore-con \
--enable-ecore-ipc
make
%install
make DESTDIR=$RPM_BUILD_ROOT install
%post
/sbin/ldconfig
%postun
/sbin/ldconfig
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%attr(755,root,root) %{prefix}/lib/libecore*.so.*
%{prefix}/lib/libecore*.la
%attr(755,root,root) %{prefix}/bin/ecore_*
%{prefix}/share/ecore
%files devel
%defattr(-,root,root)
%attr(755,root,root) %{prefix}/lib/libecore*.so
%attr(755,root,root) %{prefix}/lib/libecore*.a
%attr(755,root,root) %{prefix}/bin/ecore-config
%{prefix}/include/Ecore*.h
%doc AUTHORS
%doc COPYING
%doc README
%doc ecore_docs.tar.gz

12
legacy/ecore/gendoc Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
cp ./ecore.c.in ./ecore.c
for I in `find ./src/lib -name "Ecore*.h" -print`; do
cat $I >> ./ecore.c
done
for I in `find ./src/lib -name "*.c" -print`; do
cat $I >> ./ecore.c
done
rm -rf ./doc/html ./doc/latex ./doc/man
doxygen
cp doc/img/*.png doc/html/
exit 0

View File

@ -0,0 +1,91 @@
#!/bin/sh
make clean distclean
./configure \
--enable-ecore-fb \
--enable-ecore-evas \
--enable-ecore-job \
--enable-ecore-con \
--enable-ecore-ipc
CC="/skiff/local/bin/arm-linux-gcc"
ST="/skiff/local/bin/arm-linux-strip"
CFLAGS="-O2"
rm -rf "build"
mkdir "build"
DST=`pwd`"/build";
mkdir $DST"/lib";
mkdir $DST"/bin";
mkdir $DST"/include";
mkdir $DST"/share";
mkdir $DST"/share/ecore";
pushd src
pushd lib
for I in ecore ecore_fb ecore_job ecore_evas ecore_con ecore_ipc; do
LIB=$I
pushd $LIB
$CC \
*.c \
$CFLAGS \
-I. -I../ecore -I../ecore_x -I../ecore_fb -I../ecore_job -I../ecore_evas -I../ecore_con -I../ecore_ipc \
-I../../.. \
-I/skiff/local/include \
-shared -fPIC -DPIC \
-Wl,-soname -Wl,"lib"$LIB".so.1" \
-o "lib"$LIB".so.1.0.0"
$ST -g "lib"$LIB".so.1.0.0"
rm -f "lib"$LIB".so"
ln -s "lib"$LIB".so.1.0.0" "lib"$LIB".so"
rm -f "lib"$LIB".so.1"
ln -s "lib"$LIB".so.1.0.0" "lib"$LIB".so.1"
rm -f "lib"$LIB".so.1.0"
ln -s "lib"$LIB".so.1.0.0" "lib"$LIB".so.1.0"
cp -a "lib"$LIB".so"* $DST"/lib";
cp -a Ecore*.h $DST"/include";
popd
done
popd
pushd bin
BIN="ecore_test"
$CC $BIN".c" \
-I../.. -I../lib \
-I. -I../lib/ecore -I../lib/ecore_x -I../lib/ecore_fb -I../lib/ecore_job -I../lib/ecore_evas -I../lib/ecore_con -I../lib/ecore_ipc \
-I/skiff/local/include \
-L. -L../lib/ecore -L../lib/ecore_x -L../lib/ecore_fb -L../lib/ecore_job -L../lib/ecore_evas -L../lib/ecore_con -L../lib/ecore_ipc \
-lecore -lecore_evas -lecore_fb -lecore_job -lecore_con -lecore_ipc -levas -lfreetype -ljpeg -lpng -lz -lm \
-o $BIN
$ST $BIN
cp -a $BIN $DST"/bin";
BIN="ecore_evas_test"
$CC \
ecore_evas_test.c \
ecore_evas_test_app.c \
ecore_evas_test_bg.c \
ecore_evas_test_calibrate.c \
-I../.. -I../lib \
-I. -I../lib/ecore -I../lib/ecore_x -I../lib/ecore_fb -I../lib/ecore_job -I../lib/ecore_evas -I../lib/ecore_con -I../lib/ecore_ipc \
-I/skiff/local/include \
-L. -L../lib/ecore -L../lib/ecore_x -L../lib/ecore_fb -L../lib/ecore_job -L../lib/ecore_evas -L../lib/ecore_con -L../lib/ecore_ipc \
-lecore -lecore_evas -lecore_fb -lecore_con -lecore_con -lecore_ipc -levas -lfreetype -ljpeg -lpng -lz -lm \
-o $BIN
$ST $BIN
cp -a $BIN $DST"/bin";
popd
popd
cp -ar data $DST"/share/ecore"
PD=`pwd`
pushd "build"
tar zcvf $PD"/data.tar.gz" *
pushd /skiff/local/
sudo tar zxvf $PD"/data.tar.gz"
popd
popd

916
legacy/ecore/src/Ecore.h Normal file
View File

@ -0,0 +1,916 @@
#ifndef E_CORE_H
#define E_CORE_H 1
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
#define XK_MISCELLANY 1
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <X11/keysymdef.h>
#include <X11/extensions/XShm.h>
#include <X11/extensions/shape.h>
#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif
#define XEV_NONE NoEventMask
#define XEV_KEY KeyPressMask | KeyReleaseMask
#define XEV_BUTTON ButtonPressMask | ButtonReleaseMask
#define XEV_KEY_PRESS KeyPressMask
#define XEV_KEY_RELEASE KeyReleaseMask
#define XEV_BUTTON_PRESS ButtonPressMask
#define XEV_BUTTON_RELEASE ButtonReleaseMask
#define XEV_IN_OUT EnterWindowMask | LeaveWindowMask
#define XEV_MOUSE_MOVE PointerMotionMask | ButtonMotionMask
#define XEV_EXPOSE ExposureMask
#define XEV_VISIBILITY VisibilityChangeMask
#define XEV_CONFIGURE StructureNotifyMask
#define XEV_CHILD_CHANGE SubstructureNotifyMask
#define XEV_CHILD_REDIRECT SubstructureRedirectMask | ResizeRedirectMask
#define XEV_FOCUS FocusChangeMask
#define XEV_PROPERTY PropertyChangeMask
#define XEV_COLORMAP ColormapChangeMask
#define ECORE_ATOM(atom, name) \
if (!atom) (atom) = ecore_atom_get(name);
#define MEMCPY(src, dst, type, num) \
memcpy(dst, src, sizeof(type) * (num))
#define NEW(type, num) \
malloc(sizeof(type) * (num))
#define ZERO(ptr, type, num) \
memset((ptr), 0, sizeof(type) * (num))
#define NEW_PTR(num) \
malloc(sizeof(void *) * (num))
#define FREE(ptr) \
{ \
free(ptr); \
(ptr) = NULL; \
}
#define IF_FREE(ptr) \
{if (ptr) FREE(ptr);}
#define REALLOC(ptr, type, num) \
{ \
if ((ptr) && (num == 0)) {free(ptr); ptr = NULL;} \
else if (ptr) ptr = realloc((ptr), sizeof(type) * (num)); \
else ptr = malloc(sizeof(type) * (num)); \
}
#define REALLOC_PTR(ptr, num) \
{ \
if ((ptr) && (num == 0)) {free(ptr); ptr = NULL;} \
else if (ptr) ptr = realloc(ptr, sizeof(void *) * (num)); \
else ptr = malloc(sizeof(void *) * (num)); \
}
#define START_LIST_DEL(type, base, cmp) \
type *_p, *_pp; _pp = NULL; \
_p = (base); \
while(_p) \
{ \
if (cmp) \
{ \
if (_pp) _pp->next = _p->next; \
else (base) = _p->next;
#define END_LIST_DEL \
return; \
} \
_pp = _p; \
_p = _p->next; \
}
#define DND_TYPE_URI_LIST 0
#define DND_TYPE_PLAIN_TEXT 1
#define DND_TYPE_MOZ_URL 2
#define DND_TYPE_NETSCAPE_URL 3
#ifdef __cplusplus
extern "C"
{
#endif
extern XContext xid_context;
typedef void (*Ecore_Error_Function) (Display * d, XErrorEvent * ev);
typedef struct _ecore_keygrab Ecore_KeyGrab;
typedef enum _ecore_ev_modifiers
{
ECORE_EVENT_KEY_MODIFIER_NONE = 0,
ECORE_EVENT_KEY_MODIFIER_SHIFT = (1 << 0),
ECORE_EVENT_KEY_MODIFIER_CTRL = (1 << 1),
ECORE_EVENT_KEY_MODIFIER_ALT = (1 << 2),
ECORE_EVENT_KEY_MODIFIER_WIN = (1 << 3)
} Ecore_Event_Key_Modifiers;
typedef enum _ecore_event_stack_detail
{
ECORE_EVENT_STACK_ABOVE = Above,
ECORE_EVENT_STACK_BELOW = Below,
ECORE_EVENT_STACK_TOP_IF = TopIf,
ECORE_EVENT_STACK_BOTTOM_IF = BottomIf,
ECORE_EVENT_STACK_OPPOSITE = Opposite
} Ecore_Event_Stack_Detail;
typedef enum _ecore_event_value_mask
{
ECORE_EVENT_VALUE_X = CWX,
ECORE_EVENT_VALUE_Y = CWY,
ECORE_EVENT_VALUE_W = CWWidth,
ECORE_EVENT_VALUE_H = CWHeight,
ECORE_EVENT_VALUE_BORDER = CWBorderWidth,
ECORE_EVENT_VALUE_SIBLING = CWSibling,
ECORE_EVENT_VALUE_STACKING = CWStackMode
} Ecore_Event_Value_Mask;
typedef enum _ecore_event_type
{
ECORE_EVENT_MOUSE_MOVE,
ECORE_EVENT_MOUSE_DOWN,
ECORE_EVENT_MOUSE_UP,
ECORE_EVENT_MOUSE_IN,
ECORE_EVENT_MOUSE_OUT,
ECORE_EVENT_MOUSE_WHEEL,
ECORE_EVENT_KEY_DOWN,
ECORE_EVENT_KEY_UP,
ECORE_EVENT_WINDOW_MAP,
ECORE_EVENT_WINDOW_UNMAP,
ECORE_EVENT_WINDOW_CREATE,
ECORE_EVENT_WINDOW_DESTROY,
ECORE_EVENT_WINDOW_CONFIGURE,
ECORE_EVENT_WINDOW_CONFIGURE_REQUEST,
ECORE_EVENT_WINDOW_MAP_REQUEST,
ECORE_EVENT_WINDOW_PROPERTY,
ECORE_EVENT_WINDOW_CIRCULATE,
ECORE_EVENT_WINDOW_CIRCULATE_REQUEST,
ECORE_EVENT_WINDOW_REPARENT,
ECORE_EVENT_WINDOW_EXPOSE,
ECORE_EVENT_WINDOW_VISIBILITY,
ECORE_EVENT_WINDOW_SHAPE,
ECORE_EVENT_WINDOW_FOCUS_IN,
ECORE_EVENT_WINDOW_FOCUS_OUT,
ECORE_EVENT_MESSAGE,
ECORE_EVENT_WINDOW_DELETE,
ECORE_EVENT_COLORMAP,
ECORE_EVENT_DND_DROP_REQUEST,
ECORE_EVENT_DND_DROP_END,
ECORE_EVENT_DND_DROP_POSITION,
ECORE_EVENT_DND_DROP,
ECORE_EVENT_DND_DROP_STATUS,
ECORE_EVENT_DND_DATA_REQUEST,
ECORE_EVENT_PASTE_REQUEST,
ECORE_EVENT_CLEAR_SELECTION,
ECORE_EVENT_CHILD,
ECORE_EVENT_USER,
ECORE_EVENT_MAX
} Ecore_Event_Type;
typedef struct _ecore_event
{
Ecore_Event_Type type;
char ignore;
void *event;
void (*ev_free) (void *evnt);
struct _ecore_event *next;
} Ecore_Event;
typedef struct _ecore_event_fd_handler
{
int fd;
void (*func) (int fd);
struct _ecore_event_fd_handler *next;
} Ecore_Event_Fd_Handler;
typedef struct _ecore_event_pid_handler
{
pid_t pid;
void (*func) (pid_t pid);
struct _ecore_event_pid_handler *next;
} Ecore_Event_Pid_Handler;
typedef struct _ecore_event_ipc_handler
{
int ipc;
void (*func) (int ipc);
struct _ecore_event_ipc_handler *next;
} Ecore_Event_Ipc_Handler;
typedef struct _ecore_event_timer
{
char *name;
void (*func) (int val, void *data);
int val;
void *data;
double in;
char just_added;
struct _ecore_event_timer *next;
} Ecore_Event_Timer;
typedef struct _ecore_event_key_down
{
Window win, root;
Ecore_Event_Key_Modifiers mods;
char *key;
char *compose;
Time time;
} Ecore_Event_Key_Down;
typedef struct _ecore_event_key_up
{
Window win, root;
Ecore_Event_Key_Modifiers mods;
char *key;
char *compose;
Time time;
} Ecore_Event_Key_Up;
typedef struct _ecore_event_mouse_down
{
Window win, root;
Ecore_Event_Key_Modifiers mods;
int button;
int x, y;
int rx, ry;
int double_click, triple_click;
Time time;
} Ecore_Event_Mouse_Down;
typedef struct _ecore_event_mouse_up
{
Window win, root;
Ecore_Event_Key_Modifiers mods;
int button;
int x, y;
int rx, ry;
Time time;
} Ecore_Event_Mouse_Up;
typedef struct _ecore_event_wheel
{
Window win, root;
Ecore_Event_Key_Modifiers mods;
int x, y, z;
int rx, ry;
Time time;
} Ecore_Event_Wheel;
typedef struct _ecore_event_mouse_move
{
Window win, root;
Ecore_Event_Key_Modifiers mods;
int x, y;
int rx, ry;
Time time;
} Ecore_Event_Mouse_Move;
typedef struct _ecore_event_window_enter
{
Window win, root;
int x, y;
int rx, ry;
Ecore_Event_Key_Modifiers mods;
Time time;
} Ecore_Event_Window_Enter;
typedef struct _ecore_event_window_leave
{
Window win, root;
int x, y;
int rx, ry;
Ecore_Event_Key_Modifiers mods;
Time time;
} Ecore_Event_Window_Leave;
typedef struct _ecore_event_window_focus_in
{
Window win, root;
int key_grab;
Time time;
} Ecore_Event_Window_Focus_In;
typedef struct _ecore_event_window_focus_out
{
Window win, root;
int key_grab;
Time time;
} Ecore_Event_Window_Focus_Out;
typedef struct _ecore_event_window_expose
{
Window win, root;
int x, y, w, h;
} Ecore_Event_Window_Expose;
typedef struct _ecore_event_window_visibility
{
Window win, root;
int fully_obscured;
} Ecore_Event_Window_Visibility;
typedef struct _ecore_event_window_create
{
Window win, root;
int override;
} Ecore_Event_Window_Create;
typedef struct _ecore_event_window_destroy
{
Window win, root;
} Ecore_Event_Window_Destroy;
typedef struct _ecore_event_window_map
{
Window win, root;
} Ecore_Event_Window_Map;
typedef struct _ecore_event_window_unmap
{
Window win, root;
} Ecore_Event_Window_Unmap;
typedef struct _ecore_event_window_map_request
{
Window win, root;
} Ecore_Event_Window_Map_Request;
typedef struct _ecore_event_window_reparent
{
Window win, root;
Window parent_from, parent;
} Ecore_Event_Window_Reparent;
typedef struct _ecore_event_window_configure
{
Window win, root;
int x, y, w, h;
int wm_generated;
} Ecore_Event_Window_Configure;
typedef struct _ecore_event_window_configure_request
{
Window win, root;
int x, y, w, h;
int border;
Window stack_win;
Ecore_Event_Stack_Detail detail;
Ecore_Event_Value_Mask mask;
} Ecore_Event_Window_Configure_Request;
typedef struct _ecore_event_window_circulate
{
Window win, root;
int lower;
} Ecore_Event_Window_Circulate;
typedef struct _ecore_event_window_circulate_request
{
Window win, root;
int lower;
} Ecore_Event_Window_Circulate_Request;
typedef struct _ecore_event_window_property
{
Window win, root;
Atom atom;
Time time;
} Ecore_Event_Window_Property;
typedef struct _ecore_event_window_shape
{
Window win, root;
Time time;
} Ecore_Event_Window_Shape;
typedef struct _ecore_event_message
{
Window win;
int format;
Atom atom;
union
{
char b[20];
short s[10];
long l[5];
}
data;
} Ecore_Event_Message;
typedef struct _ecore_event_colormap
{
Window win, root;
Colormap cmap;
int installed;
} Ecore_Event_Colormap;
typedef struct _ecore_event_window_delete
{
Window win, root;
} Ecore_Event_Window_Delete;
typedef struct _ecore_event_paste_request
{
Window win, root, source_win;
char *string;
} Ecore_Event_Paste_Request;
typedef struct _ecore_event_clear_selection
{
Window win, root;
Atom selection;
} Ecore_Event_Clear_Selection;
typedef struct _ecore_event_dnd_drop_request
{
Window win, root, source_win;
int num_files;
char **files;
int copy, link, move;
} Ecore_Event_Dnd_Drop_Request;
typedef struct _ecore_event_dnd_drop_end
{
Window win, root, source_win;
} Ecore_Event_Dnd_Drop_End;
typedef struct _ecore_event_dnd_drop_position
{
Window win, root, source_win;
int x, y;
} Ecore_Event_Dnd_Drop_Position;
typedef struct _ecore_event_dnd_drop
{
Window win, root, source_win;
} Ecore_Event_Dnd_Drop;
typedef struct _ecore_event_dnd_drop_status
{
Window win, root, source_win;
int x, y, w, h;
int copy, link, move, e_private;
int all_position_msgs;
int ok;
} Ecore_Event_Dnd_Drop_Status;
typedef struct _ecore_event_dnd_data_request
{
Window win, root, source_win;
Atom destination_atom;
int plain_text;
int uri_list;
int moz_url;
int netscape_url;
} Ecore_Event_Dnd_Data_Request;
typedef struct _ecore_event_child
{
pid_t pid;
int exit_code;
} Ecore_Event_Child;
typedef struct _ecore_event_user
{
int num;
int hup;
} Ecore_Event_User;
typedef struct _ecore_event_ipc_service
{
int service;
void (*func) (int fd);
struct _ecore_event_ipc_service *next;
} Ecore_Event_Ipc_Service;
typedef struct _ecore_xid
{
Window win;
Window parent;
Window root;
int children_num;
Window *children;
int x, y, w, h;
int mapped;
int mouse_in;
int depth;
int gravity;
int coords_invalid;
int bw;
int (*grab_button_auto_replay) (Ecore_Event_Mouse_Down *ev);
} Ecore_XID;
/* ---------------- API CALLS BELOW --------------------*/
/* ---------------- X WRAPPER CALLS */
int ecore_x_get_fd(void);
void ecore_set_error_handler(Ecore_Error_Function func);
void ecore_reset_error_handler(void);
/**
* ecore_display_init - Establishes a connection to the X server
* @display: The name of the display to connect to
*
* This function creates a connection to the X server. If
* @display is NULL, the name is taken from the $DISPLAY
* environment variable.
*/
int ecore_display_init(char *display);
int ecore_events_pending(void);
void ecore_get_next_event(XEvent * event);
int ecore_event_shape_get_id(void);
void ecore_sync(void);
void ecore_flush(void);
/* ---------------- WINDOW CHILD HANDLING */
void ecore_del_child(Window win, Window child);
void ecore_add_child(Window win, Window child);
void ecore_raise_child(Window win, Window child);
void ecore_lower_child(Window win, Window child);
Ecore_XID *ecore_add_xid(Window win, int x, int y, int w, int h,
int depth, Window parent);
Ecore_XID *ecore_validate_xid(Window win);
void ecore_unvalidate_xid(Window win);
/* ---------------- WINDOWS-RELATED CALLS */
Window ecore_window_new(Window parent, int x, int y, int w,
int h);
Window ecore_window_override_new(Window parent, int x, int y,
int w, int h);
Window ecore_window_input_new(Window parent, int x, int y, int w,
int h);
void ecore_window_set_events_propagate(Window win,
int propagate);
void ecore_window_show(Window win);
void ecore_window_hide(Window win);
void ecore_window_set_background_pixmap(Window win,
Pixmap pmap);
void ecore_window_set_shape_mask(Window win, Pixmap mask);
void ecore_window_add_shape_mask(Window win, Pixmap mask);
void ecore_window_set_shape_window(Window win, Window src,
int x, int y);
void ecore_window_add_shape_window(Window win, Window src,
int x, int y);
void ecore_window_set_shape_rectangle(Window win, int x, int y,
int w, int h);
void ecore_window_add_shape_rectangle(Window win, int x, int y,
int w, int h);
void ecore_window_set_shape_rectangles(Window win,
XRectangle * rect,
int num);
void ecore_window_add_shape_rectangles(Window win,
XRectangle * rect,
int num);
void ecore_window_clip_shape_by_rectangle(Window win, int x,
int y, int w, int h);
XRectangle *ecore_window_get_shape_rectangles(Window win, int *num);
void ecore_window_select_shape_events(Window win);
void ecore_window_unselect_shape_events(Window win);
void ecore_window_clear(Window win);
void ecore_window_clear_area(Window win, int x, int y, int w,
int h);
void ecore_window_set_events(Window win, long mask);
void ecore_window_remove_events(Window win, long mask);
void ecore_window_add_events(Window win, long mask);
void ecore_window_move(Window win, int x, int y);
void ecore_window_resize(Window win, int w, int h);
void ecore_window_move_resize(Window win, int x, int y, int w,
int h);
void ecore_window_destroy(Window win);
void ecore_window_reparent(Window win, Window parent, int x,
int y);
void ecore_window_raise(Window win);
void ecore_window_lower(Window win);
void ecore_window_get_geometry(Window win, int *x, int *y,
int *w, int *h);
int ecore_window_get_depth(Window win);
int ecore_window_exists(Window win);
Window ecore_window_get_parent(Window win);
Window *ecore_window_get_children(Window win, int *num);
int ecore_window_mouse_in(Window win);
void ecore_window_mouse_set_in(Window win, int in);
Window ecore_window_get_root(Window win);
void ecore_window_set_delete_inform(Window win);
void ecore_window_property_set(Window win, Atom type,
Atom format, int size,
void *data, int number);
void *ecore_window_property_get(Window win, Atom type,
Atom format, int *size);
void ecore_window_dnd_advertise(Window win);
void ecore_window_ignore(Window win);
void ecore_window_no_ignore(Window win);
int ecore_window_is_ignored(Window win);
Window ecore_window_get_at_xy(int x, int y);
int ecore_window_dnd_capable(Window win);
void ecore_window_dnd_handle_motion(Window source_win, int x,
int y, int dragging);
void ecore_window_dnd_ok(int ok);
void ecore_window_dnd_finished(void);
void ecore_window_dnd_send_status_ok(Window source_win,
Window win, int x, int y,
int w, int h);
void ecore_window_dnd_send_finished(Window source_win,
Window win);
void ecore_window_set_title(Window win, char *title);
void ecore_window_set_name_class(Window win, char *name,
char *);
void ecore_window_get_name_class(Window win, char **name,
char **name_class);
char *ecore_window_get_machine(Window win);
char *ecore_window_get_command(Window win);
char *ecore_window_get_icon_name(Window win);
void ecore_window_get_hints(Window win, int *accepts_focus,
int *initial_state,
Pixmap * icon_pixmap,
Pixmap * icon_mask,
Window * icon_window,
Window * window_group);
void ecore_window_set_min_size(Window win, int w, int h);
void ecore_window_set_max_size(Window win, int w, int h);
void ecore_window_set_xy_hints(Window win, int x, int y);
void ecore_window_get_frame_size(Window win, int *l, int *r,
int *t, int *b);
int ecore_window_save_under(Window win);
void ecore_window_hint_set_layer(Window win, int layer);
void ecore_window_hint_set_sticky(Window win, int sticky);
void ecore_window_hint_set_borderless(Window win);
int ecore_window_get_gravity(Window win);
void ecore_window_gravity_reset(Window win);
void ecore_window_gravity_set(Window win, int gravity);
void ecore_window_bit_gravity_set(Window win, int gravity);
void ecore_window_get_root_relative_location(Window win,
int *x, int *y);
void ecore_window_send_event_move_resize(Window win, int x,
int y, int w, int h);
void ecore_window_send_client_message(Window win, Atom type,
int format, void *data);
void ecore_window_add_to_save_set(Window win);
void ecore_window_del_from_save_set(Window win);
void ecore_window_kill_client(Window win);
void ecore_window_set_border_width(Window win, int bw);
int ecore_window_get_border_width(Window win);
int ecore_window_get_wm_size_hints(Window win,
XSizeHints * hints,
int *mask);
int ecore_window_is_visible(Window win);
int ecore_window_is_normal(Window win);
/**
* ecore_window_is_manageable - Returns 1 if a window can be managed by the wm.
* @win: the window for which to query.
*
* This function returns 0 if the window is unmapped, should be ignored
* by the window manager or is of the InputOnly class, 1 otherwise.
*/
int ecore_window_is_manageable(Window win);
void ecore_windows_restack(Window * wins, int num);
void ecore_window_stack_above(Window win, Window above);
void ecore_window_stack_below(Window win, Window below);
char *ecore_window_get_title(Window win);
void ecore_window_button_grab_auto_replay_set(Window win,
int (*func) (Ecore_Event_Mouse_Down *ev));
void *ecore_window_button_grab_auto_replay_get(Window win);
Window ecore_window_root(void);
void ecore_window_get_virtual_area(Window win, int *area_x,
int *area_y);
/* ---------------- PIXMAP CALLS */
Pixmap ecore_pixmap_new(Window win, int w, int h, int dep);
void ecore_pixmap_free(Pixmap pmap);
/* ---------------- POINTER CALLS */
void ecore_pointer_xy(Window win, int *x, int *y);
void ecore_pointer_xy_set(int x, int y);
void ecore_pointer_xy_get(int *x, int *y);
void ecore_pointer_warp_by(int dx, int dy);
void ecore_pointer_warp_to(int x, int y);
void ecore_pointer_replay(Time t);
void ecore_pointer_grab(Window win, Time t);
void ecore_pointer_ungrab(Time t);
/* ---------------- KEYBOARD-RELATED CALLS */
KeySym ecore_key_get_keysym_from_keycode(KeyCode keycode);
char *ecore_key_get_string_from_keycode(KeyCode keycode);
void ecore_key_grab(char *key, Ecore_Event_Key_Modifiers mods,
int anymod, int sync);
void ecore_key_ungrab(char *key,
Ecore_Event_Key_Modifiers mods,
int anymod);
KeyCode ecore_key_get_keycode(char *key);
char *ecore_keypress_translate_into_typeable(Ecore_Event_Key_Down * e);
void ecore_event_allow(int mode, Time t);
/* ---------------- LOCKS AND MODIFIER CALLS */
int ecore_lock_mask_scroll_get(void);
int ecore_lock_mask_num_get(void);
int ecore_lock_mask_caps_get(void);
void ecore_lock_scroll_set(int onoff);
int ecore_lock_scroll_get(void);
void ecore_lock_num_set(int onoff);
int ecore_lock_num_get(void);
void ecore_lock_caps_set(int onoff);
int ecore_lock_caps_get(void);
int ecore_mod_mask_shift_get(void);
int ecore_mod_mask_ctrl_get(void);
int ecore_mod_mask_alt_get(void);
int ecore_mod_mask_win_get(void);
void ecore_mod_shift_set(int onoff);
int ecore_mod_shift_get(void);
void ecore_mod_ctrl_set(int onoff);
int ecore_mod_ctrl_get(void);
void ecore_mod_alt_set(int onoff);
int ecore_mod_alt_get(void);
void ecore_mod_win_set(int onoff);
int ecore_mod_win_get(void);
int ecore_lock_mask_get(void);
int ecore_modifier_mask_get(void);
Window ecore_get_key_grab_win(void);
Display *ecore_display_get(void);
void ecore_focus_window_set(Window win);
Window ecore_focus_window_get(void);
void ecore_focus_to_window(Window win);
void ecore_focus_mode_reset(void);
Atom ecore_atom_get(char *name);
/* ---------------- GRABBING/UNGRABBING CALLS */
/**
* ecore_grab - Grabs the X server connection
*
* This function wraps XGrabServer, which prevents all other
* clients from receiving events. Calls are reference-counted.
*/
void ecore_grab(void);
/**
* ecore_ungrab - Ungrabs the X server connection
*
* This function releases the server, provided that ecore_grab()
* has been called the same number of times as ecore_ungrab().
*/
void ecore_ungrab(void);
void ecore_grab_mouse(Window win, int confine, Cursor cursor);
void ecore_ungrab_mouse(void);
Window ecore_grab_window_get(void);
void ecore_button_grab(Window win, int button, int events,
Ecore_Event_Key_Modifiers mod,
int any_mod);
void ecore_button_ungrab(Window win, int button,
Ecore_Event_Key_Modifiers mod,
int any_mod);
void ecore_keyboard_grab(Window win);
void ecore_keyboard_ungrab(void);
Window ecore_keyboard_grab_window_get(void);
/* ----------------- GRAPHICS CONTEXT AND DRAWING CALLS */
GC ecore_gc_new(Drawable d);
void ecore_gc_free(GC gc);
void ecore_gc_set_fg(GC gc, int val);
void ecore_gc_set_include_inferiors(GC gc);
void ecore_fill_rectangle(Drawable d, GC gc, int x, int y,
int w, int h);
void ecore_draw_rectangle(Drawable d, GC gc, int x, int y,
int w, int h);
void ecore_draw_line(Drawable d, GC gc, int x1, int y1, int x2,
int y2);
void ecore_draw_point(Drawable d, GC gc, int x, int y);
void ecore_area_copy(Drawable src, Drawable dest, GC gc,
int sx, int sy, int sw, int sh, int dx,
int dy);
/* ---------------- DRAG AND DROP CALLS */
int ecore_dnd_selection_convert(Window win, Window req,
Atom type);
void *ecore_dnd_selection_get(Window win, Window req, Atom type,
int *size);
void ecore_dnd_set_data(Window win);
void ecore_dnd_set_action(Window win);
void ecore_dnd_send_data(Window win, Window source_win,
void *data, int size, Atom dest_atom,
int type);
void ecore_dnd_set_mode_copy(void);
void ecore_dnd_set_mode_link(void);
void ecore_dnd_set_mode_move(void);
void ecore_dnd_set_mode_ask(void);
void ecore_dnd_own_selection(Window win);
void ecore_dnd_send_drop(Window win, Window source_win);
void ecore_get_virtual_area(int *area_x, int *area_y);
void ecore_clear_target_status(void);
/* ---------------- IPC CALLS */
void ecore_event_ipc_init(char *path);
void ecore_event_ipc_cleanup(void);
void ecore_add_ipc_service(int service, void (*func) (int fd));
void ecore_del_ipc_service(int service);
/* ---------------- SELECTION CALLS */
char *ecore_selection_get_data(Window win, Atom prop);
Window ecore_selection_request(void);
Window ecore_selection_set(char *string);
/* ---------------- CURSOR LOOK CALLS */
void ecore_set_blank_pointer(Window w);
Cursor ecore_cursor_new(Pixmap pmap, Pixmap mask, int x, int y,
int fr, int fg, int fb, int br, int bg,
int bb);
void ecore_cursor_free(Cursor c);
void ecore_cursor_set(Window win, Cursor c);
/* ---------------- EVENT-HANDLING CALLS */
void ecore_add_event(Ecore_Event_Type type, void *event,
void (*ev_free) (void *event));
void ecore_del_event(void *event);
void ecore_del_all_events(void);
Ecore_Event *ecore_get_last_event(void);
void ecore_add_event_fd(int fd, void (*func) (int fd));
void ecore_del_event_fd(int fd);
void ecore_add_event_pid(pid_t pid, void (*func) (pid_t pid));
void ecore_del_event_pid(pid_t pid);
void ecore_add_event_ipc(int ipc, void (*func) (int ipc));
void ecore_del_event_ipc(int ipc);
void ecore_event_loop(void);
void ecore_event_loop_quit(void);
void ecore_add_event_timer(char *name, double in,
void (*func) (int val, void *data),
int val, void *data);
void *ecore_del_event_timer(char *name);
void ecore_event_filter(Ecore_Event * ev);
void ecore_event_filter_events_handle(Ecore_Event * ev);
void ecore_event_filter_idle_handle(void);
/**
* ecore_event_filter_init - Setup event handlers
*
* This function initializes all ECORE_EVENT_MAX
* event handler to be empty.
*/
void ecore_event_filter_init(void);
void ecore_event_filter_handler_add(Ecore_Event_Type type,
void (*func) (Ecore_Event *ev));
void ecore_event_filter_idle_handler_add(void (*func) (void *data), void *data);
/**
* ecore_event_signal_init - Setup for default signal handlers
*
* This function initializes signal handlers for various
* signals via sigaction().
*/
void ecore_event_signal_init(void);
int ecore_event_signal_events_pending(void);
/**
* ecore_event_x_init - Ecore X initialization
*
* This function initializes Ecore's X event handling
* callbacks.
*/
void ecore_event_x_init(void);
/* ---------------- MISCELLANEOUS CALLS */
double ecore_get_time(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,12 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = lib bin
EXTRA_DIST = \
e_ev_filter.c \
e_ev_signal.c \
e_ev_x.c \
e_events.c \
e_ipc.c \
e_util.c \
e_x.c

View File

@ -0,0 +1,112 @@
## Process this file with automake to produce Makefile.in
if BUILD_ECORE_EVAS
ECORE_EVAS_LIB = $(top_builddir)/src/lib/ecore_evas/libecore_evas.la
else
ECORE_EVAS_LIB =
endif
if BUILD_ECORE_X
ECORE_X_LIB = $(top_builddir)/src/lib/ecore_x/libecore_x.la
else
ECORE_X_LIB =
endif
if BUILD_ECORE_FB
ECORE_FB_LIB = $(top_builddir)/src/lib/ecore_fb/libecore_fb.la
else
ECORE_FB_LIB =
endif
if BUILD_ECORE_JOB
ECORE_JOB_LIB = $(top_builddir)/src/lib/ecore_job/libecore_job.la
else
ECORE_JOB_LIB =
endif
if BUILD_ECORE_CON
ECORE_CON_LIB = $(top_builddir)/src/lib/ecore_con/libecore_con.la
else
ECORE_CON_LIB =
endif
if BUILD_ECORE_IPC
ECORE_IPC_LIB = $(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la
else
ECORE_IPC_LIB =
endif
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/ecore_evas \
-I$(top_srcdir)/src/lib/ecore_x \
-I$(top_srcdir)/src/lib/ecore_fb \
-I$(top_srcdir)/src/lib/ecore_job \
-I$(top_srcdir)/src/lib/ecore_con \
-I$(top_srcdir)/src/lib/ecore_ipc \
@evas_cflags@ \
@x_cflags@
bin_PROGRAMS = \
ecore_test \
ecore_evas_test
ecore_test_SOURCES = \
ecore_test.c
ecore_test_LDADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(ECORE_JOB_LIB) \
$(ECORE_FB_LIB) \
$(ECORE_X_LIB) \
$(ECORE_EVAS_LIB) \
$(ECORE_CON_LIB) \
$(ECORE_IPC_LIB) \
-lm
ecore_test_LDFLAGS =
ecore_test_CFLAGS = \
$(CFLAGS) \
$(INCLUDES)
ecore_test_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(ECORE_JOB_LIB) \
$(ECORE_FB_LIB) \
$(ECORE_X_LIB) \
$(ECORE_EVAS_LIB) \
$(ECORE_CON_LIB) \
$(ECORE_IPC_LIB)
ecore_evas_test_SOURCES = \
ecore_evas_test.c \
ecore_evas_test_app.c \
ecore_evas_test_bg.c \
ecore_evas_test_calibrate.c \
ecore_evas_test.h
ecore_evas_test_LDADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(ECORE_JOB_LIB) \
$(ECORE_FB_LIB) \
$(ECORE_X_LIB) \
$(ECORE_EVAS_LIB) \
$(ECORE_CON_LIB) \
$(ECORE_IPC_LIB) \
-lm
ecore_evas_test_LDFLAGS =
ecore_evas_test_CFLAGS = \
$(CFLAGS) \
$(INCLUDES)
ecore_evas_test_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(ECORE_JOB_LIB) \
$(ECORE_FB_LIB) \
$(ECORE_X_LIB) \
$(ECORE_EVAS_LIB) \
$(ECORE_CON_LIB) \
$(ECORE_IPC_LIB)

View File

@ -0,0 +1,27 @@
#include "ecore_evas_test.h"
#ifdef BUILD_ECORE_EVAS
int
main(int argc, const char **argv)
{
if (app_start(argc, argv) < 1) return -1;
bg_start();
calibrate_start();
ecore_main_loop_begin();
app_finish();
return 0;
}
#else
int
main(int argc, const char **argv)
{
printf("Ecore_evas module not compiled. This program is empty.\n");
return -1;
}
#endif

View File

@ -0,0 +1,36 @@
#ifndef _ECORE_EVAS_TEST_H
#define _ECORE_EVAS_TEST_H
#include "config.h"
#include "Ecore.h"
#include <math.h>
#ifdef BUILD_ECORE_EVAS
#include "Ecore_Evas.h"
#include "Ecore_Fb.h"
#define IM PACKAGE_DATA_DIR"/data/images/"
#define PT PACKAGE_DATA_DIR"/data/pointers/"
#define FN PACKAGE_DATA_DIR"/data/fonts/"
extern double start_time;
extern Ecore_Evas *ee;
extern Evas *evas;
void calibrate_pos_set(int pos);
int calibrate_pos_get(void);
void calibrate_finish(void);
void calibrate_start(void);
void bg_resize(double w, double h);
void bg_start(void);
void bg_go(void);
int app_start(int argc, const char **argv);
void app_finish(void);
#endif
#endif

View File

@ -0,0 +1,91 @@
#include "ecore_evas_test.h"
#ifdef BUILD_ECORE_EVAS
double start_time = 0.0;
Ecore_Evas *ee = NULL;
Evas *evas = NULL;
static void app_resize(Ecore_Evas *ee);
static int app_signal_exit(void *data, int ev_type, void *ev);
static void app_delete_request(Ecore_Evas *ee);
int
app_start(int argc, const char **argv)
{
/* init the app */
start_time = ecore_time_get();
ecore_init();
ecore_app_args_set(argc, argv);
ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL);
/* create an evas */
if (!ecore_evas_init()) return -1;
if ((argc > 1) && (!strcmp(argv[1], "-fb")))
ee = ecore_evas_fb_new(NULL, 0, 240, 320);
else if ((argc > 1) && (!strcmp(argv[1], "-x")))
ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 240, 320);
else if ((argc > 1) && (!strcmp(argv[1], "-gl")))
ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 240, 320);
else if ((argc > 1) && (!strcmp(argv[1], "-h")))
{
printf("%s -x Test ecore_evas in X (default)\n"
"%s -gl Test ecore_evas in X GL\n"
"%s -fb Test ecore_evas in the Framebuffer\n"
"%s -h Display this help\n",
argv[0], argv[0], argv[0], argv[0]);
ecore_evas_shutdown();
ecore_shutdown();
return 0;
}
else
#ifdef BUILD_ECORE_X
ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 240, 320);
#else
#ifdef BUILD_ECORE_FB
ee = ecore_evas_fb_new(NULL, 270, 240, 320);
#endif
#endif
if (!ee) return -1;
ecore_evas_callback_delete_request_set(ee, app_delete_request);
ecore_evas_callback_resize_set(ee, app_resize);
ecore_evas_title_set(ee, "Ecore Evas Test");
ecore_evas_name_class_set(ee, "ecore_test", "test_evas");
ecore_evas_show(ee);
evas = ecore_evas_get(ee);
evas_image_cache_set(evas, 8192 * 1024);
evas_font_cache_set(evas, 512 * 1024);
evas_font_path_append(evas, FN);
return 1;
}
void
app_finish(void)
{
ecore_evas_shutdown();
ecore_shutdown();
}
static void
app_resize(Ecore_Evas *ee)
{
double w, h;
evas_output_viewport_get(evas, NULL, NULL, &w, &h);
bg_resize(w, h);
}
static int
app_signal_exit(void *data, int ev_type, void *ev)
{
ecore_main_loop_quit();
return 1;
}
static void
app_delete_request(Ecore_Evas *ee)
{
ecore_main_loop_quit();
}
#endif

View File

@ -0,0 +1,403 @@
#include "ecore_evas_test.h"
#ifdef BUILD_ECORE_EVAS
Evas_Object *o_bg_rect = NULL;
Evas_Object *o_logo = NULL;
Ecore_Timer *anim_timer = NULL;
#define NUM 32
#define SIZE 32
#define SLIDE 80
Evas_Object *o_ball[NUM];
Evas_Object *o_shad[NUM];
Evas_Object *o_clip = NULL;
Evas_Object *o_bar[2];
Evas_Object *o_bar_shad_1[3];
Evas_Object *o_bar_shad_2[2];
Evas_Object *o_bg = NULL;
static int bg_animate_obj_timer(void *data);
static void bg_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
void
bg_resize(double w, double h)
{
evas_object_resize(o_bg_rect, w, h);
evas_object_move(o_logo, (w - 240) / 2, (h - 280) / 2);
bg_animate_obj_timer(NULL);
}
void
bg_start(void)
{
Evas_Object *o;
/* set up a big white rectangle on the bg */
o = evas_object_rectangle_add(evas);
evas_object_color_set(o, 255, 255, 255, 255);
evas_object_move(o, 0, 0);
evas_object_resize(o, 240, 320);
evas_object_layer_set(o, -1000000);
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, bg_cb_key_down, ee);
evas_object_focus_set(o, 1);
evas_object_show(o);
o_bg_rect = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"e_logo.png", NULL);
evas_object_resize(o, 240, 280);
evas_object_image_fill_set(o, 0, 0, 240, 280);
evas_object_move(o, (240 - 240) / 2, (320 - 280) / 2);
evas_object_layer_set(o, -999);
evas_object_pass_events_set(o, 1);
evas_object_show(o);
o_logo = o;
o = evas_object_rectangle_add(evas);
evas_object_color_set(o, 255, 255, 255, 255);
evas_object_resize(o, 240, 0);
evas_object_pass_events_set(o, 1);
evas_object_show(o);
o_clip = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bg.png", NULL);
evas_object_resize(o, 240, 320);
evas_object_image_fill_set(o, 0, 0, 240, 320);
evas_object_layer_set(o, -9999);
evas_object_move(o, 0, 0);
evas_object_clip_set(o, o_clip);
evas_object_pass_events_set(o, 1);
evas_object_show(o);
o_bg = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bar.png", NULL);
evas_object_image_border_set(o, 5, 5, 5, 5);
evas_object_resize(o, 240, 32);
evas_object_image_fill_set(o, 0, 0, 240, 32);
evas_object_layer_set(o, 100);
evas_object_pass_events_set(o, 1);
o_bar[0] = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bar.png", NULL);
evas_object_image_border_set(o, 5, 5, 5, 5);
evas_object_resize(o, 240, 32);
evas_object_image_fill_set(o, 0, 0, 240, 32);
evas_object_layer_set(o, 100);
evas_object_pass_events_set(o, 1);
o_bar[1] = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bar_shad_above.png", NULL);
evas_object_resize(o, 240, 8);
evas_object_image_fill_set(o, 0, 0, 240, 8);
evas_object_image_smooth_scale_set(o, 0);
evas_object_layer_set(o, 100);
evas_object_pass_events_set(o, 1);
o_bar_shad_1[0] = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bar_shad_below.png", NULL);
evas_object_resize(o, 240, 32);
evas_object_image_fill_set(o, 0, 0, 240, 32);
evas_object_image_smooth_scale_set(o, 0);
evas_object_layer_set(o, -100);
evas_object_pass_events_set(o, 1);
evas_object_clip_set(o, o_clip);
o_bar_shad_1[1] = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bar_shad_below.png", NULL);
evas_object_resize(o, 240, 16);
evas_object_image_fill_set(o, 0, 0, 240, 16);
evas_object_image_smooth_scale_set(o, 0);
evas_object_layer_set(o, 100);
evas_object_pass_events_set(o, 1);
evas_object_clip_set(o, o_clip);
o_bar_shad_1[2] = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bar_shad_above.png", NULL);
evas_object_resize(o, 240, 8);
evas_object_image_fill_set(o, 0, 0, 240, 8);
evas_object_image_smooth_scale_set(o, 0);
evas_object_layer_set(o, 100);
evas_object_pass_events_set(o, 1);
evas_object_clip_set(o, o_clip);
o_bar_shad_2[0] = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"bar_shad_below.png", NULL);
evas_object_resize(o, 240, 8);
evas_object_image_fill_set(o, 0, 0, 240, 8);
evas_object_image_smooth_scale_set(o, 0);
evas_object_layer_set(o, 100);
evas_object_pass_events_set(o, 1);
o_bar_shad_2[1] = o;
{
int i;
for (i = 0; i < NUM; i++)
{
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"ball.png", NULL);
evas_object_resize(o, SIZE, SIZE);
evas_object_image_fill_set(o, 0, 0, SIZE, SIZE);
evas_object_move(o, 0, 0);
evas_object_pass_events_set(o, 1);
evas_object_clip_set(o, o_clip);
o_ball[i] = o;
o = evas_object_image_add(evas);
evas_object_image_file_set(o, IM"shadow.png", NULL);
evas_object_resize(o, SIZE, SIZE);
evas_object_image_fill_set(o, 0, 0, SIZE, SIZE);
evas_object_move(o, 0, 0);
evas_object_pass_events_set(o, 1);
evas_object_clip_set(o, o_clip);
evas_object_lower(o);
o_shad[i] = o;
}
}
}
void
bg_go(void)
{
/* add a timer to animate them */
anim_timer = ecore_timer_add(0.01, bg_animate_obj_timer, NULL);
}
static int
bg_animate_obj_timer(void *data)
{
Evas_Object *o;
double x, y, sx, sy, v;
double w, h;
int ow, oh;
double t;
int l, m, n;
int i;
static double t_first = 0;
static int done = 0;
t = ecore_time_get() - start_time;
if (t_first == 0) t_first = t;
if (t - t_first > 2.0) done = 1;
evas_output_viewport_get(evas_object_evas_get(o_clip), NULL, NULL, &w, &h);
if (!done)
{
v = ((cos(((t - t_first) / 2) * 3.14159) - 1.0) / -2);
l = (SLIDE) * v;
}
else
{
l = SLIDE;
}
evas_object_move(o_bar[0], 0, (h / 2) - 32 - l);
evas_object_move(o_bar[1], 0, (h / 2) + l);
evas_object_move(o_bar_shad_1[0], 0, (h / 2) - 32 - l - 8);
evas_object_move(o_bar_shad_1[1], 0, (h / 2) - l);
evas_object_move(o_bar_shad_1[2], 0, (h / 2) - l);
evas_object_move(o_bar_shad_2[0], 0, (h / 2) + l - 8);
evas_object_move(o_bar_shad_2[1], 0, (h / 2) + 32 + l);
evas_object_resize(o_bar[0], w, 32);
evas_object_image_fill_set(o_bar[0], 0, 0, w, 32);
evas_object_resize(o_bar[1], w, 32);
evas_object_image_fill_set(o_bar[1], 0, 0, w, 32);
evas_object_resize(o_bar_shad_1[0], w, 8);
evas_object_image_fill_set(o_bar_shad_1[0], 0, 0, w, 8);
evas_object_resize(o_bar_shad_1[1], w, 32);
evas_object_image_fill_set(o_bar_shad_1[1], 0, 0, w, 32);
evas_object_resize(o_bar_shad_1[2], w, 16);
evas_object_image_fill_set(o_bar_shad_1[2], 0, 0, w, 16);
evas_object_resize(o_bar_shad_2[0], w, 8);
evas_object_image_fill_set(o_bar_shad_2[0], 0, 0, w, 8);
evas_object_resize(o_bar_shad_2[1], w, 8);
evas_object_image_fill_set(o_bar_shad_2[1], 0, 0, w, 8);
evas_object_move(o_clip, 0, (h / 2) - l);
evas_object_resize(o_clip, w, l * 2);
evas_object_resize(o_bg, w, h);
evas_object_image_fill_set(o_bg, 0, 0, w, h);
evas_object_show(o_bar[0]);
evas_object_show(o_bar[1]);
evas_object_show(o_bar_shad_1[0]);
evas_object_show(o_bar_shad_1[1]);
evas_object_show(o_bar_shad_1[2]);
evas_object_show(o_bar_shad_2[0]);
evas_object_show(o_bar_shad_2[1]);
for (i = 0; i < NUM; i++)
{
o = o_ball[i];
evas_output_viewport_get(evas_object_evas_get(o), NULL, NULL, &w, &h);
l = ((int)o / 179) & 0x0f;
v = (sin(t * (double)l / 12) + 1.0) / 2;
v = 0.25 + (0.75 * v);
m = 1 + (((int)o / 36) & 0x0f);
n = 1 + (((int)o / 763) & 0x0f);
ow = SIZE * v;
oh = SIZE * v;
evas_object_resize(o, ow, oh);
evas_object_image_fill_set(o, 0, 0, ow, oh);
x = sin(t * (double)m / 12) * ((w - ow) / 2);
y = sin(t * (double)n / 12) * ((h - oh) / 2);
evas_object_move(o, (w / 2) - (ow / 2) + x, (h / 2) - (oh / 2) + y);
evas_object_show(o);
o = o_shad[i];
evas_object_resize(o, ow, oh);
evas_object_image_fill_set(o, 0, 0, ow, oh);
sx = v * (((w - ow) / 2) + x) / 8;
sy = v * (((h - oh) / 2) + y) / 8;
evas_object_move(o,
(w / 2) - (ow / 2) + x + sx,
(h / 2) - (oh / 2) + y + sy);
evas_object_show(o);
}
return 1;
}
/* NB: on ipaq
*
* "F1" "F2" "F3" "F4"
* "Up"
* "Left" "Return" "Right"
* "Down"
*
*/
static void
bg_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Key_Down *ev;
ev = event_info;
if (!strcmp(ev->keyname, "Escape")) ecore_main_loop_quit();
if (!strcmp(ev->keyname, "q")) ecore_main_loop_quit();
if (!strcmp(ev->keyname, "Q")) ecore_main_loop_quit();
if ((!strcmp(ev->keyname, "f")) ||
(!strcmp(ev->keyname, "F1")))
{
if (!ecore_evas_fullscreen_get(ee))
ecore_evas_fullscreen_set(ee, 1);
else
ecore_evas_fullscreen_set(ee, 0);
}
if (!strcmp(ev->keyname, "o"))
{
if (!ecore_evas_override_get(ee))
ecore_evas_override_set(ee, 1);
else
ecore_evas_override_set(ee, 0);
}
if ((!strcmp(ev->keyname, "r")) ||
(!strcmp(ev->keyname, "F4")))
{
int r;
r = ecore_evas_rotation_get(ee);
if (r == 0) r = 90;
else if (r == 90) r = 270;
else if (r == 270) r = 0;
ecore_evas_rotation_set(ee, r);
}
if (!strcmp(ev->keyname, "b"))
{
if (!ecore_evas_borderless_get(ee))
ecore_evas_borderless_set(ee, 1);
else
ecore_evas_borderless_set(ee, 0);
}
if (!strcmp(ev->keyname, "d"))
{
if (!ecore_evas_avoid_damage_get(ee))
ecore_evas_avoid_damage_set(ee, 1);
else
ecore_evas_avoid_damage_set(ee, 0);
}
if (!strcmp(ev->keyname, "s"))
{
if (!ecore_evas_shaped_get(ee))
ecore_evas_shaped_set(ee, 1);
else
ecore_evas_shaped_set(ee, 0);
}
if (!strcmp(ev->keyname, "Up"))
{
#ifdef BUILD_ECORE_FB
double br;
br = ecore_fb_backlight_brightness_get();
ecore_fb_backlight_brightness_set(br + 0.1);
#endif
}
if (!strcmp(ev->keyname, "Down"))
{
#ifdef BUILD_ECORE_FB
double br;
br = ecore_fb_backlight_brightness_get();
ecore_fb_backlight_brightness_set(br - 0.1);
#endif
}
if (!strcmp(ev->keyname, "F2"))
{
#ifdef BUILD_ECORE_FB
if (ecore_fb_backlight_get())
ecore_fb_backlight_set(0);
else
ecore_fb_backlight_set(1);
#endif
}
if (!strcmp(ev->keyname, "F3"))
{
#ifdef BUILD_ECORE_FB
static int v = 0;
if (v) ecore_fb_led_set(0);
else ecore_fb_led_set(1);
if (!v) v = 1;
else v = 0;
#endif
}
if (!strcmp(ev->keyname, "Left"))
{
#ifdef BUILD_ECORE_FB
ecore_fb_led_blink_set(0.1);
#endif
}
if (!strcmp(ev->keyname, "Right"))
{
#ifdef BUILD_ECORE_FB
ecore_fb_led_blink_set(0.5);
#endif
}
if ((!strcmp(ev->keyname, "p")) ||
(!strcmp(ev->keyname, "Return")))
{
char *fl;
ecore_evas_cursor_get(ee, &fl, NULL, NULL, NULL);
if (!fl)
ecore_evas_cursor_set(ee, PT"mouse_pointer.png", 1000000, 2, 2);
else
ecore_evas_cursor_set(ee, NULL, 0, 0, 0);
#ifdef BUILD_ECORE_FB
printf("%3.3f\n", ecore_fb_light_sensor_get());
#endif
}
}
#endif

View File

@ -0,0 +1,284 @@
#include "ecore_evas_test.h"
#ifdef BUILD_ECORE_EVAS
static Evas_Object *o_events = NULL;
static Evas_Object *o_crosshair = NULL;
static Evas_Object *o_text = NULL;
static int cal_pos = 0;
static int down = 0;
static int cal_coords[] = {15, 15, -15, 15, 15, -15, -15, -15};
static char *cal_lines[] =
{
"Please click on the crosshair",
"Again please",
"And again",
"Last one, then calibration is complete"
};
static int cal_input[8];
static int tmp_input_count = 0;
static int tmp_input[16];
static void calibrate_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void calibrate_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void calibrate_cb_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
void
calibrate_pos_set(int pos)
{
double w, h;
int x, y, ow, oh;
cal_pos = pos;
evas_object_geometry_get(o_crosshair, NULL, NULL, &w, &h);
x = cal_coords[(cal_pos * 2) + 0];
y = cal_coords[(cal_pos * 2) + 1];
evas_output_size_get(evas, &ow, &oh);
if (x < 0) x = ow + x - 1;
if (y < 0) y = oh + y - 1;
cal_coords[(cal_pos * 2) + 0] = x;
cal_coords[(cal_pos * 2) + 1] = y;
evas_object_move(o_crosshair, x - (((int)w - 1) / 2), y - (((int)h - 1) / 2));
evas_object_text_text_set(o_text, cal_lines[cal_pos]);
evas_object_geometry_get(o_text, NULL, NULL, &w, &h);
evas_object_move(o_text, (ow - w) / 2, (oh - h) / 2);
}
int
calibrate_pos_get(void)
{
return cal_pos;
}
void
calibrate_finish(void)
{
int m0, m1;
int y0, y1;
int x[4], y[4], xi[4], yi[4];
int i, rot;
int xscale, xtrans, yscale, ytrans, xyswap;
rot = ecore_evas_rotation_get(ee);
for (i = 0; i < 4; i++)
{
x[i] = cal_coords[(i * 2) + 0];
y[i] = cal_coords[(i * 2) + 1];
xi[i] = cal_input[(i * 2) + 0];
yi[i] = cal_input[(i * 2) + 1];
}
xyswap = 0;
m0 = ((x[1] - x[0]) * 256) / (xi[1] - xi[0]);
y0 = ((x[1] - ((xi[1] * m0) / 256)) + (x[0] - ((xi[0] * m0) >> 8)) ) / 2;
m1 = ((x[3] - x[2]) * 256) / (xi[3] - xi[2]);
y1 = ((x[3] - ((xi[3] * m1) / 256)) + (x[2] - ((xi[2] * m1) >> 8)) ) / 2;
xscale = (m0 + m1) / 2;
xtrans = (y0 + y1) / 2;
m0 = ((y[2] - y[0]) * 256) / (yi[2] - yi[0]);
y0 = ((y[2] - ((yi[2] * m0) / 256)) + (y[0] - ((yi[0] * m0) >> 8)) ) / 2;
m1 = ((y[3] - y[1]) * 256) / (yi[3] - yi[1]);
y1 = ((y[3] - ((yi[3] * m1) / 256)) + (y[1] - ((yi[1] * m1) >> 8)) ) / 2;
yscale = (m0 + m1) / 2;
ytrans = (y0 + y1) / 2;
if (rot == 0)
{
#ifdef BUILD_ECORE_FB
ecore_fb_touch_screen_calibrate_set(xscale, xtrans, yscale, ytrans, xyswap);
#endif
}
else if (rot == 270)
{
int ow, oh;
evas_output_size_get(evas, &ow, &oh);
ytrans = oh - (ytrans + ((oh * yscale) / 256));
#ifdef BUILD_ECORE_FB
ecore_fb_touch_screen_calibrate_set(yscale, ytrans, xscale, xtrans, xyswap);
#endif
}
evas_object_del(o_crosshair);
evas_object_del(o_events);
evas_object_del(o_text);
o_crosshair = NULL;
o_events = NULL;
o_text = NULL;
cal_pos = 0;
bg_go();
}
void
calibrate_start(void)
{
Evas_Object *o;
#ifdef BUILD_ECORE_FB
ecore_fb_touch_screen_calibrate_set(256, 0, 256, 0, 0);
#endif
o = evas_object_rectangle_add(evas);
evas_object_layer_set(o, 1000000);
evas_object_color_set(o, 255, 255, 255, 120);
evas_object_move(o, -12000, -16000);
evas_object_resize(o, 24000, 32000);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, calibrate_cb_down, ee);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, calibrate_cb_up, ee);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, calibrate_cb_move, ee);
o_events = o;
o = evas_object_image_add(evas);
evas_object_layer_set(o, 1000001);
evas_object_image_file_set(o, IM"crosshair.png", NULL);
evas_object_resize(o, 31, 31);
evas_object_image_fill_set(o, 0, 0, 31, 31);
evas_object_pass_events_set(o, 1);
evas_object_show(o);
o_crosshair = o;
o = evas_object_text_add(evas);
evas_object_layer_set(o, 1000002);
evas_object_color_set(o, 0, 0, 0, 255);
evas_object_text_font_set(o, "helmet", 10);
evas_object_pass_events_set(o, 1);
evas_object_show(o);
o_text = o;
calibrate_pos_set(0);
}
static void
calibrate_cb_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Down *ev;
ev = event_info;
tmp_input_count = 0;
tmp_input[((tmp_input_count & 0x7) * 2) + 0] = ev->output.x;
tmp_input[((tmp_input_count & 0x7) * 2) + 1] = ev->output.y;
tmp_input_count++;
down = 1;
}
static void
calibrate_cb_up(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Up *ev;
int n, i, avx, avy, c, mx, my;
int dists[8];
int indexes[8];
int sorted;
ev = event_info;
down = 0;
tmp_input[((tmp_input_count & 0x7) * 2) + 0] = ev->output.x;
tmp_input[((tmp_input_count & 0x7) * 2) + 1] = ev->output.y;
tmp_input_count++;
n = 8;
if (tmp_input_count < 8) n = tmp_input_count;
avx = 0; avy = 0; c = 0;
for (i = 0; i < n; i++)
{
dists[i] = tmp_input[(i * 2) + 0];
indexes[i] = i;
}
sorted = 0;
while (!sorted)
{
sorted = 1;
for (i = 0; i < n - 1; i++)
{
if (dists[i + 1] < dists[i])
{
int tmp;
sorted = 0;
tmp = dists[i];
dists[i] = dists[i + 1];
dists[i + 1] = tmp;
tmp = indexes[i];
indexes[i] = indexes[i + 1];
indexes[i + 1] = tmp;
}
}
}
mx = dists[(n + 1) / 2];
for (i = 0; i < n; i++)
{
dists[i] = tmp_input[(i * 2) + 1];
indexes[i] = i;
}
sorted = 0;
while (!sorted)
{
sorted = 1;
for (i = 0; i < n - 1; i++)
{
if (dists[i + 1] < dists[i])
{
int tmp;
sorted = 0;
tmp = dists[i];
dists[i] = dists[i + 1];
dists[i + 1] = tmp;
tmp = indexes[i];
indexes[i] = indexes[i + 1];
indexes[i + 1] = tmp;
}
}
}
my = dists[(n + 1) / 2];
for (i = 0; i < n; i++)
{
int x, y, dx, dy;
x = tmp_input[(i * 2) + 0];
y = tmp_input[(i * 2) + 1];
dx = x - mx;
dy = y - my;
if (dx < 0) dx = -dx;
if (dy < 0) dy = -dy;
if ((dx <= 8) && (dy <= 8))
{
avx += tmp_input[(i * 2) + 0];
avy += tmp_input[(i * 2) + 1];
c++;
}
}
cal_input[(cal_pos * 2) + 0] = avx / c;
cal_input[(cal_pos * 2) + 1] = avy / c;
n = calibrate_pos_get();
if (n < 3)
{
calibrate_pos_set(n + 1);
return;
}
calibrate_finish();
}
static void
calibrate_cb_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Mouse_Move *ev;
ev = event_info;
if (!down) return;
tmp_input[((tmp_input_count & 0x7) * 2) + 0] = ev->cur.output.x;
tmp_input[((tmp_input_count & 0x7) * 2) + 1] = ev->cur.output.y;
tmp_input_count++;
}
#endif

View File

@ -0,0 +1,763 @@
#include "config.h"
#include "Ecore.h"
#ifdef BUILD_ECORE_JOB
#include "Ecore_Job.h"
#endif
#ifdef BUILD_ECORE_X
#include "Ecore_X.h"
#endif
#ifdef BUILD_ECORE_FB
#include "Ecore_Fb.h"
#endif
#ifdef BUILD_ECORE_EVAS
#include "Ecore_Evas.h"
#endif
#ifdef BUILD_ECORE_CON
#include "Ecore_Con.h"
#endif
#ifdef BUILD_ECORE_IPC
#include "Ecore_Ipc.h"
#endif
#include <math.h>
/* APP GLOBALS */
double start_time = 0;
int
handler_signal_exit(void *data, int ev_type, void *ev)
{
Ecore_Event_Signal_Exit *e;
e = ev;
if (e->interrupt) printf("exit: interrupt\n");
if (e->quit) printf("exit: quit\n");
if (e->terminate) printf("exit: terminate\n");
ecore_main_loop_quit();
return 1;
}
int
handler_ipc_client_add(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_IPC
Ecore_Ipc_Event_Client_Add *e;
e = event;
printf("!!! client %p connected to server!\n", e->client);
return 1;
#endif
}
int
handler_ipc_client_del(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_IPC
Ecore_Ipc_Event_Client_Del *e;
e = event;
printf("!!! client %p disconnected from server!\n", e->client);
return 1;
#endif
}
int
handler_ipc_client_data(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_IPC
Ecore_Ipc_Event_Client_Data *e;
e = event;
printf("!!! client sent: [%i] [%i] (%i) \"%s\"\n", e->major, e->minor, e->size, e->data);
ecore_ipc_client_send(e->client, 1, 2, 0, 0, 0, "ABC", 4);
/* we can disconnect a client like this: */
/* ecore_ipc_client_del(e->client); */
/* or we can end a server by: */
/* ecore_ipc_server_del(ecore_ipc_client_server_get(e->client)); */
return 1;
#endif
}
int
handler_ipc_server_add(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_IPC
Ecore_Ipc_Event_Server_Add *e;
e = event;
printf("!!! client made successful connect to server %p!\n", e->server);
return 1;
#endif
}
int
handler_ipc_server_del(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_IPC
Ecore_Ipc_Event_Server_Del *e;
e = event;
printf("!!! server went away!\n");
/* clean up our server connection since it went away */
ecore_ipc_server_del(e->server);
return 1;
#endif
}
int
handler_ipc_server_data(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_IPC
Ecore_Ipc_Event_Server_Data *e;
static int count = 0;
e = event;
printf("!!! server sent: [%i] [%i] (%i) \"%s\"\n", e->major, e->minor, e->size, e->data);
ecore_ipc_server_send(e->server, 3, 4, 0, 0, 0, "EFG", 4);
count++;
if (count > 4)
{
printf("!!! go & disconnect from server!\n");
ecore_ipc_server_del(e->server);
}
return 1;
#endif
}
/**** ECORE_CON TEST CODE */
int
handler_client_add(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_CON
Ecore_Con_Event_Client_Add *e;
e = event;
printf("!!! client %p connected to server!\n", e->client);
return 1;
#endif
}
int
handler_client_del(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_CON
Ecore_Con_Event_Client_Del *e;
e = event;
printf("!!! client %p disconnected from server!\n", e->client);
return 1;
#endif
}
int
handler_client_data(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_CON
Ecore_Con_Event_Client_Data *e;
e = event;
printf("!!! client sent: \"%s\"\n", e->data);
ecore_con_client_send(e->client, "ABC", 4);
/* we can disconnect a client like this: */
/* ecore_con_client_del(e->client); */
/* or we can end a server by: */
/* ecore_con_server_del(ecore_con_client_server_get(e->client)); */
return 1;
#endif
}
int
handler_server_add(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_CON
Ecore_Con_Event_Server_Add *e;
e = event;
printf("!!! client made successful connect to server %p!\n", e->server);
return 1;
#endif
}
int
handler_server_del(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_CON
Ecore_Con_Event_Server_Del *e;
e = event;
printf("!!! server went away!\n");
/* clean up our server connection since it went away */
ecore_con_server_del(e->server);
return 1;
#endif
}
int
handler_server_data(void *data, int type, void *event)
{
#ifdef BUILD_ECORE_CON
Ecore_Con_Event_Server_Data *e;
static int count = 0;
e = event;
printf("!!! server sent: \"%s\"\n", e->data);
ecore_con_server_send(e->server, "EFG", 4);
count++;
if (count > 4)
{
printf("!!! go & disconnect from server!\n");
ecore_con_server_del(e->server);
}
return 1;
#endif
}
/* NB: also tests ECORE_JOB */
#ifdef BUILD_ECORE_JOB
void
job_call(void *data)
{
printf("!! Job done \"%s\"!\n", (char *)data);
}
#endif
int
idle_enterer(void *data)
{
printf("-------> Entering idle %3.3f\n", ecore_time_get() - start_time);
return 1;
}
int
idler(void *data)
{
printf("oo Idler %3.3f\n", ecore_time_get() - start_time);
return 1;
}
int
timer(void *data)
{
printf("Q- Timer tick %3.8f\n", ecore_time_get() - start_time);
/* test ecore_job */
#ifdef BUILD_ECORE_JOB
ecore_job_add(job_call, "1");
ecore_job_add(job_call, "2");
ecore_job_add(job_call, "3");
#endif
return 1;
}
void
setup_ecore_test(void)
{
ecore_idle_enterer_add(idle_enterer, NULL);
/* ecore_idler_add(idler, NULL); */
ecore_timer_add(2.0, timer, NULL);
}
#ifdef BUILD_ECORE_X
/**** ECORE_X TEST CODE */
Ecore_X_Window win = 0;
int
handler_x_key_down(void *data, int type, void *event)
{
Ecore_X_Event_Key_Down *e;
e = event;
printf("Key down %s\n", e->keyname);
return 1;
}
int
handler_x_key_up(void *data, int type, void *event)
{
Ecore_X_Event_Key_Up *e;
e = event;
printf("Key up %s\n", e->keyname);
return 1;
}
int
handler_x_mouse_button_down(void *data, int type, void *event)
{
Ecore_X_Event_Mouse_Button_Down *e;
e = event;
printf("Mouse down %i [%i][%i]\n", e->button, e->double_click, e->triple_click);
return 1;
}
int
handler_x_mouse_button_up(void *data, int type, void *event)
{
Ecore_X_Event_Mouse_Button_Up *e;
e = event;
printf("Mouse up %i\n", e->button);
return 1;
}
int
handler_x_mouse_move(void *data, int type, void *event)
{
Ecore_X_Event_Mouse_Move *e;
e = event;
printf("Mouse move to %i %i\n", e->x, e->y);
return 1;
}
int
handler_x_mouse_in(void *data, int type, void *event)
{
Ecore_X_Event_Mouse_In *e;
e = event;
printf("Mouse in\n");
return 1;
}
int
handler_x_mouse_out(void *data, int type, void *event)
{
Ecore_X_Event_Mouse_Out *e;
e = event;
printf("Mouse out\n");
return 1;
}
int
handler_x_window_focus_in(void *data, int type, void *event)
{
Ecore_X_Event_Window_Focus_In *e;
e = event;
printf("Focus in\n");
return 1;
}
int
handler_x_window_focus_out(void *data, int type, void *event)
{
Ecore_X_Event_Window_Focus_Out *e;
e = event;
printf("Focus out\n");
return 1;
}
int
handler_x_window_damage(void *data, int type, void *event)
{
Ecore_X_Event_Window_Damage *e;
e = event;
printf("Damage %i %i, %ix%i\n", e->x, e->y, e->w, e->h);
return 1;
}
int
handler_x_window_destroy(void *data, int type, void *event)
{
Ecore_X_Event_Window_Destroy *e;
e = event;
printf("Destroy\n");
ecore_main_loop_quit();
return 1;
}
int
handler_x_window_configure(void *data, int type, void *event)
{
Ecore_X_Event_Window_Configure *e;
e = event;
printf("Configure %i %i, %ix%i\n", e->x, e->y, e->w, e->h);
return 1;
}
int
handler_x_window_delete_request(void *data, int type, void *event)
{
Ecore_X_Event_Window_Delete_Request *e;
e = event;
printf("Delete Request\n");
ecore_main_loop_quit();
return 1;
}
int
handler_x_window_prop_title_change(void *data, int type, void *event)
{
Ecore_X_Event_Window_Prop_Title_Change *e;
e = event;
if (e->title)
printf("Title change to \"%s\"\n", e->title);
else
printf("Title deleted\n");
return 1;
}
int
handler_x_window_prop_name_class_change(void *data, int type, void *event)
{
Ecore_X_Event_Window_Prop_Name_Class_Change *e;
e = event;
if ((e->name) && (e->clas))
printf("Name & Class change to \"%s\".\"%s\"\n", e->name, e->clas);
else
printf("Name & Class deleted\n");
return 1;
}
void
setup_ecore_x_test(void)
{
win = ecore_x_window_new(0, 0, 0, 120, 60);
ecore_x_window_prop_title_set(win, "Ecore Test Program");
ecore_x_window_prop_name_class_set(win, "ecore_test", "main");
ecore_x_window_prop_delete_request_set(win, 1);
ecore_x_window_show(win);
ecore_x_flush();
ecore_event_handler_add(ECORE_X_EVENT_KEY_DOWN, handler_x_key_down, NULL);
ecore_event_handler_add(ECORE_X_EVENT_KEY_UP, handler_x_key_up, NULL);
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_DOWN, handler_x_mouse_button_down, NULL);
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_UP, handler_x_mouse_button_up, NULL);
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_MOVE, handler_x_mouse_move, NULL);
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_IN, handler_x_mouse_in, NULL);
ecore_event_handler_add(ECORE_X_EVENT_MOUSE_OUT, handler_x_mouse_out, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, handler_x_window_focus_in, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, handler_x_window_focus_out, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DAMAGE, handler_x_window_damage, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, handler_x_window_destroy, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE, handler_x_window_configure, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, handler_x_window_delete_request, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_TITLE_CHANGE, handler_x_window_prop_title_change, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_NAME_CLASS_CHANGE, handler_x_window_prop_name_class_change, NULL);
}
#endif
#ifdef BUILD_ECORE_EVAS
/* choose: TEST_X, TEST_FB */
#define TEST_X
/**** ECORE_EVAS TEST CODE */
Ecore_Timer *anim_timer = NULL;
Ecore_Evas *ee = NULL;
Evas *evas = NULL;
Evas_Object *objects[64];
int
obj_timer(void *data)
{
Evas_Object *o;
double x, y;
double w, h;
double ow, oh;
double t;
int m, n;
int i;
t = ecore_time_get() - start_time;
for (i = 0; i < (sizeof(objects) / sizeof(Evas_Object *)); i++)
{
o = objects[i];
evas_output_viewport_get(evas_object_evas_get(o), NULL, NULL, &w, &h);
evas_object_geometry_get(o, NULL, NULL, &ow, &oh);
m = ((int)o / 36) & 0x3f;
n = ((int)o / 763) & 0x3f;
x = sin(t * (double)m / 12) * ((w - ow) / 2);
y = sin(t * (double)n / 12) * ((h - oh) / 2);
evas_object_move(o, (w / 2) - (ow / 2) + x, (h / 2) - (oh / 2) + y);
}
return 1;
}
void
del_req(Ecore_Evas *ee)
{
int i;
printf("request to go away... nice exit\n");
for (i = 0; i < (sizeof(objects) / sizeof(Evas_Object *)); i++)
objects[i] = NULL;
ecore_timer_del(anim_timer);
anim_timer = NULL;
ecore_main_loop_quit();
}
static void
cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Key_Down *ev;
ev = event_info;
if (!strcmp(ev->keyname, "Escape")) ecore_main_loop_quit();
if (!strcmp(ev->keyname, "q")) ecore_main_loop_quit();
if (!strcmp(ev->keyname, "Q")) ecore_main_loop_quit();
if (!strcmp(ev->keyname, "f"))
{
if (!ecore_evas_fullscreen_get(ee))
ecore_evas_fullscreen_set(ee, 1);
else
ecore_evas_fullscreen_set(ee, 0);
}
if (!strcmp(ev->keyname, "o"))
{
if (!ecore_evas_override_get(ee))
ecore_evas_override_set(ee, 1);
else
ecore_evas_override_set(ee, 0);
}
if (!strcmp(ev->keyname, "r"))
{
int r;
r = ecore_evas_rotation_get(ee);
if (r == 0) r = 90;
else if (r == 90) r = 270;
else if (r == 270) r = 0;
ecore_evas_rotation_set(ee, r);
}
if (!strcmp(ev->keyname, "b"))
{
if (!ecore_evas_borderless_get(ee))
ecore_evas_borderless_set(ee, 1);
else
ecore_evas_borderless_set(ee, 0);
}
if (!strcmp(ev->keyname, "d"))
{
if (!ecore_evas_avoid_damage_get(ee))
ecore_evas_avoid_damage_set(ee, 1);
else
ecore_evas_avoid_damage_set(ee, 0);
}
if (!strcmp(ev->keyname, "s"))
{
if (!ecore_evas_shaped_get(ee))
ecore_evas_shaped_set(ee, 1);
else
ecore_evas_shaped_set(ee, 0);
}
#if 1 /* no data files shipped yet to test this */
if (!strcmp(ev->keyname, "p"))
{
char *fl;
ecore_evas_cursor_get(ee, &fl, NULL, NULL, NULL);
if (!fl)
ecore_evas_cursor_set(ee, "data/pointers/mouse_pointer.png", 1000000, 2, 2);
else
ecore_evas_cursor_set(ee, NULL, 0, 0, 0);
}
#endif
}
int
setup_ecore_evas_test(void)
{
Evas_Object *o;
int i;
/* create a new ecore wrapped evas canvas in X */
#ifdef TEST_X
ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 240, 320);
#endif
#ifdef TEST_FB
ee = ecore_evas_fb_new(NULL, 270, 240, 320);
#endif
if (!ee) return 0;
ecore_evas_title_set(ee, "Ecore Evas Test");
ecore_evas_name_class_set(ee, "ecore_test", "test_evas");
/* callback if clsoe button is pressed and win is asked to be deleted */
ecore_evas_callback_delete_request_set(ee, del_req);
/* get the actual evas ecore created for us */
evas = ecore_evas_get(ee);
/* image cache set (in bytes) */
evas_image_cache_set(evas, 0 * 1024);
/* font cache set (in bytes) */
evas_font_cache_set(evas, 0 * 1024);
/* add a directory to look in for fonts */
evas_font_path_append(evas, "./");
/* set up a big white rectangle on the bg */
o = evas_object_rectangle_add(evas);
evas_object_color_set(o, 255, 255, 255, 255);
evas_object_move(o, 0, 0);
evas_object_resize(o, 100000, 100000);
evas_object_layer_set(o, -1000000);
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, cb_key_down, ee);
evas_object_focus_set(o, 1);
evas_object_show(o);
/* make a bunch of rectangles */
for (i = 0; i < (sizeof(objects) / sizeof(Evas_Object *)); i++)
{
o = evas_object_rectangle_add(evas);
evas_object_move(o, 10, 10);
evas_object_pass_events_set(o, 1);
evas_object_color_set(o,
((int)o) & 0xff,
((int)o / 30) & 0xff,
((int)o / 65) & 0xff,
((int)o / 156) & 0xff);
evas_object_resize(o, 4 + (((int)o) % 100), 4 + (((int)o / 50) % 100));
evas_object_show(o);
objects[i] = o;
}
/* add a timer to animate them */
anim_timer = ecore_timer_add(0.01, obj_timer, NULL);
ecore_evas_show(ee);
return 1;
}
#endif
/**** MAIN */
int
main(int argc, const char **argv)
{
/* get the time the program started at */
start_time = ecore_time_get();
/* init ecore */
ecore_init();
/* tell ecore what our arguments are */
ecore_app_args_set(argc, argv);
#if 1
/* setup to test ecore module basics */
setup_ecore_test();
#endif
#ifdef BUILD_ECORE_CON
#if 0
/* init ecore_con */
ecore_con_init();
{
Ecore_Con_Server *server;
server = ecore_con_server_add(ECORE_CON_LOCAL_USER, "ecore_test", 0, NULL);
/* server = ecore_con_server_add(ECORE_CON_REMOTE_SYSTEM, "localhost", 7654, NULL); */
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, handler_client_add, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, handler_client_del, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, handler_client_data, NULL);
printf("create server %p\n", server);
}
{
Ecore_Con_Server *server;
server = ecore_con_server_connect(ECORE_CON_LOCAL_USER, "ecore_test", 0, NULL);
/* server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, "localhost", 7654, NULL); */
/* server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, "www.rasterman.com", 80, NULL); */
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, handler_server_add, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, handler_server_del, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, handler_server_data, NULL);
printf("connect to server: %p\n", server);
if (server)
{
char data[160 * 1024];
strcpy(data, "BLAHPANTS!");
ecore_con_server_send(server, data, 160 * 1024);
}
}
#endif
#endif
#ifdef BUILD_ECORE_IPC
#if 1
/* init ecore_ipc */
ecore_ipc_init();
{
Ecore_Ipc_Server *server;
server = ecore_ipc_server_add(ECORE_IPC_LOCAL_SYSTEM, "ecore_ipc_test", 0, NULL);
/* server = ecore_ipc_server_add(ECORE_IPC_REMOTE_SYSTEM, "localhost", 4567, NULL); */
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, handler_ipc_client_add, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, handler_ipc_client_del, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, handler_ipc_client_data, NULL);
printf("create ipc server %p\n", server);
}
{
Ecore_Ipc_Server *server;
server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, "ecore_ipc_test", 0, NULL);
/* server = ecore_ipc_server_connect(ECORE_IPC_REMOTE_SYSTEM, "localhost", 4567, NULL); */
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, handler_ipc_server_add, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, handler_ipc_server_del, NULL);
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, handler_ipc_server_data, NULL);
printf("connect to ipc server: %p\n", server);
if (server)
{
char data[160 * 1024];
strcpy(data, "BLAHPANTS!");
ecore_ipc_server_send(server, 5, 6, 0, 0, 0, data, 160 * 1024);
}
}
#endif
#endif
#ifdef BUILD_ECORE_EVAS
/* init ecore_evas */
/* if (!ecore_evas_init()) return -1; */
#endif
/* setup a callback to handle a systsme signal to quit */
ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, handler_signal_exit, NULL);
#ifdef BUILD_ECORE_X
/* setup to test ecore_x module things */
/* if (!ecore_x_init(NULL)) return -1; */
/* setup_ecore_x_test(); */
#endif
#ifdef BUILD_ECORE_EVAS
/* setup to test ecore_evas module */
/* if (!setup_ecore_evas_test()) return -1; */
#endif
/* run the main loop */
ecore_main_loop_begin();
#ifdef BUILD_ECORE_EVAS
/* shut down ecore_evas */
ecore_evas_shutdown();
#endif
#ifdef BUILD_ECORE_IPC
/* shut down ecore_ipc */
ecore_ipc_shutdown();
#endif
#ifdef BUILD_ECORE_CON
/* shut down ecore_con */
ecore_con_shutdown();
#endif
/* shut down ecore */
ecore_shutdown();
return 0;
}

View File

@ -0,0 +1,132 @@
#include "Ecore.h"
typedef struct _ecore_event_handler Ecore_Event_Handler;
typedef struct _ecore_event_idle_handler Ecore_Event_Idle_Handler;
struct _ecore_event_handler
{
void (*func) (Ecore_Event * ev);
Ecore_Event_Handler *next;
};
struct _ecore_event_idle_handler
{
void (*func) (void *data);
void *data;
Ecore_Event_Idle_Handler *next;
};
static Ecore_Event_Handler *handler[ECORE_EVENT_MAX];
static Ecore_Event_Idle_Handler *idle_handlers = NULL;
void
ecore_event_filter(Ecore_Event * ev)
{
Ecore_Event *evp;
int motion_events = 0;
int dnd_pos_events = 0;
int dnd_status_events = 0;
/* count events to only use last events of some types */
for (evp = ev; evp; evp = evp->next)
{
if (evp->type == ECORE_EVENT_MOUSE_MOVE)
motion_events++;
if (evp->type == ECORE_EVENT_DND_DROP_POSITION)
dnd_pos_events++;
if (evp->type == ECORE_EVENT_DND_DROP_STATUS)
dnd_status_events++;
}
for (evp = ev; evp; evp = evp->next)
{
if (evp->type == ECORE_EVENT_MOUSE_MOVE)
{
if (motion_events > 1)
{
evp->ignore = 1;
motion_events--;
}
}
else if (evp->type == ECORE_EVENT_DND_DROP_POSITION)
{
if (dnd_pos_events > 1)
{
evp->ignore = 1;
dnd_pos_events--;
}
}
else if (evp->type == ECORE_EVENT_DND_DROP_STATUS)
{
if (dnd_status_events > 1)
{
evp->ignore = 1;
dnd_status_events--;
}
}
}
}
void
ecore_event_filter_events_handle(Ecore_Event * ev)
{
Ecore_Event *evp;
for (evp = ev; evp; evp = evp->next)
{
Ecore_Event_Handler *h;
if (!evp->ignore)
{
for (h = handler[evp->type]; h; h = h->next)
{
if (h->func)
h->func(evp);
}
}
}
}
void
ecore_event_filter_idle_handle(void)
{
Ecore_Event_Idle_Handler *h;
for (h = idle_handlers; h; h = h->next)
h->func(h->data);
}
extern int __quit_ev_loop;
void
ecore_event_filter_init(void)
{
int i;
__quit_ev_loop = 0;
for (i = 0; i < ECORE_EVENT_MAX; i++)
handler[i] = NULL;
}
void
ecore_event_filter_handler_add(Ecore_Event_Type type,
void (*func) (Ecore_Event * ev))
{
Ecore_Event_Handler *h;
h = NEW(Ecore_Event_Handler, 1);
h->func = func;
h->next = handler[type];
handler[type] = h;
}
void
ecore_event_filter_idle_handler_add(void (*func) (void *data), void *data)
{
Ecore_Event_Idle_Handler *h;
h = NEW(Ecore_Event_Idle_Handler, 1);
h->func = func;
h->data = data;
h->next = idle_handlers;
idle_handlers = h;
}

View File

@ -0,0 +1,320 @@
#include "Ecore.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>
static void ecore_event_signal_free(void *event);
static void ecore_event_signal_handle_sigchld(int num);
static void ecore_event_signal_handle_sigusr1(int num);
static void ecore_event_signal_handle_sigusr2(int num);
static void ecore_event_signal_handle_sighup(int num);
static void ecore_event_signal_handle_sigpipe(int num);
static void ecore_event_signal_handle_sigsegv(int num);
static void ecore_event_signal_handle_sigfpe(int num);
static void ecore_event_signal_handle_sigill(int num);
static void ecore_event_signal_handle_sigbus(int num);
#ifdef HAVE_SIGSTKFLT
static void ecore_event_signal_handle_sigstkflt(int num);
#endif
#ifdef HAVE_SIGPWR
static void ecore_event_signal_handle_sigpwr(int num);
#endif
static void ecore_event_signal_handle_sigchld(int num);
static void ecore_event_signal_handle_all(pid_t pid);
static int signal_chld_count = 0;
static int signal_usr1_count = 0;
static int signal_usr2_count = 0;
static int signal_hup_count = 0;
/* freeing stuff */
static void
ecore_event_signal_free(void *event)
{
FREE(event);
}
/* signal handlers we can return from and add to signal recieved counts */
static void
ecore_event_signal_handle_sigchld(int num)
{
signal_chld_count++;
return;
num = 0;
}
static void
ecore_event_signal_handle_sigusr1(int num)
{
signal_usr1_count++;
return;
num = 0;
}
static void
ecore_event_signal_handle_sigusr2(int num)
{
signal_usr2_count++;
return;
num = 0;
}
static void
ecore_event_signal_handle_sighup(int num)
{
signal_hup_count++;
return;
num = 0;
}
/* signals to ignore */
static void
ecore_event_signal_handle_sigpipe(int num)
{
return;
num = 0;
}
/* signal handlers we cant return from - so handle here */
static void
ecore_event_signal_handle_sigsegv(int num)
{
for (;;)
{
fprintf(stderr, "EEEEEEEEK SEGV - waiting 10 seconds\n");
sleep(10);
}
/* EEK - can't return - bad */
abort();
num = 0;
}
static void
ecore_event_signal_handle_sigfpe(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
}
static void
ecore_event_signal_handle_sigill(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
}
static void
ecore_event_signal_handle_sigbus(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
}
#ifdef HAVE_SIGSTKFLT
static void
ecore_event_signal_handle_sigstkflt(int num)
{
/* EEK - can't return - bad */
abort();
return;
num = 0;
}
#endif
static void
ecore_event_signal_handle_sigint(int num)
{
exit(0);
return;
num = 0;
}
static void
ecore_event_signal_handle_sigquit(int num)
{
exit(0);
return;
num = 0;
}
static void
ecore_event_signal_handle_sigabrt(int num)
{
abort();
return;
num = 0;
}
static void
ecore_event_signal_handle_sigalrm(int num)
{
return;
num = 0;
}
static void
ecore_event_signal_handle_sigterm(int num)
{
exit(0);
return;
num = 0;
}
#ifdef HAVE_SIGPWR
static void
ecore_event_signal_handle_sigpwr(int num)
{
exit(0);
return;
num = 0;
}
#endif
static void
ecore_event_signal_handle_all(pid_t pid_pass)
{
int status;
pid_t pid;
if (signal_chld_count > 0)
{
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
{
if (WIFEXITED(status))
{
Ecore_Event_Child *e;
int code;
code = WEXITSTATUS(status);
e = NEW(Ecore_Event_Child, 1);
e->pid = pid;
e->exit_code = code;
ecore_add_event(ECORE_EVENT_CHILD, e, ecore_event_signal_free);
}
}
signal_chld_count = 0;
}
while (signal_usr1_count > 0)
{
Ecore_Event_User *e;
e = NEW(Ecore_Event_User, 1);
e->num = 0;
e->hup = 0;
ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free);
signal_usr1_count--;
}
while (signal_hup_count > 0)
{
Ecore_Event_User *e;
e = NEW(Ecore_Event_User, 1);
e->num = 0;
e->hup = 1;
ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free);
signal_hup_count--;
}
return;
pid_pass = 0;
}
int
ecore_event_signal_events_pending(void)
{
return (signal_chld_count + signal_usr1_count + signal_hup_count);
}
void
ecore_event_signal_init(void)
{
struct sigaction sa;
ecore_add_event_pid(0, ecore_event_signal_handle_all);
sa.sa_handler = ecore_event_signal_handle_sigchld;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigusr1;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR1, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigusr2;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR2, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sighup;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGHUP, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigpipe;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGPIPE, &sa, (struct sigaction *)0);
/*
sa.sa_handler = ecore_event_signal_handle_sigsegv;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, (struct sigaction *)0);
*/
sa.sa_handler = ecore_event_signal_handle_sigfpe;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGFPE, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigill;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGILL, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigbus;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGBUS, &sa, (struct sigaction *)0);
#ifdef HAVE_SIGSTKFLT
sa.sa_handler = ecore_event_signal_handle_sigstkflt;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGSTKFLT, &sa, (struct sigaction *)0);
#endif
sa.sa_handler = ecore_event_signal_handle_sigint;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigquit;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGQUIT, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigabrt;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGABRT, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigalrm;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGALRM, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigterm;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGTERM, &sa, (struct sigaction *)0);
#ifdef HAVE_SIGPWR
sa.sa_handler = ecore_event_signal_handle_sigpwr;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGPWR, &sa, (struct sigaction *)0);
#endif
}

1234
legacy/ecore/src/e_ev_x.c Normal file

File diff suppressed because it is too large Load Diff

430
legacy/ecore/src/e_events.c Normal file
View File

@ -0,0 +1,430 @@
#include "Ecore.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/* glocal (yes global/local) variabels for events */
Ecore_Event_Fd_Handler *fd_handlers = NULL;
Ecore_Event_Ipc_Handler *ipc_handlers = NULL;
Ecore_Event_Pid_Handler *pid_handlers = NULL;
Ecore_Event_Timer *timers = NULL;
Ecore_Event *events = NULL;
Ecore_Event *last_event = NULL;
int __quit_ev_loop = 0;
/* local functions for event handling */
static void ecore_handle_event_timer(void);
static void ecore_handle_zero_event_timer(void);
/* public functions */
/* add an event to the end of the event queue */
void
ecore_add_event(Ecore_Event_Type type, void *event,
void (*ev_free) (void *event))
{
Ecore_Event *ev;
ev = NEW(Ecore_Event, 1);
ev->type = type;
ev->ignore = 0;
ev->event = event;
ev->next = NULL;
ev->ev_free = ev_free;
if (!events)
events = ev;
else
last_event->next = ev;
last_event = ev;
}
/* delete an event from the event queue */
void
ecore_del_event(void *event)
{
Ecore_Event *ev, *pev;
pev = NULL;
ev = events;
while (ev)
{
if (ev->event == event)
{
if (pev)
pev->next = ev->next;
else
events = ev->next;
if (!ev->next)
last_event = pev;
if ((ev->event) && (ev->ev_free))
(*ev->ev_free) (ev->event);
FREE(ev);
return;
}
pev = ev;
ev = ev->next;
}
}
void
ecore_del_all_events(void)
{
Ecore_Event *ev, *pev;
ev = events;
while (ev)
{
pev = ev;
ev = ev->next;
if ((pev->event) && (pev->ev_free))
pev->ev_free(pev->event);
FREE(pev);
}
events = NULL;
last_event = NULL;
}
Ecore_Event *
ecore_get_last_event(void)
{
return last_event;
}
/* add a callback handler if fd is active for reading */
void
ecore_add_event_fd(int fd, void (*func) (int fd))
{
Ecore_Event_Fd_Handler *fd_h;
/* new handler struct */
fd_h = NEW(Ecore_Event_Fd_Handler, 1);
fd_h->next = fd_handlers;
fd_h->fd = fd;
fd_h->func = func;
fd_handlers = fd_h;
}
/* delete handler for fd */
void
ecore_del_event_fd(int fd)
{
START_LIST_DEL(Ecore_Event_Fd_Handler, fd_handlers, (_p->fd == fd));
FREE(_p);
END_LIST_DEL;
}
void
ecore_add_event_pid(pid_t pid, void (*func) (pid_t pid))
{
Ecore_Event_Pid_Handler *pid_h;
/* delete the old handler */
ecore_del_event_pid(pid);
/* new handler struct */
pid_h = NEW(Ecore_Event_Pid_Handler, 1);
pid_h->next = pid_handlers;
pid_h->pid = pid;
pid_h->func = func;
pid_handlers = pid_h;
}
void
ecore_del_event_pid(pid_t pid)
{
START_LIST_DEL(Ecore_Event_Pid_Handler, pid_handlers, (_p->pid == pid));
FREE(_p);
END_LIST_DEL;
}
void
ecore_add_event_ipc(int ipc, void (*func) (int ipc))
{
Ecore_Event_Ipc_Handler *ipc_h;
/* delete the old handler */
ecore_del_event_ipc(ipc);
/* new handler struct */
ipc_h = NEW(Ecore_Event_Ipc_Handler, 1);
ipc_h->next = ipc_handlers;
ipc_h->ipc = ipc;
ipc_h->func = func;
ipc_handlers = ipc_h;
}
void
ecore_del_event_ipc(int ipc)
{
START_LIST_DEL(Ecore_Event_Ipc_Handler, ipc_handlers, (_p->ipc == ipc));
FREE(_p);
END_LIST_DEL;
}
/* sit in this loop forever and process events */
void
ecore_event_loop(void)
{
int fdcount, fdsize, ipccount, ipcsize;
int timed_out, were_events;
double time1, time2, prev_time = 0.0;
struct timeval tval;
fd_set fdset, ipcset;
Ecore_Event_Fd_Handler *fd_h;
Ecore_Event_Pid_Handler *pid_h;
Ecore_Event_Ipc_Handler *ipc_h;
/* init some of the time variables */
time1 = ecore_get_time();
time2 = time1 - prev_time;
prev_time = time1;
while (__quit_ev_loop == 0)
{
/* state setup */
timed_out = 0;
were_events = 0;
/* setup fd array from list of listening fd's */
fdsize = 0;
FD_ZERO(&fdset);
/* for ever fd handler add the fd to the array and incriment fdsize */
for (fd_h = fd_handlers; fd_h; fd_h = fd_h->next)
{
FD_SET(fd_h->fd, &fdset);
if (fd_h->fd > fdsize)
fdsize = fd_h->fd;
}
fdcount = 1;
ipcsize = 0;
FD_ZERO(&ipcset);
/* for ever fd handler add the fd to the array and incriment fdsize */
for (ipc_h = ipc_handlers; ipc_h; ipc_h = ipc_h->next)
{
FD_SET(ipc_h->ipc, &ipcset);
if (ipc_h->ipc > ipcsize)
ipcsize = ipc_h->ipc;
}
ipccount = 1;
/* if there are timers setup adjust timeout value and select */
if (timers)
{
if (timers->just_added)
{
timers->just_added = 0;
time1 = timers->in;
}
else
{
time1 = timers->in - time2;
if (time1 < 0.0)
time1 = 0.0;
timers->in = time1;
}
tval.tv_sec = (long)time1;
tval.tv_usec = (long)((time1 - ((double)tval.tv_sec)) * 1000000);
if (tval.tv_sec < 0)
tval.tv_sec = 0;
if (tval.tv_usec <= 1000)
tval.tv_usec = 1000;
ecore_handle_zero_event_timer();
if ((!ecore_events_pending()) && (!ecore_event_signal_events_pending()))
fdcount = select(fdsize + 1, &fdset, NULL, NULL, &tval);
}
/* no timers - just sit and block */
else
{
if ((!ecore_events_pending()) && (!ecore_event_signal_events_pending()))
fdcount = select(fdsize + 1, &fdset, NULL, NULL, NULL);
}
for (pid_h = pid_handlers; pid_h; pid_h = pid_h->next)
pid_h->func(pid_h->pid);
/* see if we have any new ipc connections */
tval.tv_sec = 0;
tval.tv_usec = 0;
ipccount += select(ipcsize + 1, &ipcset, NULL, NULL, &tval);
/* return < 0 - error or signal interrupt */
if (fdcount < 0)
{
/* error */
if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))
{
fprintf(stderr, "Lost connection to X display.\n");
exit(1);
}
}
/* timers are available and its a timeout */
if ((timers) && (fdcount == 0))
{
ecore_handle_event_timer();
timed_out = 1;
}
if (fdcount < 0)
fdcount = 0;
if (ecore_events_pending())
{
fdcount++;
FD_SET(ecore_x_get_fd(), &fdset);
}
/* fd's are active */
if (fdcount > 0)
{
/* for every fd handler - if its fd is set - call the func */
for (fd_h = fd_handlers; fd_h;)
{
Ecore_Event_Fd_Handler *fdh;
fdh = fd_h;
fd_h = fd_h->next;
if (FD_ISSET(fdh->fd, &fdset))
fdh->func(fdh->fd);
}
}
/* ipc clients are active */
if (ipccount > 0)
{
for (ipc_h = ipc_handlers; ipc_h;)
{
Ecore_Event_Ipc_Handler *ipch;
ipch = ipc_h;
ipc_h = ipc_h->next;
if (FD_ISSET(ipch->ipc, &ipcset))
ipch->func(ipch->ipc);
}
}
if (events)
ecore_event_filter(events);
if (events)
{
ecore_event_filter_events_handle(events);
were_events = 1;
}
ecore_del_all_events();
if ((timed_out) || (were_events))
ecore_event_filter_idle_handle();
ecore_flush();
time1 = ecore_get_time();
time2 = time1 - prev_time;
prev_time = time1;
}
__quit_ev_loop = 0;
}
/* set a flag to 0 so that we can quit the event loop and shutdown
* properly */
void
ecore_event_loop_quit(void)
{
__quit_ev_loop = 1;
}
/* add a timeout funcitont o be called in "in" seconds with name name */
void
ecore_add_event_timer(char *name, double in, void (*func) (int val, void *data),
int val, void *data)
{
Ecore_Event_Timer *timer, *ptr, *pptr;
double tally;
if (name)
ecore_del_event_timer(name);
timer = NEW(Ecore_Event_Timer, 1);
timer->next = NULL;
timer->func = func;
timer->data = data;
timer->val = val;
timer->just_added = 1;
timer->in = in;
timer->name = strdup(name);
if (!timers)
timers = timer;
else
{
pptr = NULL;
ptr = timers;
tally = 0.0;
while (ptr)
{
tally += ptr->in;
if (tally > in)
{
tally -= ptr->in;
timer->next = ptr;
if (pptr)
pptr->next = timer;
else
timers = timer;
timer->in -= tally;
if (timer->next)
timer->next->in -= timer->in;
return;
}
pptr = ptr;
ptr = ptr->next;
}
if (pptr)
pptr->next = timer;
else
timers = timer;
timer->in -= tally;
}
}
/* delete a timer timeout entry named "name" */
void *
ecore_del_event_timer(char *name)
{
Ecore_Event_Timer *timer, *ptr, *pptr;
pptr = NULL;
ptr = timers;
while (ptr)
{
timer = ptr;
if (!strcmp(timer->name, name))
{
void *data;
if (pptr)
pptr->next = timer->next;
else
timers = timer->next;
if (timer->next)
timer->next->in += timer->in;
IF_FREE(timer->name);
data = timer->data;
FREE(timer);
return data;
}
pptr = ptr;
ptr = ptr->next;
}
return NULL;
}
/* private functions */
static void
ecore_handle_event_timer(void)
{
Ecore_Event_Timer *timer;
if (!timers)
return;
timer = timers;
timers = timer->next;
(*(timer->func)) (timer->val, timer->data);
IF_FREE(timer->name);
FREE(timer);
}
static void
ecore_handle_zero_event_timer(void)
{
while ((timers) && (timers->in == 0.0))
ecore_handle_event_timer();
}

187
legacy/ecore/src/e_ipc.c Normal file
View File

@ -0,0 +1,187 @@
#include "Ecore.h"
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
void ecore_ipc_init(char *path);
void ecore_ipc_cleanup(void);
static void ecore_ipc_connect_handler(int fd);
static void ecore_ipc_client_handler(int fd);
void ecore_ipc_get_data(int fd, void *buf);
void ecore_ipc_send_data(int fd, void *buf, int size);
void ecore_add_ipc_service(int service, void (*func) (int fd));
void ecore_del_ipc_service(int service);
Ecore_Event_Ipc_Service *ipc_services = NULL;
void
ecore_ev_ipc_init(char *path)
{
int fd, len;
struct sockaddr_un saun;
if (path == NULL)
return;
/* a UNIX domain, stream socket */
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
printf("Cannot create ipc socket... disabling ipc.\n");
return;
}
/* create the address we will be binding to */
saun.sun_family = AF_UNIX;
strcpy(saun.sun_path, path);
/* unlink the address so the bind won't fail */
unlink(path);
len = sizeof(saun.sun_family) + strlen(saun.sun_path);
if (bind(fd, (struct sockaddr *)&saun, len) < 0)
{
printf("Cannot bind ipc socket... disabling ipc.\n");
return;
}
/* listen on the socket */
if (listen(fd, 5) < 0)
{
printf("Cannot listen on ipc socket... disabling ipc.\n");
return;
}
/* add ipc listener */
ecore_add_event_ipc(fd, ecore_ipc_connect_handler);
}
void
ecore_ev_ipc_cleanup(void)
{
Ecore_Event_Ipc_Service *ipc_s;
/* cleanup services list */
for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next)
{
ecore_del_ipc_service(ipc_s->service);
}
}
static void
ecore_ipc_connect_handler(int fd)
{
struct sockaddr_un fsaun;
int fromlen, nfd;
/* accept ipc connection */
fromlen = sizeof(fsaun);
if ((nfd = accept(fd, (struct sockaddr *)&fsaun, &fromlen)) < 0)
{
printf("Cannot accept ipc connection... ignoring connection attempt.\n");
return;
}
/* add ipc client */
ecore_add_event_ipc(nfd, ecore_ipc_client_handler);
}
static void
ecore_ipc_client_handler(int fd)
{
int nread, service;
Ecore_Event_Ipc_Service *ipc_s;
if ((nread = read(fd, &service, sizeof(service))) == 0)
{
close(fd);
ecore_del_event_ipc(fd);
}
else if (nread > 0)
{
/* call the service function */
for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next)
{
if (ipc_s->service == service)
{
ipc_s->func(fd);
break;
}
}
}
else
{
printf("ipc error in read service.\n");
fflush(stdout);
}
}
void
ecore_ipc_get_data(int fd, void *buf)
{
int readn, nread;
/* read number of bytes being sent */
if ((nread = read(fd, &readn, sizeof(readn))) == -1)
{
printf("ipc error in get data.\n");
fflush(stdout);
return;
}
/* get data structure */
if ((nread = read(fd, buf, readn)) == -1)
{
printf("ipc error in get data.\n");
fflush(stdout);
return;
}
}
void
ecore_ipc_send_data(int fd, void *buf, int size)
{
int n;
/* send length of data being sent */
if ((n = write(fd, &size, sizeof(size))) == -1)
{
printf("ipc error in send data length.\n");
fflush(stdout);
return;
}
/* send data */
if ((n = write(fd, buf, size)) == -1)
{
printf("ipc error in send data.\n");
fflush(stdout);
return;
}
}
void
ecore_add_ipc_service(int service, void (*func) (int fd))
{
Ecore_Event_Ipc_Service *ipc_s;
/* delete the old service */
ecore_del_ipc_service(service);
/* new service struct */
ipc_s = NEW(Ecore_Event_Ipc_Service, 1);
ipc_s->next = ipc_services;
ipc_s->service = service;
ipc_s->func = func;
ipc_services = ipc_s;
}
void
ecore_del_ipc_service(int service)
{
START_LIST_DEL(Ecore_Event_Ipc_Service, ipc_services,
(_p->service == service));
FREE(_p);
END_LIST_DEL;
}

10
legacy/ecore/src/e_util.c Normal file
View File

@ -0,0 +1,10 @@
#include "Ecore.h"
double
ecore_get_time(void)
{
struct timeval timev;
gettimeofday(&timev, NULL);
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
}

3610
legacy/ecore/src/e_x.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = \
ecore \
ecore_job \
ecore_x \
ecore_fb \
ecore_evas \
ecore_con \
ecore_ipc

View File

@ -0,0 +1,130 @@
#ifndef _ECORE_H
#define _ECORE_H
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ECORE_EVENT_NONE 0
#define ECORE_EVENT_EXE_EXIT 1 /**< Spawned Exe has exit event */
#define ECORE_EVENT_SIGNAL_USER 2 /**< User signal event */
#define ECORE_EVENT_SIGNAL_HUP 3 /**< Hup signal event */
#define ECORE_EVENT_SIGNAL_EXIT 4 /**< Exit signal event */
#define ECORE_EVENT_SIGNAL_POWER 5 /**< Power signal event */
#define ECORE_EVENT_COUNT 6
#ifndef _ECORE_PRIVATE_H
enum _Ecore_Fd_Handler_Flags
{
ECORE_FD_READ = 1, /**< Fd Read mask */
ECORE_FD_WRITE = 2 /**< Fd Write mask */
};
typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
typedef void Ecore_Exe; /**< A handle for spawned processes */
typedef void Ecore_Timer; /**< A handle for timers */
typedef void Ecore_Idler; /**< A handle for idlers */
typedef void Ecore_Idle_Enterer; /**< A handle for idle enterers */
typedef void Ecore_Fd_Handler; /**< A handle for Fd hanlders */
typedef void Ecore_Event_Handler; /**< A handle for an event handler */
typedef void Ecore_Event_Filter; /**< A handle for an event filter */
typedef void Ecore_Event; /**< A handle for an event */
#endif
typedef struct _Ecore_Event_Exe_Exit Ecore_Event_Exe_Exit; /**< Spawned Exe exit event */
typedef struct _Ecore_Event_Signal_User Ecore_Event_Signal_User; /**< User signal event */
typedef struct _Ecore_Event_Signal_Hup Ecore_Event_Signal_Hup; /**< Hup signal event */
typedef struct _Ecore_Event_Signal_Exit Ecore_Event_Signal_Exit; /**< Exit signal event */
typedef struct _Ecore_Event_Signal_Power Ecore_Event_Signal_Power; /**< Power signal event */
struct _Ecore_Event_Exe_Exit /** Process exit event */
{
pid_t pid; /**< The process ID of the process that exited */
int exit_code; /**< The exit code of the process */
Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */
void *ext_data; /**< Extension data - not used */
};
struct _Ecore_Event_Signal_User /** User signal event */
{
int number; /**< The signal number. Either 1 or 2 */
void *ext_data; /**< Extension data - not used */
};
struct _Ecore_Event_Signal_Hup /** Hup signal event */
{
void *ext_data; /**< Extension data - not used */
};
struct _Ecore_Event_Signal_Exit /** Exit request event */
{
int interrupt : 1; /**< Set if the exit request was an interrupt signal*/
int quit : 1; /**< set if the exit request was a quit signal */
int terminate : 1; /**< Set if the exit request was a terminate singal */
void *ext_data; /**< Extension data - not used */
};
struct _Ecore_Event_Signal_Power /** Power event */
{
void *ext_data; /**< Extension data - not used */
};
int ecore_init(void);
void ecore_shutdown(void);
void ecore_app_args_set(int argc, const char **argv);
void ecore_app_args_get(int *argc, char ***argv);
void ecore_app_restart(void);
Ecore_Event_Handler *ecore_event_handler_add(int type, int (*func) (void *data, int type, void *event), const void *data);
void *ecore_event_handler_del(Ecore_Event_Handler *event_handler);
Ecore_Event *ecore_event_add(int type, void *ev, void (*func_free) (void *data, void *ev), void *data);
void *ecore_event_del(Ecore_Event *event);
int ecore_event_type_new(void);
Ecore_Event_Filter *ecore_event_filter_add(void * (*func_start) (void *data), int (*func_filter) (void *data, void *loop_data, int type, void *event), void (*func_end) (void *data, void *loop_data), const void *data);
void *ecore_event_filter_del(Ecore_Event_Filter *ef);
int ecore_event_current_type_get(void);
void *ecore_event_current_event_get(void);
Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data);
void *ecore_exe_free(Ecore_Exe *exe);
pid_t ecore_exe_pid_get(Ecore_Exe *exe);
void *ecore_exe_data_get(Ecore_Exe *exe);
void ecore_exe_pause(Ecore_Exe *exe);
void ecore_exe_continue(Ecore_Exe *exe);
void ecore_exe_terminate(Ecore_Exe *exe);
void ecore_exe_kill(Ecore_Exe *exe);
void ecore_exe_signal(Ecore_Exe *exe, int num);
void ecore_exe_hup(Ecore_Exe *exe);
Ecore_Idler *ecore_idler_add(int (*func) (void *data), const void *data);
void *ecore_idler_del(Ecore_Idler *idler);
Ecore_Idle_Enterer *ecore_idle_enterer_add(int (*func) (void *data), const void *data);
void *ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
void ecore_main_loop_iterate(void);
void ecore_main_loop_begin(void);
void ecore_main_loop_quit(void);
Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, int (*func) (void *data, Ecore_Fd_Handler *fd_handler), const void *data, int (*buf_func) (void *buf_data, Ecore_Fd_Handler *fd_handler), const void *buf_data);
void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler);
int ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
double ecore_time_get(void);
Ecore_Timer *ecore_timer_add(double in, int (*func) (void *data), const void *data);
void *ecore_timer_del(Ecore_Timer *timer);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,24 @@
## Process this file with automake to produce Makefile.in
INCLUDES =
lib_LTLIBRARIES = libecore.la
include_HEADERS = \
Ecore.h
libecore_la_SOURCES = \
ecore.c \
ecore_app.c \
ecore_events.c \
ecore_exe.c \
ecore_idle_enterer.c \
ecore_idler.c \
ecore_list.c \
ecore_main.c \
ecore_signal.c \
ecore_time.c \
ecore_timer.c \
ecore_private.h
libecore_la_LIBADD =
libecore_la_LDFLAGS = -version-info 1:0:0

View File

@ -0,0 +1,117 @@
#include "ecore_private.h"
#include "Ecore.h"
static const char *_ecore_magic_string_get(Ecore_Magic m);
/**
* Set up connections, signal handlers, sockets etc.
* @return 1 or greater on success, 0 otherwise
*
* This function sets up all singal handlers and the basic event loop. If it
* succeeds, 1 will be returned, otherwise 0 will be returned.
*
* @code
* #include <Ecore.h>
*
* int main(int argc, char **argv)
* {
* if (!ecore_init())
* {
* printf("ERROR: Cannot init Ecore!\n");
* return -1;
* }
* ecore_main_loop_begin();
* ecore_shutdown();
* }
* @endcode
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_init(void)
{
_ecore_signal_init();
return 1;
}
/**
* Shut down connections, signal handlers sockets etc.
*
* This function shuts down all things set up in ecore_init() and cleans up all
* event queues, handlers, filters, timers, idlers, idle enterers etc. set up
* after ecore_init() was called.
*
* Do not call this function from any callback that may be called from the main
* loop, as the main loop will then fall over and not function properly.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_shutdown(void)
{
_ecore_exe_shutdown();
_ecore_idle_enterer_shutdown();
_ecore_idler_shutdown();
_ecore_timer_shutdown();
_ecore_event_shutdown();
_ecore_main_shutdown();
_ecore_signal_shutdown();
}
void
_ecore_magic_fail(void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname)
{
fprintf(stderr,
"\n"
"*** ECORE ERROR: Ecore Magic Check Failed!!!\n"
"*** IN FUNCTION: %s()\n", fname);
if (!d)
fprintf(stderr, " Input handle pointer is NULL!\n");
else if (m == ECORE_MAGIC_NONE)
fprintf(stderr, " Input handle has already been freed!\n");
else if (m != req_m)
fprintf(stderr, " Input handle is wrong type\n"
" Expected: %08x - %s\n"
" Supplied: %08x - %s\n",
(unsigned int)req_m, _ecore_magic_string_get(req_m),
(unsigned int)m, _ecore_magic_string_get(m));
fprintf(stderr,
"*** NAUGHTY PROGRAMMER!!!\n"
"*** SPANK SPANK SPANK!!!\n"
"*** Now go fix your code. Tut tut tut!\n"
"\n");
if (getenv("ECORE_ERROR_ABORT")) abort();
}
static const char *
_ecore_magic_string_get(Ecore_Magic m)
{
switch (m)
{
case ECORE_MAGIC_NONE:
return "None (Freed Object)";
break;
case ECORE_MAGIC_EXE:
return "Ecore_Exe (Executable)";
break;
case ECORE_MAGIC_TIMER:
return "Ecore_Timer (Timer)";
break;
case ECORE_MAGIC_IDLER:
return "Ecore_Idler (Idler)";
break;
case ECORE_MAGIC_IDLE_ENTERER:
return "Ecore_Idle_Enterer (Idler Enterer)";
break;
case ECORE_MAGIC_FD_HANDLER:
return "Ecore_Fd_Handler (Fd Handler)";
break;
case ECORE_MAGIC_EVENT_HANDLER:
return "Ecore_Event_Handler (Event Handler)";
break;
case ECORE_MAGIC_EVENT:
return "Ecore_Event (Event)";
break;
default:
return "<UNKNOWN>";
};
return "<UNKNOWN>";
}

View File

@ -0,0 +1,83 @@
#include "ecore_private.h"
#include "Ecore.h"
static int app_argc = 0;
static char **app_argv = NULL;
/**
* Set up the programs command-line arguments.
* @param argc The same as passed as argc to the programs main() function
* @param argv The same as passed as argv to the programs main() function
*
* A call to this function will store the programs command-line arguments
* for later use by ecore_app_restart() or ecore_app_args_get().
*
* @code
* #include <Ecore.h>
*
* int timer_once(void *data)
* {
* int argc;
* char **argv;
* int i;
*
* ecore_app_args_get(&argc, &argv);
* for (i = 0; i < argc; i++) printf("ARG %i: %s\n", i, argv[i]);
* return 0;
* }
*
* int main(int argc, char **argv)
* {
* ecore_init();
* ecore_app_args_set(argc, argv);
* ecore_timer_add(5.0, timer_once, NULL);
* ecore_main_loop_begin();
* ecore_shutdown();
* }
* @endcode
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_app_args_set(int argc, const char **argv)
{
if ((argc < 1) ||
(!argv)) return;
app_argc = argc;
app_argv = (char **)argv;
}
/**
* Return the programs stored command-line arguments.
* @param argc A pointer to the return value to hold argc
* @param argv A pointer to the return value to hold argv
*
* When called, this funciton returns the arguments for the program stored by
* ecore_app_args_set(). The integer pointed to by @p argc will be filled, if
* the pointer is not NULL, and the string array pointer @p argv will be filled
* also if the pointer is not NULL. The values they are filled with will be the
* same set by ecore_app_args_set().
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_app_args_get(int *argc, char ***argv)
{
if (argc) *argc = app_argc;
if (argv) *argv = app_argv;
}
/**
* Restart the program executable with the command-line arguments stored.
*
* This function will restart & re-execute this program in place of itself
* using the command-line arguments stored by ecore_app_args_set(). This is
* an easy way for a program to restart itself for cleanup purposes,
* configuration reasons or in the event of a crash.
*
* FIXME: Currently not implimented.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_app_restart(void)
{
/* FIXME: exec self using argv, argc etc. */
}

View File

@ -0,0 +1,551 @@
#include "ecore_private.h"
#include "Ecore.h"
static int events_num = 0;
static Ecore_Event *events = NULL;
static Ecore_Event_Handler *event_handlers = NULL;
static int event_handlers_delete_me = 0;
static Ecore_Event_Filter *event_filters = NULL;
static int event_filters_delete_me = 0;
static int event_id_max = ECORE_EVENT_COUNT;
static int ecore_raw_event_type = ECORE_EVENT_NONE;
static void *ecore_raw_event_event = NULL;
/**
* Add an event handler.
* @param type The type of the event this handler will get called for
* @param func The function to call when the event is found in the queue
* @param data A data pointer to pass to the called function @p func
* @return A new Event handler, or NULL on failure
*
* Add an event handler to the list of handlers. This will, on success, return
* a handle to the event handler object that was created, that can be used
* later to remove the handler using ecore_event_handler_del(). The @p type
* parameter is the iteger of the event type that will trigger this callback
* to be called. The callback @p func is called when this event is processed
* and will be passed the event type, a pointer to the private event
* structure that is specific to that event type, and a data pointer that is
* provided in this call as the @p data parameter.
*
* When the callback @p func is called, it must return 1 or 0. If it returns
* 1, It will keep being called as per normal, when events come into the event
* queue. If it returns 0, it will be removed from the list of event handlers
* and be destroyed. If this happens the event handler object returned is no
* longer valid, and the handler will not be called again after it returns 0.
*
* @code
* #include <Ecore.h>
*
* Ecore_Event_Handler *handler1 = NULL, *handler2 = NULL;
*
* int event_hup(void *data, int ev_type, void *ev)
* {
* printf("Hup signal! Remove the exit handler.\n");
* ecore_event_handler_del(handler1);
* return 0;
* }
*
* int event_exit(void *data, int ev_type, void *ev)
* {
* Ecore_Event_Signal_Exit *e;
*
* e = (Ecore_Event_Signal_Exit *)ev;
* printf("This callback handles event type: %i\n", ECORE_EVENT_SIGNAL_EXIT);
* printf("Event type recieved: %i\n", ev_type);
* if (e->interrupt) printf("Exit: interrupt\n");
* if (e->quit) printf("Exit: quit\n");
* if (e->terminate) printf("Exit: terminate\n");
* ecore_main_loop_quit();
* return 1;
* }
*
* int main(int argc, char **argv)
* {
* ecore_init();
* ecore_app_args_set(argc, argv);
* handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT,
* event_exit, NULL);
* handler2 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP,
* event_hup, NULL);
* ecore_main_loop_begin();
* ecore_shutdown();
* }
* @endcode
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Event_Handler *
ecore_event_handler_add(int type, int (*func) (void *data, int type, void *event), const void *data)
{
Ecore_Event_Handler *eh;
if (!func) return NULL;
if ((type <= ECORE_EVENT_NONE) || (type >= event_id_max)) return NULL;
eh = calloc(1, sizeof(Ecore_Event_Handler));
if (!eh) return NULL;
ECORE_MAGIC_SET(eh, ECORE_MAGIC_EVENT_HANDLER);
eh->type = type;
eh->func = func;
eh->data = (void *)data;
event_handlers = _ecore_list_append(event_handlers, eh);
return eh;
}
/**
* Delete an event handler.
* @param event_handler Event handler handle to delete
* @return Data passed to handler
*
* Delete a specified event handler from the handler list. On success this will
* delete the event handler and return the pointer passed as @p data when the
* handler was added by ecore_event_handler_add(). On failure NULL will be
* returned. Once a handler is deleted it will no longer be called.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_event_handler_del(Ecore_Event_Handler *event_handler)
{
if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER))
{
ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER,
"ecore_event_handler_del");
return NULL;
}
event_handler->delete_me = 1;
event_handlers_delete_me = 1;
return event_handler->data;
}
/**
* Add an event to the event queue.
* @param type The event type to add to the end of the event queue
* @param ev The private data structure for this event type
* @param func_free The function to be called to free this private structure
* @param data The data pointer to be passed to the free function
* @return A Handle for that event
*
* On success this function returns a handle to an event on the event queue, or
* NULL if it fails. If it succeeds, an event of type @p type will be added
* to the queue for processing by event handlers added by
* ecore_event_handler_add(). The @p ev parameter will be a pointer to the event
* private data that is specific to that event type. When the event is no
* longer needed, @p func_free will be called and passed the private sructure
* pointer for cleaning up. If @p func_free is NULL, nothnig will be called.
* This function is passed @p data as its data parameter.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Event *
ecore_event_add(int type, void *ev, void (*func_free) (void *data, void *ev), void *data)
{
if (!func_free) return NULL;
if (!ev) return NULL;
if (type <= ECORE_EVENT_NONE) return NULL;
if (type >= event_id_max) return NULL;
return _ecore_event_add(type, ev, func_free, data);
}
/**
* Delete an event from the queue.
* @param event The event handle to delete
* @return The data pointer originally set for the event free function
*
* This deletes the event @p event from the event queue, and returns the
* @p data parameer originally set when adding it with ecore_event_add(). This
* does not immediately call the free function, and it may be called later on
* cleanup, and so if the free function depends on the data pointer to work,
* you should defer cleaning of this till the free function is called later.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_event_del(Ecore_Event *event)
{
if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT))
{
ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT,
"ecore_event_del");
return NULL;
}
event->delete_me = 1;
return event->data;
}
/**
* Allocate a new event type id sensibly and return the new id.
* @return A new event type id.
*
* This function allocates a new event type id and returns it. Once an event
* type has been allocated it can never be de-allocated during the life of
* the program. There is no guarantee of the contents of this event ID, or how
* it is calculated, except that the ID will be unique to the current instance
* of the process.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_event_type_new(void)
{
event_id_max++;
return event_id_max - 1;
}
/**
* Add a filter the current event queue.
* @param func_start Function to call just before filtering and return data
* @param func_filter Function to call on each event
* @param func_end Function to call after the queu has been filtered
* @param data Data to pass to the filter functions
* @return A filter handle
*
* This adds a filter to call callbacks to loop through the event queue and
* filter events out of the queue. On failure NULL is returned. On success a
* Filter handle is returned. Filters are called on the queue just before
* Event handler processing to try and remove redundant events. Just as
* processing starts @p func_start is called and passed the @p data pointer.
* This function returns a pointer that is used as loop_data that is now passed to
* @p func_filter as loop_data. @p func_filter is also passed @p data and the
* event type and private event structure. If this callback returns 0, the
* event is removed from the queue. If it returns 1, the event is kept. When
* processing is finished @p func_end is called and is passed the loop_data
* and @p data pointer to clean up.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Event_Filter *
ecore_event_filter_add(void * (*func_start) (void *data), int (*func_filter) (void *data, void *loop_data, int type, void *event), void (*func_end) (void *data, void *loop_data), const void *data)
{
Ecore_Event_Filter *ef;
if (!func_filter) return NULL;
ef = calloc(1, sizeof(Ecore_Event_Filter));
if (!ef) return NULL;
ECORE_MAGIC_SET(ef, ECORE_MAGIC_EVENT_FILTER);
ef->func_start = func_start;
ef->func_filter = func_filter;
ef->func_end = func_end;
ef->data = (void *)data;
event_filters = _ecore_list_append(event_filters, ef);
return ef;
}
/**
* Delete an event filter.
* @param ef The event filter handle
* @return The data set for the filter
*
* Delete a filter that has been added by its @p ef handle. On success this
* will return the data pointer set when this filter was added. On failure
* NULL is returned.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_event_filter_del(Ecore_Event_Filter *ef)
{
if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER))
{
ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER,
"ecore_event_filter_del");
return NULL;
}
ef->delete_me = 1;
event_filters_delete_me = 1;
return ef->data;
}
/**
* Return the current event type being handled.
* @return The current event type being handled if inside a handler callback
*
* If the program is currently inside an Ecore event handler callback this
* will return the type of the current event being processed. If Ecore is
* not inside an event handler, ECORE_EVENT_NONE is returned.
*
* This is useful when certain Ecore modules such as Ecore_Evas "swallow"
* events and not all the original information is passed on. In special cases
* this extra information may be useful or needed and using this call can let
* the program know if the event type being handled is one it wants to get more
* information about.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_event_current_type_get(void)
{
return ecore_raw_event_type;
}
/**
* Return the current event type pointer handled.
* @return The current event pointer being handled if inside a handler callback
*
* If the program is currently inside an Ecore event handler callback this
* will return the pointer of the current event being processed. If Ecore is
* not inside an event handler, NULL will be returned.
*
* This is useful when certain Ecore modules such as Ecore_Evas "swallow"
* events and not all the original information is passed on. In special cases
* this extra information may be useful or needed and using this call can let
* the program access the event data if the type of the event is handled by
* the program.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_event_current_event_get(void)
{
return ecore_raw_event_event;
}
void
_ecore_event_shutdown(void)
{
while (events) _ecore_event_del(events);
while (event_handlers)
{
Ecore_Event_Handler *eh;
eh = event_handlers;
event_handlers = _ecore_list_remove(event_handlers, eh);
ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
free(eh);
}
event_handlers_delete_me = 0;
while (event_filters)
{
Ecore_Event_Filter *ef;
ef = event_filters;
event_filters = _ecore_list_remove(event_filters, ef);
ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
free(ef);
}
event_filters_delete_me = 0;
}
int
_ecore_event_exist(void)
{
if (events) return 1;
return 0;
}
Ecore_Event *
_ecore_event_add(int type, void *ev, void (*func_free) (void *data, void *ev), void *data)
{
Ecore_Event *e;
e = calloc(1, sizeof(Ecore_Event));
if (!e) return NULL;
ECORE_MAGIC_SET(e, ECORE_MAGIC_EVENT);
e->type = type;
e->event = ev;
e->func_free = func_free;
e->data = data;
events = _ecore_list_append(events, e);
events_num++;
return e;
}
void *
_ecore_event_del(Ecore_Event *event)
{
void *data;
data = event->data;
event->func_free(event->data, event->event);
events = _ecore_list_remove(events, event);
ECORE_MAGIC_SET(event, ECORE_MAGIC_NONE);
free(event);
events_num--;
return data;
}
static void
_ecore_event_filter_del(Ecore_Event_Filter *ef)
{
ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
event_filters = _ecore_list_remove(event_filters, ef);
free(ef);
}
void
_ecore_event_call(void)
{
Ecore_List *l;
for (l = (Ecore_List *)event_filters; l; l = l->next)
{
Ecore_Event_Filter *ef;
ef = (Ecore_Event_Filter *)l;
if (!ef->delete_me)
{
Ecore_List *ll;
if (ef->func_start)
ef->loop_data = ef->func_start(ef->data);
for (ll = (Ecore_List *)events; ll; ll = ll->next)
{
Ecore_Event *e;
e = (Ecore_Event *)ll;
if (!ef->func_filter(ef->loop_data, ef->data,
e->type, e->event))
ecore_event_del(e);
}
if (ef->func_end)
ef->func_end(ef->data, ef->loop_data);
}
}
if (event_filters_delete_me)
{
for (l = (Ecore_List *)event_filters; l; l = l->next)
{
Ecore_Event_Filter *ef;
ef = (Ecore_Event_Filter *)l;
l = l->next;
if (ef->delete_me)
{
event_filters = _ecore_list_remove(event_filters, ef);
ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE);
free(ef);
}
}
event_filters_delete_me = 0;
}
for (l = (Ecore_List *)events; l; l = l->next)
{
Ecore_List *ll;
Ecore_Event *e;
e = (Ecore_Event *)l;
if (!e->delete_me)
{
ecore_raw_event_type = e->type;
ecore_raw_event_event = e->event;
for (ll = (Ecore_List *)event_handlers; ll; ll = ll->next)
{
Ecore_Event_Handler *eh;
eh = (Ecore_Event_Handler *)ll;
if (!eh->delete_me)
{
if (eh->type == e->type)
{
if (!eh->func(eh->data, e->type, e->event))
break;
}
}
}
ecore_raw_event_type = ECORE_EVENT_NONE;
ecore_raw_event_event = NULL;
}
}
while (events) _ecore_event_del(events);
if (!event_handlers_delete_me) return;
for (l = (Ecore_List *)event_handlers; l;)
{
Ecore_Event_Handler *eh;
eh = (Ecore_Event_Handler *)l;
l = l->next;
if (eh->delete_me)
{
event_handlers = _ecore_list_remove(event_handlers, eh);
ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE);
free(eh);
}
}
event_handlers_delete_me = 0;
}
void *
_ecore_event_exe_exit_new(void)
{
Ecore_Event_Exe_Exit *e;
e = calloc(1, sizeof(Ecore_Event_Exe_Exit));
return e;
}
void
_ecore_event_exe_exit_free(void *data, void *ev)
{
Ecore_Event_Exe_Exit *e;
e = ev;
if (e->exe) _ecore_exe_free(e->exe);
free(e);
}
void *
_ecore_event_signal_user_new(void)
{
Ecore_Event_Signal_User *e;
e = calloc(1, sizeof(Ecore_Event_Signal_User));
return e;
}
void
_ecore_event_signal_user_free(void *data, void *ev)
{
Ecore_Event_Signal_User *e;
e = ev;
free(e);
}
void *
_ecore_event_signal_hup_new(void)
{
Ecore_Event_Signal_Hup *e;
e = calloc(1, sizeof(Ecore_Event_Signal_Hup));
return e;
}
void
_ecore_event_signal_hup_free(void *data, void *ev)
{
Ecore_Event_Signal_Hup *e;
e = ev;
free(e);
}
void *
_ecore_event_signal_exit_new(void)
{
Ecore_Event_Signal_Exit *e;
e = calloc(1, sizeof(Ecore_Event_Signal_Exit));
return e;
}
void
_ecore_event_signal_exit_free(void *data, void *ev)
{
Ecore_Event_Signal_Exit *e;
e = ev;
free(e);
}
void *
_ecore_event_signal_power_new(void)
{
Ecore_Event_Signal_Power *e;
e = calloc(1, sizeof(Ecore_Event_Signal_Power));
return e;
}
void
_ecore_event_signal_power_free(void *data, void *ev)
{
Ecore_Event_Signal_Power *e;
e = ev;
free(e);
}

View File

@ -0,0 +1,272 @@
#include "ecore_private.h"
#include "Ecore.h"
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
static Ecore_Exe *exes = NULL;
/**
* Spawn off a child process and return a handle to that process.
* @param exe_cmd The command-line to run as if typed in a shell
* @param data A generic data pointer to attach to the process handle
* @return A process handle to the spawned off process
*
* This function will fork and execute the command line @p exe_cmd as specified
* using the system shell (/bin/sh). The data pointer @p data is attached to
* the process handle returned. The application does not need to free or keep
* the process handle returned unless it has a use for it. It should be noted
* that the process handle is only valid until a child process terminated
* event is recieved. After all handlers for this child process terminated
* event have been called, this process handle will be freed and cleaned up
* by Ecore, and so any references to it will become invalid.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Exe *
ecore_exe_run(const char *exe_cmd, const void *data)
{
Ecore_Exe *exe;
pid_t pid;
if (!exe_cmd) return NULL;
pid = fork();
if (pid)
{
exe = calloc(1, sizeof(Ecore_Exe));
if (!exe)
{
kill(pid, SIGKILL);
return NULL;
}
ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE);
exe->pid = pid;
exe->data = (void *)data;
exes = _ecore_list_append(exes, exe);
return exe;
}
setsid();
execl("/bin/sh", "/bin/sh", "-c", exe_cmd, NULL);
exit(0);
return NULL;
}
/**
* Free an exe handle.
* @param exe
* @return The data pointer set on execution of the program
*
* This frees an exe handle (but does not affect the process that was spawned
* that this handle was a result of) and returns the data pointer set on
* executable start. This does mean there is no handle for the spawned
* process anymore.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_exe_free(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_free");
return NULL;
}
return _ecore_exe_free(exe);
}
/**
* Get the process ID of a spawned process.
* @param exe The process handle returned by ecore_exe_run()
* @return A system process ID of the process handle
*
* This function returns the system process ID of a spawned off child process.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
pid_t
ecore_exe_pid_get(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_pid_get");
return -1;
}
return exe->pid;
}
/**
* Get the data pointer attached to a process handle.
* @param exe The process handle returned by ecore_exe_run()
* @return An pointer to the attached data of the process handle
*
* This function returns the data pointer attached to the spawned off process
* whose handle is @p exe.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_exe_data_get(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_data_get");
return NULL;
}
return exe->data;
}
/**
* Pause a spawned process.
* @param exe The process handle to control
*
* This function pauses a process that was spawned.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_exe_pause(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_pause");
return;
}
kill(exe->pid, SIGSTOP);
}
/**
* Continue a paused process.
* @param exe The process handle to control
*
* This Continues a process. This is only useful if the process has already
* been paused by something like ecore_exe_pause().
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_exe_continue(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_continue");
return;
}
kill(exe->pid, SIGCONT);
}
/**
* Terminate a process.
* @param exe The process handle to control
*
* This function asks a process to terminate.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_exe_terminate(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_terminate");
return;
}
kill(exe->pid, SIGTERM);
}
/**
* Kill a process.
* @param exe The process handle to control
*
* This function ills off a process, and that process has no choice and will
* exit as a result of this function, without having a chance to clean up,
* save data, or safely shut down.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_exe_kill(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_kill");
return;
}
kill(exe->pid, SIGKILL);
}
/**
* Send a user signal to a process.
* @param exe The process handle to control
* @param num The signal number to send to the process
*
* This function sends a user signal (SIGUSR) to a process. @p num determines
* what numbered user signal to send. This may be either 1 or 2. Other values
* are illegal and will be ignored, with this function doing nothing.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_exe_signal(Ecore_Exe *exe, int num)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_signal");
return;
}
if (num == 1)
kill(exe->pid, SIGUSR1);
else if (num == 2)
kill(exe->pid, SIGUSR2);
}
/**
* Send a HUP signal to a process.
* @param exe The process handle to control
*
* This function sends a HUP signal to the specified process.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_exe_hup(Ecore_Exe *exe)
{
if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE))
{
ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE,
"ecore_exe_hup");
return;
}
kill(exe->pid, SIGHUP);
}
void
_ecore_exe_shutdown(void)
{
while (exes) _ecore_exe_free(exes);
}
Ecore_Exe *
_ecore_exe_find(pid_t pid)
{
Ecore_List *l;
for (l = (Ecore_List *)exes; l; l = l->next)
{
Ecore_Exe *exe;
exe = (Ecore_Exe *)l;
if (exe->pid == pid) return exe;
}
return NULL;
}
void *
_ecore_exe_free(Ecore_Exe *exe)
{
void *data;
data = exe->data;
exes = _ecore_list_remove(exes, exe);
ECORE_MAGIC_SET(exe, ECORE_MAGIC_NONE);
free(exe);
return data;
}

View File

@ -0,0 +1,116 @@
#include "ecore_private.h"
#include "Ecore.h"
static Ecore_Idle_Enterer *idle_enterers = NULL;
static int idle_enterers_delete_me = 0;
/**
* Add an idle enterer handler.
* @param func The function to call when entering an idle state.
* @param data The data to be passed to the @p func call
* @return A handle to the idle enterer callback
*
* This function adds an idle enterer handler and returns its handle on success
* or NULL on failure. Idle enterers are called just before he program goes
* int an idle state where it is waiting on timers to time out, data to come
* in on file descriptors, etc. The program will be in a "sleeping" state
* after all the idle enterer callbacks are called. This is a good callback to
* use to update your program's state if it has a state engine. Do all your
* heavy processing here to update state (like drawing etc.). When @p func
* is called, it will be passed the pointer @p data.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Idle_Enterer *
ecore_idle_enterer_add(int (*func) (void *data), const void *data)
{
Ecore_Idle_Enterer *ie;
if (!func) return NULL;
ie = calloc(1, sizeof(Ecore_Idle_Enterer));
if (!ie) return NULL;
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLE_ENTERER);
ie->func = func;
ie->data = (void *)data;
idle_enterers = _ecore_list_append(idle_enterers, ie);
return ie;
}
/**
* Delete an idle enter handler.
* @param idle_enterer The idle enterer to delete
*
* Delete the specified @p idle_enterer from the set of idle_enterers that are
* executed during main loop execution. On success the data pointer that was
* being passed to the idle handler function, set by ecore_idle_enterer_add()
* will be returned.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer)
{
if (!ECORE_MAGIC_CHECK(idle_enterer, ECORE_MAGIC_IDLE_ENTERER))
{
ECORE_MAGIC_FAIL(idle_enterer, ECORE_MAGIC_IDLE_ENTERER,
"ecore_idle_enterer_del");
return NULL;
}
idle_enterer->delete_me = 1;
idle_enterers_delete_me = 1;
return idle_enterer->data;
}
void
_ecore_idle_enterer_shutdown(void)
{
while (idle_enterers)
{
Ecore_Idle_Enterer *ie;
ie = idle_enterers;
idle_enterers = _ecore_list_remove(idle_enterers, ie);
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
idle_enterers_delete_me = 0;
}
void
_ecore_idle_enterer_call(void)
{
Ecore_List *l;
for (l = (Ecore_List *)idle_enterers; l; l = l->next)
{
Ecore_Idle_Enterer *ie;
ie = (Ecore_Idle_Enterer *)l;
if (!ie->delete_me)
{
if (!ie->func(ie->data)) ecore_idle_enterer_del(ie);
}
}
if (idle_enterers_delete_me)
{
for (l = (Ecore_List *)idle_enterers; l;)
{
Ecore_Idle_Enterer *ie;
ie = (Ecore_Idle_Enterer *)l;
l = l->next;
if (ie->delete_me)
{
idle_enterers = _ecore_list_remove(idle_enterers, ie);
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
}
idle_enterers_delete_me = 0;
}
}
int
_ecore_idle_enterer_exist(void)
{
if (idle_enterers) return 1;
return 0;
}

View File

@ -0,0 +1,119 @@
#include "ecore_private.h"
#include "Ecore.h"
static Ecore_Idler *idlers = NULL;
static int idlers_delete_me = 0;
/**
* Add an idler handler.
* @param func The function to call when idling.
* @param data The data to be passed to this @p func call
* @return A idler handle
*
* This function adds an idler handler and returns its handle on success, or
* NULL on failure. Idlers will get called after idle enterer calls have all
* been called and the program is in an idle state waiting on data or timers.
* If no idler functions are set the process literally goes to sleep and uses
* no CPU. If You have idler functions set they will be called continuously
* during this "idle" time with your process consuming as much CPU as it can
* get to do so. This is useful for when there are interfaces that require
* polling and timers will mean too slow a response from the process if polling
* is done by timers.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Idler *
ecore_idler_add(int (*func) (void *data), const void *data)
{
Ecore_Idler *ie;
if (!func) return NULL;
ie = calloc(1, sizeof(Ecore_Idler));
if (!ie) return NULL;
ECORE_MAGIC_SET(ie, ECORE_MAGIC_IDLER);
ie->func = func;
ie->data = (void *)data;
idlers = _ecore_list_append(idlers, ie);
return ie;
}
/**
* Delete an idler handler.
* @param idler The idler to delete
*
* Delete the specified @p idler from the set of idlers that are executed
* during main loop execution. On success the data pointer set by
* ecore_idler_add() and passed to the idler function is returned, or NULL
* on failure.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_idler_del(Ecore_Idler *idler)
{
if (!ECORE_MAGIC_CHECK(idler, ECORE_MAGIC_IDLER))
{
ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER,
"ecore_idler_del");
return NULL;
}
idler->delete_me = 1;
idlers_delete_me = 1;
return idler->data;
}
void
_ecore_idler_shutdown(void)
{
while (idlers)
{
Ecore_Idler *ie;
ie = idlers;
idlers = _ecore_list_remove(idlers, ie);
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
idlers_delete_me = 0;
}
int
_ecore_idler_call(void)
{
Ecore_List *l;
for (l = (Ecore_List *)idlers; l; l = l->next)
{
Ecore_Idler *ie;
ie = (Ecore_Idler *)l;
if (!ie->delete_me)
{
if (!ie->func(ie->data)) ecore_idler_del(ie);
}
}
if (idlers_delete_me)
{
for (l = (Ecore_List *)idlers; l;)
{
Ecore_Idler *ie;
ie = (Ecore_Idler *)l;
l = l->next;
if (ie->delete_me)
{
idlers = _ecore_list_remove(idlers, ie);
ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE);
free(ie);
}
}
idlers_delete_me = 0;
}
if (idlers) return 1;
return 0;
}
int
_ecore_idler_exist(void)
{
if (idlers) return 1;
return 0;
}

View File

@ -0,0 +1,172 @@
#include "ecore_private.h"
#include "Ecore.h"
void *
_ecore_list_append(void *in_list, void *in_item)
{
Ecore_List *l, *new_l;
Ecore_List *list, *item;
list = in_list;
item = in_item;
new_l = item;
new_l->next = NULL;
if (!list)
{
new_l->prev = NULL;
new_l->last = new_l;
return new_l;
}
if (list->last) l = list->last;
else for (l = list; l; l = l->next);
l->next = new_l;
new_l->prev = l;
list->last = new_l;
return list;
}
void *
_ecore_list_prepend(void *in_list, void *in_item)
{
Ecore_List *new_l;
Ecore_List *list, *item;
list = in_list;
item = in_item;
new_l = item;
new_l->prev = NULL;
if (!list)
{
new_l->next = NULL;
new_l->last = new_l;
return new_l;
}
new_l->next = list;
list->prev = new_l;
new_l->last = list->last;
list->last = NULL;
return new_l;
}
void *
_ecore_list_append_relative(void *in_list, void *in_item, void *in_relative)
{
Ecore_List *l;
Ecore_List *list, *item, *relative;
list = in_list;
item = in_item;
relative = in_relative;
for (l = list; l; l = l->next)
{
if (l == relative)
{
Ecore_List *new_l;
new_l = item;
if (l->next)
{
new_l->next = l->next;
l->next->prev = new_l;
}
else new_l->next = NULL;
l->next = new_l;
new_l->prev = l;
if (!new_l->next)
list->last = new_l;
return list;
}
}
return _ecore_list_append(list, item);
}
void *
_ecore_list_prepend_relative(void *in_list, void *in_item, void *in_relative)
{
Ecore_List *l;
Ecore_List *list, *item, *relative;
list = in_list;
item = in_item;
relative = in_relative;
for (l = list; l; l = l->next)
{
if (l == relative)
{
Ecore_List *new_l;
new_l = item;
new_l->prev = l->prev;
new_l->next = l;
l->prev = new_l;
if (new_l->prev)
{
new_l->prev->next = new_l;
if (!new_l->next)
list->last = new_l;
return list;
}
else
{
if (!new_l->next)
new_l->last = new_l;
else
{
new_l->last = list->last;
list->last = NULL;
}
return new_l;
}
}
}
return _ecore_list_prepend(list, item);
}
void *
_ecore_list_remove(void *in_list, void *in_item)
{
Ecore_List *return_l;
Ecore_List *list, *item;
/* checkme */
if(!in_list)
return in_list;
list = in_list;
item = in_item;
if (!item) return list;
if (item->next)
item->next->prev = item->prev;
if (item->prev)
{
item->prev->next = item->next;
return_l = list;
}
else
{
return_l = item->next;
if (return_l)
return_l->last = list->last;
}
if (item == list->last)
list->last = item->prev;
item->next = NULL;
item->prev = NULL;
return return_l;
}
void *
_ecore_list_find(void *in_list, void *in_item)
{
Ecore_List *l;
Ecore_List *list, *item;
list = in_list;
item = in_item;
for (l = list; l; l = l->next)
{
if (l == item) return item;
}
return NULL;
}

View File

@ -0,0 +1,525 @@
#include "ecore_private.h"
#include "Ecore.h"
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
static int _ecore_main_select(double timeout);
static void _ecore_main_fd_handlers_cleanup(void);
static void _ecore_main_fd_handlers_call(void);
static int _ecore_main_fd_handlers_buf_call(void);
static void _ecore_main_loop_iterate_internal(int once_only);
static int in_main_loop = 0;
static int do_quit = 0;
static Ecore_Fd_Handler *fd_handlers = NULL;
static int fd_handlers_delete_me = 0;
/**
* Run 1 iteration of the main loop and process everything on the queue.
*
* This function Processes 1 iteration of the main loop, handling anything on
* the queue. See ecore_main_loop_begin() for more information.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_main_loop_iterate(void)
{
_ecore_main_loop_iterate_internal(1);
}
/**
* Run the application main loop.
*
* This function does not return until ecore_main_loop_quit() is called. It
* will keep looping internally and call all callbacks set up to handle timers,
* idle state and events Ecore recieves from X, fd's, IPC, signals etc. and
* anything else that has registered a handler with ecore itself.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_main_loop_begin(void)
{
in_main_loop++;
for (;do_quit == 0;) _ecore_main_loop_iterate_internal(0);
do_quit = 0;
in_main_loop--;
}
/**
* Quit the main loop after it is done processing.
*
* This function will flag a quit of the main loop once the current loop has
* finished processing all events. It will not quit instantly, so expect more
* callbacks to be called after this command has been issued.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_main_loop_quit(void)
{
do_quit = 1;
}
/**
* Add a handler for read/write notification of a file descriptor.
* @param fd The file descriptor to watch
* @param flags To watch it for read and/or write ability
* @param func The function to call when the file descriptor becomes active
* @param data The data to pass to the @p func call
* @param buf_func The function to call to check if any data has been buffered and already read from the fd.
* @param buf_data The data to pass to the @p buf_func call
* @return A fd handler handle
*
* This adds a fd handler, calling @p func whenever the fd is active for
* read or write (or both) depending what flags were set as @p flags. On
* failure NULL is returned. The @p func call will the triggered during
* execution of ecore_main_loop_begin() when a file descriptor (fd) is
* available for reading or writing (or both). The #p buf_func call is called
* during event loop handling to check if data that has already been read from
* the file descriptor is in a buffer and is available to read. This function
* is optional and can be NULL. If it is called it will be passed @p buf_data
* as the data parameter.
*
* Example:
*
* @code
* int fd;
* Ecore_Fd_Handler *fdh;
*
* fd = open("/tmp/fifo", O_RDONLY);
* fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, func_read_fifo, NULL);
* @endcode
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Fd_Handler *
ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, int (*func) (void *data, Ecore_Fd_Handler *fd_handler), const void *data, int (*buf_func) (void *buf_data, Ecore_Fd_Handler *fd_handler), const void *buf_data)
{
Ecore_Fd_Handler *fdh;
if ((fd < 0) ||
(flags == 0) ||
(!func)) return NULL;
fdh = calloc(1, sizeof(Ecore_Fd_Handler));
if (!fdh) return NULL;
ECORE_MAGIC_SET(fdh, ECORE_MAGIC_FD_HANDLER);
fdh->fd = fd;
fdh->flags = flags;
fdh->read_active = 0;
fdh->write_active = 0;
fdh->delete_me = 0;
fdh->func = func;
fdh->data = (void *)data;
fdh->buf_func = buf_func;
fdh->buf_data = (void *)buf_data;
fd_handlers = _ecore_list_append(fd_handlers, fdh);
return fdh;
}
/**
* Delete a handler for file descriptors.
*
* @param fd_handler The handler to delete
* @return The data pointer set for the fd_handler
*
* This deletes a file descriptore (fd) handler and on success returns the data
* pointer that was being passed to it, set by ecore_main_fd_handler_add().
* NUll is returned on failure.
*/
void *
ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler)
{
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_del");
return NULL;
}
fd_handler->delete_me = 1;
fd_handlers_delete_me = 1;
return fd_handler->data;
}
/**
* Return the file descriptor that the handler is handling
* @param fd_handler The fd handler to query
* @return The fd the handler is watching
*
* This returns the fd the @p fd_handler is monitoring.
*/
int
ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler)
{
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_fd_get");
return -1;
}
return fd_handler->fd;
}
/**
* Return if read or write is active on the fd
* @param fd_handler The handler to query
* @param flags The flags to query
* @return The active state of read or write on the fd, or both
*
* Return if the fd the handler is watching is active for read, write or both.
* The @p flags parameter determines what youw ant to query, and 1 is returned
* if the hanldere reports an active state for any of the values in
* @p flags since this is the same bitmask the handler was set up with. 0 is
* returned if the fd is not active for the @p flags passed in.
*/
int
ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
{
int ret;
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_active_get");
return 0;
}
ret = 0;
if ((flags & ECORE_FD_READ) && (fd_handler->read_active)) ret = 1;
if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active)) ret = 1;
return ret;
}
/**
* Set what active stream the fd should be monitoring
* @param fd_handler The handler to modify
* @param flags The flags to be watching
*
* This function changes if an fd shoudl be watched for read, write or both.
*/
void
ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags)
{
if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER))
{
ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER,
"ecore_main_fd_handler_active_set");
return;
}
fd_handler->flags = flags;
}
void
_ecore_main_shutdown(void)
{
if (in_main_loop)
{
fprintf(stderr,
"\n"
"*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n"
"*** Program may crash or behave strangely now.\n");
return;
}
while (fd_handlers)
{
Ecore_Fd_Handler *fdh;
fdh = fd_handlers;
fd_handlers = _ecore_list_remove(fd_handlers, fdh);
ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
free(fdh);
}
fd_handlers_delete_me = 0;
}
static int
_ecore_main_select(double timeout)
{
struct timeval tv, *t;
fd_set rfds, wfds;
int max_fd;
int ret;
Ecore_List *l;
t = NULL;
if (timeout > 0.0)
{
int sec, usec;
sec = (int)timeout;
usec = (int)((timeout - (double)sec) * 1000000);
tv.tv_sec = sec;
tv.tv_usec = usec;
t = &tv;
}
else if (timeout == 0.0)
{
tv.tv_sec = 0;
tv.tv_usec = 0;
t = &tv;
}
max_fd = 0;
FD_ZERO(&rfds);
FD_ZERO(&wfds);
for (l = (Ecore_List *)fd_handlers; l; l = l->next)
{
Ecore_Fd_Handler *fdh;
fdh = (Ecore_Fd_Handler *)l;
if (fdh->flags & ECORE_FD_READ)
{
FD_SET(fdh->fd, &rfds);
if (fdh->fd > max_fd) max_fd = fdh->fd;
}
if (fdh->flags & ECORE_FD_WRITE)
{
FD_SET(fdh->fd, &wfds);
if (fdh->fd > max_fd) max_fd = fdh->fd;
}
}
if (_ecore_signal_count_get()) return -1;
ret = select(max_fd + 1, &rfds, &wfds, NULL, t);
if (ret < 0)
{
if (errno == EINTR) return -1;
}
if (ret > 0)
{
for (l = (Ecore_List *)fd_handlers; l; l = l->next)
{
Ecore_Fd_Handler *fdh;
fdh = (Ecore_Fd_Handler *)l;
if (!fdh->delete_me)
{
if (FD_ISSET(fdh->fd, &rfds))
fdh->read_active = 1;
if (FD_ISSET(fdh->fd, &wfds))
fdh->write_active = 1;
}
}
_ecore_main_fd_handlers_cleanup();
return 1;
}
return 0;
}
static void
_ecore_main_fd_handlers_cleanup(void)
{
Ecore_List *l;
if (!fd_handlers_delete_me) return;
for (l = (Ecore_List *)fd_handlers; l;)
{
Ecore_Fd_Handler *fdh;
fdh = (Ecore_Fd_Handler *)l;
l = l->next;
if (fdh->delete_me)
{
fd_handlers = _ecore_list_remove(fd_handlers, fdh);
ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE);
free(fdh);
}
}
fd_handlers_delete_me = 0;
}
static void
_ecore_main_fd_handlers_call(void)
{
Ecore_List *l;
for (l = (Ecore_List *)fd_handlers; l; l = l->next)
{
Ecore_Fd_Handler *fdh;
fdh = (Ecore_Fd_Handler *)l;
if (!fdh->delete_me)
{
if ((fdh->read_active) || (fdh->write_active))
{
if (!fdh->func(fdh->data, fdh))
{
fdh->delete_me = 1;
fd_handlers_delete_me = 1;
}
fdh->read_active = 0;
fdh->write_active = 0;
}
}
}
}
static int
_ecore_main_fd_handlers_buf_call(void)
{
Ecore_List *l;
int ret;
ret = 0;
for (l = (Ecore_List *)fd_handlers; l; l = l->next)
{
Ecore_Fd_Handler *fdh;
fdh = (Ecore_Fd_Handler *)l;
if (!fdh->delete_me)
{
if (fdh->buf_func)
{
if (fdh->buf_func(fdh->buf_data, fdh))
{
ret |= fdh->func(fdh->data, fdh);
fdh->read_active = 1;
}
}
}
}
return ret;
}
static void
_ecore_main_loop_iterate_internal(int once_only)
{
double next_time;
int have_event;
int have_signal;
in_main_loop++;
/* expire any timers */
{
double now;
now = ecore_time_get();
while (_ecore_timer_call(now));
_ecore_timer_cleanup();
}
/* any timers re-added as a result of these are allowed to go */
_ecore_timer_enable_new();
/* process signals into events .... */
while (_ecore_signal_count_get()) _ecore_signal_call();
if (_ecore_event_exist())
{
have_event = 1;
have_signal = 1;
goto process_events;
}
/* call idle enterers ... */
if (!once_only)
_ecore_idle_enterer_call();
else
{
int ret;
have_event = have_signal = 0;
ret = _ecore_main_select(0);
if (ret > 0) have_event = 1;
if (_ecore_signal_count_get() > 0) have_signal = 1;
if (have_signal || have_event)
goto process_events;
}
/* if these calls caused any biuffered events to appear - deal with them */
while (_ecore_main_fd_handlers_buf_call());
/* if ther are any - jump to processing them */
if (_ecore_event_exist())
{
have_event = 1;
have_signal = 1;
goto process_events;
}
if (once_only)
{
_ecore_idle_enterer_call();
in_main_loop--;
return;
}
start_loop:
/* init flags */
have_event = have_signal = 0;
next_time = _ecore_timer_next_get();
/* no timers */
if (next_time < 0)
{
/* no idlers */
if (!_ecore_idler_exist())
{
int ret;
ret = _ecore_main_select(-1);
if (ret > 0) have_event = 1;
if (_ecore_signal_count_get() > 0) have_signal = 1;
}
/* idlers */
else
{
for (;;)
{
int ret;
if (!_ecore_idler_call()) goto start_loop;
if (_ecore_event_exist()) break;
ret = _ecore_main_select(0);
if (ret > 0) have_event = 1;
if (_ecore_signal_count_get() > 0) have_signal = 1;
if (have_event || have_signal) break;
next_time = _ecore_timer_next_get();
if (next_time >= 0) goto start_loop;
}
}
}
/* timers */
else
{
/* no idlers */
if (!_ecore_idler_exist())
{
int ret;
ret = _ecore_main_select(next_time);
if (ret > 0) have_event = 1;
if (_ecore_signal_count_get() > 0) have_signal = 1;
}
/* idlers */
else
{
for (;;)
{
double cur_time, t;
int ret;
if (!_ecore_idler_call()) goto start_loop;
if (_ecore_event_exist()) break;
ret = _ecore_main_select(0);
if (ret > 0) have_event = 1;
if (_ecore_signal_count_get() > 0) have_signal = 1;
if ((have_event) || (have_signal)) break;
cur_time = ecore_time_get();
t = ecore_time_get() - cur_time;
if (t >= next_time) break;
next_time = _ecore_timer_next_get();
if (next_time < 0) goto start_loop;
}
}
}
/* call the fd handler per fd that became alive... */
/* this should read or write any data to the monitored fd and then */
/* post events onto the ecore event pipe if necessary */
process_events:
if (have_event) _ecore_main_fd_handlers_call();
do
{
/* process signals into events .... */
while (_ecore_signal_count_get()) _ecore_signal_call();
/* handle events ... */
_ecore_event_call();
_ecore_main_fd_handlers_cleanup();
}
while (_ecore_main_fd_handlers_buf_call());
if (once_only) _ecore_idle_enterer_call();
in_main_loop--;
}

View File

@ -0,0 +1,192 @@
#ifndef _ECORE_PRIVATE_H
#define _ECORE_PRIVATE_H
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#define ECORE_MAGIC_NONE 0x1234fedc
#define ECORE_MAGIC_EXE 0xf7e812f5
#define ECORE_MAGIC_TIMER 0xf7d713f4
#define ECORE_MAGIC_IDLER 0xf7c614f3
#define ECORE_MAGIC_IDLE_ENTERER 0xf7b515f2
#define ECORE_MAGIC_FD_HANDLER 0xf7a416f1
#define ECORE_MAGIC_EVENT_HANDLER 0xf79317f0
#define ECORE_MAGIC_EVENT_FILTER 0xf78218ff
#define ECORE_MAGIC_EVENT 0xf77119fe
#define ECORE_MAGIC Ecore_Magic __magic
#define ECORE_MAGIC_SET(d, m) (d)->__magic = (m)
#define ECORE_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m)))
#define ECORE_MAGIC_FAIL(d, m, fn) _ecore_magic_fail((d), (d) ? (d)->__magic : 0, (m), (fn));
typedef int Ecore_Magic;
typedef struct _Ecore_List Ecore_List;
struct _Ecore_List
{
Ecore_List *next, *prev;
Ecore_List *last;
};
#ifndef _ECORE_H
enum _Ecore_Fd_Handler_Flags
{
ECORE_FD_READ = 1,
ECORE_FD_WRITE = 2
};
typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
typedef struct _Ecore_Exe Ecore_Exe;
typedef struct _Ecore_Timer Ecore_Timer;
typedef struct _Ecore_Idler Ecore_Idler;
typedef struct _Ecore_Idle_Enterer Ecore_Idle_Enterer;
typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler;
typedef struct _Ecore_Event_Handler Ecore_Event_Handler;
typedef struct _Ecore_Event_Filter Ecore_Event_Filter;
typedef struct _Ecore_Event Ecore_Event;
struct _Ecore_Exe
{
Ecore_List __list_data;
ECORE_MAGIC;
pid_t pid;
void *data;
};
struct _Ecore_Timer
{
Ecore_List __list_data;
ECORE_MAGIC;
double in;
double at;
char delete_me : 1;
char just_added : 1;
int (*func) (void *data);
void *data;
};
struct _Ecore_Idler
{
Ecore_List __list_data;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
struct _Ecore_Idle_Enterer
{
Ecore_List __list_data;
ECORE_MAGIC;
int delete_me : 1;
int (*func) (void *data);
void *data;
};
struct _Ecore_Fd_Handler
{
Ecore_List __list_data;
ECORE_MAGIC;
int fd;
Ecore_Fd_Handler_Flags flags;
int read_active : 1;
int write_active : 1;
int delete_me : 1;
int (*func) (void *data, Ecore_Fd_Handler *fd_handler);
void *data;
int (*buf_func) (void *data, Ecore_Fd_Handler *fd_handler);
void *buf_data;
};
struct _Ecore_Event_Handler
{
Ecore_List __list_data;
ECORE_MAGIC;
int type;
int delete_me : 1;
int (*func) (void *data, int type, void *event);
void *data;
};
struct _Ecore_Event_Filter
{
Ecore_List __list_data;
ECORE_MAGIC;
int delete_me : 1;
void * (*func_start) (void *data);
int (*func_filter) (void *data, void *loop_data, int type, void *event);
void (*func_end) (void *data, void *loop_data);
void *loop_data;
void *data;
};
struct _Ecore_Event
{
Ecore_List __list_data;
ECORE_MAGIC;
int type;
void *event;
int delete_me : 1;
void (*func_free) (void *data, void *ev);
void *data;
};
#endif
void _ecore_magic_fail(void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname);
void _ecore_timer_shutdown(void);
void _ecore_timer_cleanup(void);
void _ecore_timer_enable_new(void);
double _ecore_timer_next_get(void);
int _ecore_timer_call(double when);
void _ecore_idler_shutdown(void);
int _ecore_idler_call(void);
int _ecore_idler_exist(void);
void _ecore_idle_enterer_shutdown(void);
void _ecore_idle_enterer_call(void);
int _ecore_idle_enterer_exist(void);
void _ecore_event_shutdown(void);
int _ecore_event_exist(void);
Ecore_Event *_ecore_event_add(int type, void *ev, void (*func_free) (void *data, void *ev), void *data);
void *_ecore_event_del(Ecore_Event *event);
void _ecore_event_call(void);
void *_ecore_event_exe_exit_new(void);
void _ecore_event_exe_exit_free(void *data, void *ev);
void *_ecore_event_signal_user_new(void);
void _ecore_event_signal_user_free(void *data, void *ev);
void *_ecore_event_signal_hup_new(void);
void _ecore_event_signal_hup_free(void *data, void *ev);
void *_ecore_event_signal_exit_new(void);
void _ecore_event_signal_exit_free(void *data, void *ev);
void *_ecore_event_signal_power_new(void);
void _ecore_event_signal_power_free(void *data, void *ev);
void _ecore_main_shutdown(void);
void _ecore_signal_shutdown(void);
void _ecore_signal_init(void);
int _ecore_signal_count_get(void);
void _ecore_signal_call(void);
void _ecore_exe_shutdown(void);
Ecore_Exe *_ecore_exe_find(pid_t pid);
void *_ecore_exe_free(Ecore_Exe *exe);
void *_ecore_list_append (void *in_list, void *in_item);
void *_ecore_list_prepend (void *in_list, void *in_item);
void *_ecore_list_append_relative (void *in_list, void *in_item, void *in_relative);
void *_ecore_list_prepend_relative (void *in_list, void *in_item, void *in_relative);
void *_ecore_list_remove (void *in_list, void *in_item);
void *_ecore_list_find (void *in_list, void *in_item);
#endif

View File

@ -0,0 +1,276 @@
#include "ecore_private.h"
#include "Ecore.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <unistd.h>
static void _ecore_signal_callback_set(int sig, void (*func)(int sig));
static void _ecore_signal_callback_ignore(int sig);
static void _ecore_signal_callback_sigchld(int sig);
static void _ecore_signal_callback_sigusr1(int sig);
static void _ecore_signal_callback_sigusr2(int sig);
static void _ecore_signal_callback_sighup(int sig);
static void _ecore_signal_callback_sigquit(int sig);
static void _ecore_signal_callback_sigint(int sig);
static void _ecore_signal_callback_sigterm(int sig);
static void _ecore_signal_callback_sigpwr(int sig);
static int sigchld_count = 0;
static int sigusr1_count = 0;
static int sigusr2_count = 0;
static int sighup_count = 0;
static int sigquit_count = 0;
static int sigint_count = 0;
static int sigterm_count = 0;
static int sigpwr_count = 0;
static int sig_count = 0;
void
_ecore_signal_shutdown(void)
{
_ecore_signal_callback_set(SIGPIPE, SIG_DFL);
_ecore_signal_callback_set(SIGALRM, SIG_DFL);
_ecore_signal_callback_set(SIGCHLD, SIG_DFL);
_ecore_signal_callback_set(SIGUSR1, SIG_DFL);
_ecore_signal_callback_set(SIGUSR2, SIG_DFL);
_ecore_signal_callback_set(SIGHUP, SIG_DFL);
_ecore_signal_callback_set(SIGQUIT, SIG_DFL);
_ecore_signal_callback_set(SIGINT, SIG_DFL);
_ecore_signal_callback_set(SIGTERM, SIG_DFL);
#ifdef SIGPWR
_ecore_signal_callback_set(SIGPWR, SIG_DFL);
#endif
sigchld_count = 0;
sigusr1_count = 0;
sigusr2_count = 0;
sighup_count = 0;
sigquit_count = 0;
sigint_count = 0;
sigterm_count = 0;
sigpwr_count = 0;
sig_count = 0;
}
void
_ecore_signal_init(void)
{
_ecore_signal_callback_set(SIGPIPE, _ecore_signal_callback_ignore);
_ecore_signal_callback_set(SIGALRM, _ecore_signal_callback_ignore);
_ecore_signal_callback_set(SIGCHLD, _ecore_signal_callback_sigchld);
_ecore_signal_callback_set(SIGUSR1, _ecore_signal_callback_sigusr1);
_ecore_signal_callback_set(SIGUSR2, _ecore_signal_callback_sigusr2);
_ecore_signal_callback_set(SIGHUP, _ecore_signal_callback_sighup);
_ecore_signal_callback_set(SIGQUIT, _ecore_signal_callback_sigquit);
_ecore_signal_callback_set(SIGINT, _ecore_signal_callback_sigint);
_ecore_signal_callback_set(SIGTERM, _ecore_signal_callback_sigterm);
#ifdef SIGPWR
_ecore_signal_callback_set(SIGPWR, _ecore_signal_callback_sigpwr);
#endif
}
int
_ecore_signal_count_get(void)
{
return sig_count;
}
void
_ecore_signal_call(void)
{
while (sigchld_count > 0)
{
pid_t pid;
int status;
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
{
if (WIFEXITED(status))
{
Ecore_Event_Exe_Exit *e;
e = _ecore_event_exe_exit_new();
if (e)
{
e->exit_code = WEXITSTATUS(status);
e->pid = pid;
e->exe = _ecore_exe_find(pid);
_ecore_event_add(ECORE_EVENT_EXE_EXIT, e,
_ecore_event_exe_exit_free, NULL);
}
}
}
sigchld_count--;
sig_count--;
}
while (sigusr1_count > 0)
{
Ecore_Event_Signal_User *e;
e = _ecore_event_signal_user_new();
if (e)
{
e->number = 1;
_ecore_event_add(ECORE_EVENT_SIGNAL_USER, e,
_ecore_event_signal_user_free, NULL);
}
sigusr1_count--;
sig_count--;
}
while (sigusr2_count > 0)
{
Ecore_Event_Signal_User *e;
e = _ecore_event_signal_user_new();
if (e)
{
e->number = 2;
_ecore_event_add(ECORE_EVENT_SIGNAL_USER, e,
_ecore_event_signal_user_free, NULL);
}
sigusr2_count--;
sig_count--;
}
while (sighup_count > 0)
{
Ecore_Event_Signal_Hup *e;
e = _ecore_event_signal_hup_new();
if (e)
{
_ecore_event_add(ECORE_EVENT_SIGNAL_HUP, e,
_ecore_event_signal_hup_free, NULL);
}
sighup_count--;
sig_count--;
}
while (sigquit_count > 0)
{
Ecore_Event_Signal_Exit *e;
e = _ecore_event_signal_exit_new();
if (e)
{
e->quit = 1;
_ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e,
_ecore_event_signal_exit_free, NULL);
}
sigquit_count--;
sig_count--;
}
while (sigint_count > 0)
{
Ecore_Event_Signal_Exit *e;
e = _ecore_event_signal_exit_new();
if (e)
{
e->interrupt = 1;
_ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e,
_ecore_event_signal_exit_free, NULL);
}
sigint_count--;
sig_count--;
}
while (sigterm_count > 0)
{
Ecore_Event_Signal_Exit *e;
e = _ecore_event_signal_exit_new();
if (e)
{
e->terminate = 1;
_ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e,
_ecore_event_signal_exit_free, NULL);
}
sigterm_count--;
sig_count--;
}
while (sigpwr_count > 0)
{
Ecore_Event_Signal_Power *e;
e = _ecore_event_signal_power_new();
if (e)
{
_ecore_event_add(ECORE_EVENT_SIGNAL_POWER, e,
_ecore_event_signal_power_free, NULL);
}
sigpwr_count--;
sig_count--;
}
}
static void
_ecore_signal_callback_set(int sig, void (*func)(int sig))
{
struct sigaction sa;
sa.sa_handler = func;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(sig, &sa, NULL);
}
static void
_ecore_signal_callback_ignore(int sig)
{
}
static void
_ecore_signal_callback_sigchld(int sig)
{
sigchld_count++;
sig_count++;
}
static void
_ecore_signal_callback_sigusr1(int sig)
{
sigusr1_count++;
sig_count++;
}
static void
_ecore_signal_callback_sigusr2(int sig)
{
sigusr2_count++;
sig_count++;
}
static void
_ecore_signal_callback_sighup(int sig)
{
sighup_count++;
sig_count++;
}
static void
_ecore_signal_callback_sigquit(int sig)
{
sigquit_count++;
sig_count++;
}
static void
_ecore_signal_callback_sigint(int sig)
{
sigint_count++;
sig_count++;
}
static void
_ecore_signal_callback_sigterm(int sig)
{
sigterm_count++;
sig_count++;
}
static void
_ecore_signal_callback_sigpwr(int sig)
{
sigpwr_count++;
sig_count++;
}

View File

@ -0,0 +1,22 @@
#include "ecore_private.h"
#include "Ecore.h"
#include <sys/time.h>
/**
* Get the current system time as a floating point value in seconds.
* @return The current time (since the epoch start) in seconds
*
* This function returns the current system time in seconds from 12:00am
* 1st Janruary 1970. The time is returned as a double precision floating point
* value to allow for fractions of a second to be determined.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
double
ecore_time_get(void)
{
struct timeval timev;
gettimeofday(&timev, NULL);
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
}

View File

@ -0,0 +1,231 @@
#include "ecore_private.h"
#include "Ecore.h"
/* FIXME: write code for timers... */
static void _ecore_timer_set(Ecore_Timer *timer, double at, double in, int (*func) (void *data), void *data);
static int timers_added = 0;
static int timers_delete_me = 0;
static Ecore_Timer *timers = NULL;
/**
* Add a timer to tick off in a specified time during main loop execution.
* @param in The number of seconds in which to expire the timer
* @param func The function to call when it expires
* @param data The data to pass to the function
* @return
*
* This function adds a timer and returns its handle on success and NULL on
* failure. The function @p func will be called in @p in seconds from the
* time this function call was made. The function @p func is passed the
* @p data pointer as its parameter.
*
* When the timer @p func is called, it must return a value of either 1 or 0.
* If it returns 1, it will be re-scheduled to repeat in the same interval
* after this timer was triggered (ie if this timer was triggered with an
* @p in value of 1.0 then the next timer will be triggered at the time this
* timer was called plus 1.0).
*
* @code
* #include <Ecore.h>
*
* Ecore_Timer *timer1 = NULL, *timer2 = NULL, *timer3 = NULL;
*
* int timer_tick(void *data)
* {
* printf("Tick timer %3.2f\n", ecore_time_get());
* return 1;
* }
*
* int timer_repeat(void *data)
* {
* printf("Repeat timer called at %3.2f seconds, data %p\n",
* ecore_time_get(), data);
* return 1;
* }
*
* int timer_once(void *data)
* {
* printf("Once only timer called at %3.2f seconds, data %p\n",
* ecore_time_get(), data);
* ecore_timer_del(timer2);
* return 0;
* }
*
* int main(int argc, char **argv)
* {
* ecore_init();
* ecore_app_args_set(argc, argv);
* timer1 = ecore_timer_add(5.0, timer_once, NULL);
* timer2 = ecore_timer_add(0.5, timer_repeat, NULL);
* timer3 = ecore_timer_add(1.0, timer_tick, NULL);
* ecore_main_loop_begin();
* ecore_shutdown();
* }
* @endcode
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Timer *
ecore_timer_add(double in, int (*func) (void *data), const void *data)
{
double now;
Ecore_Timer *timer;
if (!func) return NULL;
if (in < 0.0) in = 0.0;
timer = calloc(1, sizeof(Ecore_Timer));
if (!timer) return NULL;
ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER);
now = ecore_time_get();
_ecore_timer_set(timer, now + in, in, func, (void *)data);
return timer;
}
/**
* Delete the specified timer from the timer list.
* @param timer
* @return The data pointer set for the timer
*
* Delete the specified @p timer from the set of timers that are executed
* during main loop execution. This function returns the data parameter that
* was being passed to the callback on success, or NULL on failure. After this
* call returns the specified timer object @p timer is invalid and should not
* be used again. It will not get called again after deletion.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_timer_del(Ecore_Timer *timer)
{
if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER))
{
ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER,
"ecore_timer_del");
return NULL;
}
if (timer->delete_me) return timer->data;
timers_delete_me++;
timer->delete_me = 1;
return timer->data;
}
void
_ecore_timer_shutdown(void)
{
while (timers)
{
Ecore_Timer *timer;
timer = timers;
timers = _ecore_list_remove(timers, timer);
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
free(timer);
}
}
void
_ecore_timer_cleanup(void)
{
Ecore_List *l;
if (!timers_delete_me) return;
for (l = (Ecore_List *)timers; l;)
{
Ecore_Timer *timer;
timer = (Ecore_Timer *)l;
l = l->next;
if (timer->delete_me)
{
timers = _ecore_list_remove(timers, timer);
ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE);
free(timer);
timers_delete_me--;
if (timers_delete_me == 0) return;
}
}
timers_delete_me = 0;
}
void
_ecore_timer_enable_new(void)
{
Ecore_List *l;
if (!timers_added) return;
timers_added = 0;
for (l = (Ecore_List *)timers; l; l = l->next)
{
Ecore_Timer *timer;
timer = (Ecore_Timer *)l;
timer->just_added = 0;
}
}
double
_ecore_timer_next_get(void)
{
double now;
double in;
if (!timers) return -1;
now = ecore_time_get();
in = timers->at - now;
if (in < 0) in = 0;
return in;
}
int
_ecore_timer_call(double when)
{
Ecore_List *l;
Ecore_Timer *timer;
if (!timers) return 0;
for (l = (Ecore_List *)timers; l; l = l->next)
{
timer = (Ecore_Timer *)l;
if ((timer->at <= when) &&
(!timer->just_added) &&
(!timer->delete_me))
{
timers = _ecore_list_remove(timers, timer);
_ecore_timer_call(when);
if (timer->func(timer->data))
_ecore_timer_set(timer, timer->at + timer->in, timer->in, timer->func, timer->data);
else
free(timer);
return 1;
}
}
return 0;
}
static void
_ecore_timer_set(Ecore_Timer *timer, double at, double in, int (*func) (void *data), void *data)
{
Ecore_List *l;
timers_added = 1;
timer->at = at;
timer->in = in;
timer->func = func;
timer->data = data;
timer->just_added = 1;
if (timers)
{
for (l = ((Ecore_List *)(timers))->last; l; l = l->prev)
{
Ecore_Timer *t2;
t2 = (Ecore_Timer *)l;
if (timer->at > t2->at)
{
timers = _ecore_list_append_relative(timers, timer, t2);
return;
}
}
}
timers = _ecore_list_prepend(timers, timer);
}

View File

@ -0,0 +1,90 @@
#ifndef _ECORE_CON_H
#define _ECORE_CON_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ECORE_CON_PRIVATE_H
typedef void Ecore_Con_Server; /**< A connection handle */
typedef void Ecore_Con_Client; /**< A connection handle */
typedef enum _Ecore_Con_Type
{
ECORE_CON_LOCAL_USER,
ECORE_CON_LOCAL_SYSTEM,
ECORE_CON_REMOTE_SYSTEM,
} Ecore_Con_Type;
#endif
typedef struct _Ecore_Con_Event_Client_Add Ecore_Con_Event_Client_Add;
typedef struct _Ecore_Con_Event_Client_Del Ecore_Con_Event_Client_Del;
typedef struct _Ecore_Con_Event_Server_Add Ecore_Con_Event_Server_Add;
typedef struct _Ecore_Con_Event_Server_Del Ecore_Con_Event_Server_Del;
typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
struct _Ecore_Con_Event_Client_Add
{
Ecore_Con_Client *client;
};
struct _Ecore_Con_Event_Client_Del
{
Ecore_Con_Client *client;
};
struct _Ecore_Con_Event_Server_Add
{
Ecore_Con_Server *server;
};
struct _Ecore_Con_Event_Server_Del
{
Ecore_Con_Server *server;
};
struct _Ecore_Con_Event_Client_Data
{
Ecore_Con_Client *client;
void *data;
int size;
};
struct _Ecore_Con_Event_Server_Data
{
Ecore_Con_Server *server;
void *data;
int size;
};
extern int ECORE_CON_EVENT_CLIENT_ADD;
extern int ECORE_CON_EVENT_CLIENT_DEL;
extern int ECORE_CON_EVENT_SERVER_ADD;
extern int ECORE_CON_EVENT_SERVER_DEL;
extern int ECORE_CON_EVENT_CLIENT_DATA;
extern int ECORE_CON_EVENT_SERVER_DATA;
int ecore_con_init(void);
int ecore_con_shutdown(void);
Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type, char *name, int port, const void *data);
Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type, char *name, int port, const void *data);
void *ecore_con_server_del(Ecore_Con_Server *svr);
void *ecore_con_server_data_get(Ecore_Con_Server *svr);
int ecore_con_server_connected_get(Ecore_Con_Server *svr);
int ecore_con_server_send(Ecore_Con_Server *svr, void *data, int size);
int ecore_con_client_send(Ecore_Con_Client *cl, void *data, int size);
Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
void *ecore_con_client_del(Ecore_Con_Client *cl);
void ecore_con_client_data_set(Ecore_Con_Client *cl, const void *data);
void *ecore_con_client_data_get(Ecore_Con_Client *cl);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,30 @@
## Process this file with automake to produce Makefile.in
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore
libecore_con_la_LDFLAGS = -version-info 1:0:0 \
-L$(top_builddir)/src/lib/ecore/.libs
if BUILD_ECORE_CON
lib_LTLIBRARIES = libecore_con.la
include_HEADERS = \
Ecore_Con.h
libecore_con_la_SOURCES = \
ecore_con.c \
ecore_con_private.h
libecore_con_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la
libecore_con_la_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la
endif
EXTRA_DIST = \
Ecore_Con.h \
ecore_con.c \
ecore_con_private.h

View File

@ -0,0 +1,957 @@
#include "Ecore.h"
#include "ecore_private.h"
#include "ecore_con_private.h"
#include "Ecore_Con.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <netdb.h>
static void _ecore_con_server_free(Ecore_Con_Server *svr);
static void _ecore_con_client_free(Ecore_Con_Client *cl);
static int _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler);
static int _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler);
static int _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler);
static void _ecore_con_server_flush(Ecore_Con_Server *svr);
static void _ecore_con_client_flush(Ecore_Con_Client *cl);
static void _ecore_con_event_client_add_free(void *data, void *ev);
static void _ecore_con_event_client_del_free(void *data, void *ev);
static void _ecore_con_event_server_add_free(void *data, void *ev);
static void _ecore_con_event_server_del_free(void *data, void *ev);
static void _ecore_con_event_client_data_free(void *data, void *ev);
static void _ecore_con_event_server_data_free(void *data, void *ev);
int ECORE_CON_EVENT_CLIENT_ADD = 0;
int ECORE_CON_EVENT_CLIENT_DEL = 0;
int ECORE_CON_EVENT_SERVER_ADD = 0;
int ECORE_CON_EVENT_SERVER_DEL = 0;
int ECORE_CON_EVENT_CLIENT_DATA = 0;
int ECORE_CON_EVENT_SERVER_DATA = 0;
static Ecore_Con_Server *servers = NULL;
static int init_count = 0;
#define LENGTH_OF_SOCKADDR_UN(s) (strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_con_init(void)
{
init_count++;
if (!ECORE_CON_EVENT_CLIENT_ADD)
{
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();
ECORE_CON_EVENT_SERVER_DEL = ecore_event_type_new();
ECORE_CON_EVENT_CLIENT_DATA = ecore_event_type_new();
ECORE_CON_EVENT_SERVER_DATA = ecore_event_type_new();
}
return init_count;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_con_shutdown(void)
{
if (init_count > 0)
{
init_count--;
if (init_count > 0) return init_count;
while (servers) _ecore_con_server_free(servers);
}
return 0;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Con_Server *
ecore_con_server_add(Ecore_Con_Type type,
char *name,
int port,
const void *data)
{
Ecore_Con_Server *svr;
struct sockaddr_in socket_addr;
struct sockaddr_un socket_unix;
struct linger lin;
char buf[4096];
if (port < 0) return NULL;
/* local user socket: FILE: ~/.ecore/[name]/[port] */
/* local system socket: FILE: /tmp/.ecore_service|[name]|[port] */
/* remote system socket: TCP/IP: [name]:[port] */
svr = calloc(1, sizeof(Ecore_Con_Server));
if (!svr) return NULL;
if ((type == ECORE_CON_LOCAL_USER) ||
(type == ECORE_CON_LOCAL_SYSTEM))
{
char *homedir;
struct stat st;
mode_t pmode, mask;
if (!name) goto error;
mask =
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH;
if (type == ECORE_CON_LOCAL_USER)
{
homedir = getenv("HOME");
if (!homedir) homedir = getenv("TMP");
if (!homedir) homedir = "/tmp";
mask = S_IRUSR | S_IWUSR | S_IXUSR;
snprintf(buf, sizeof(buf), "%s/.ecore", homedir);
if (stat(buf, &st) < 0) mkdir(buf, mask);
snprintf(buf, sizeof(buf), "%s/.ecore/%s", homedir, name);
if (stat(buf, &st) < 0) mkdir(buf, mask);
snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", homedir, name, port);
mask =
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH;
}
else if (type == ECORE_CON_LOCAL_SYSTEM)
{
mask = 0;
snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s|%i", name, port);
}
pmode = umask(mask);
svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (svr->fd < 0)
{
umask(pmode);
goto error;
}
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0)
{
umask(pmode);
goto error;
}
if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0)
{
umask(pmode);
goto error;
}
lin.l_onoff = 1;
lin.l_linger = 100;
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, &lin, sizeof(struct linger)) < 0)
{
umask(pmode);
goto error;
}
socket_unix.sun_family = AF_UNIX;
strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
if (bind(svr->fd, (struct sockaddr *)&socket_unix, LENGTH_OF_SOCKADDR_UN(&socket_unix)) < 0)
{
umask(pmode);
goto error;
}
if (listen(svr->fd, 4096) < 0)
{
umask(pmode);
goto error;
}
svr->path = strdup(buf);
if (!svr->path)
{
umask(pmode);
goto error;
}
svr->fd_handler = ecore_main_fd_handler_add(svr->fd,
ECORE_FD_READ,
_ecore_con_svr_handler, svr,
NULL, NULL);
umask(pmode);
if (!svr->fd_handler) goto error;
}
else if (type == ECORE_CON_REMOTE_SYSTEM)
{
svr->fd = socket(AF_INET, SOCK_STREAM, 0);
if (svr->fd < 0) goto error;
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
lin.l_onoff = 1;
lin.l_linger = 100;
if (setsockopt(svr->fd, SOL_SOCKET, SO_LINGER, &lin, sizeof(struct linger)) < 0) goto error;
socket_addr.sin_family = AF_INET;
socket_addr.sin_port = htons(port);
socket_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if (bind(svr->fd, (struct sockaddr *)&socket_addr, sizeof(struct sockaddr_in)) < 0) goto error;
if (listen(svr->fd, 4096) < 0) goto error;
svr->fd_handler = ecore_main_fd_handler_add(svr->fd,
ECORE_FD_READ,
_ecore_con_svr_handler, svr,
NULL, NULL);
if (!svr->fd_handler) goto error;
}
svr->name = strdup(name);
if (!svr->name) goto error;
svr->type = type;
svr->port = port;
svr->data = (void *)data;
svr->created = 1;
servers = _ecore_list_append(servers, svr);
ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER);
return svr;
error:
if (svr->name) free(svr->name);
if (svr->path) free(svr->path);
if (svr->fd >= 0) close(svr->fd);
if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
if (svr->buf) free(svr->buf);
free(svr);
return NULL;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Con_Server *
ecore_con_server_connect(Ecore_Con_Type type,
char *name,
int port,
const void *data)
{
Ecore_Con_Server *svr;
struct sockaddr_un socket_unix;
struct sockaddr_in socket_addr;
int curstate;
char buf[4096];
if (!name) return NULL;
if (port < 0) return NULL;
/* local user socket: FILE: ~/.ecore/[name]/[port] */
/* local system socket: FILE: /tmp/.ecore_service|[name]|[port] */
/* remote system socket: TCP/IP: [name]:[port] */
svr = calloc(1, sizeof(Ecore_Con_Server));
if (!svr) return NULL;
if ((type == ECORE_CON_LOCAL_USER) ||
(type == ECORE_CON_LOCAL_SYSTEM))
{
char *homedir;
if (type == ECORE_CON_LOCAL_USER)
{
homedir = getenv("HOME");
if (!homedir) homedir = getenv("TMP");
if (!homedir) homedir = "/tmp";
snprintf(buf, sizeof(buf), "%s/.ecore/%s/%i", homedir, name, port);
}
else if (type == ECORE_CON_LOCAL_SYSTEM)
snprintf(buf, sizeof(buf), "/tmp/.ecore_service|%s|%i", name, port);
svr->fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (svr->fd < 0) goto error;
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, &curstate, sizeof(curstate)) < 0) goto error;
socket_unix.sun_family = AF_UNIX;
strncpy(socket_unix.sun_path, buf, sizeof(socket_unix.sun_path));
if (connect(svr->fd, (struct sockaddr *)&socket_unix, LENGTH_OF_SOCKADDR_UN(&socket_unix)) < 0) goto error;
svr->path = strdup(buf);
if (!svr->path) goto error;
svr->fd_handler = ecore_main_fd_handler_add(svr->fd,
ECORE_FD_READ,
_ecore_con_cl_handler, svr,
NULL, NULL);
if (!svr->fd_handler) goto error;
{
/* we got our server! */
Ecore_Con_Event_Server_Add *e;
e = calloc(1, sizeof(Ecore_Con_Event_Server_Add));
if (e)
{
e->server = svr;
ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e,
_ecore_con_event_server_add_free, NULL);
}
}
}
else if (type == ECORE_CON_REMOTE_SYSTEM)
{
struct hostent *he;
/* FIXME: gethostbyname is blocking... */
if (!(he = gethostbyname(name))) goto error;
svr->fd = socket(AF_INET, SOCK_STREAM, 0);
if (svr->fd < 0) goto error;
if (fcntl(svr->fd, F_SETFL, O_NONBLOCK) < 0) goto error;
if (fcntl(svr->fd, F_SETFD, FD_CLOEXEC) < 0) goto error;
if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, &curstate, sizeof(curstate)) < 0) goto error;
socket_addr.sin_family = AF_INET;
socket_addr.sin_port = htons(port);
memcpy((struct in_addr *)&socket_addr.sin_addr,
he->h_addr, sizeof(struct in_addr));
if (connect(svr->fd, (struct sockaddr *)&socket_addr, sizeof(struct sockaddr_in)) < 0)
{
if (errno != EINPROGRESS)
goto error;
svr->connecting = 1;
svr->fd_handler = ecore_main_fd_handler_add(svr->fd,
ECORE_FD_READ | ECORE_FD_WRITE,
_ecore_con_cl_handler, svr,
NULL, NULL);
}
else
svr->fd_handler = ecore_main_fd_handler_add(svr->fd,
ECORE_FD_READ,
_ecore_con_cl_handler, svr,
NULL, NULL);
if (!svr->fd_handler) goto error;
}
svr->name = strdup(name);
if (!svr->name) goto error;
svr->type = type;
svr->port = port;
svr->data = (void *)data;
svr->created = 0;
servers = _ecore_list_append(servers, svr);
ECORE_MAGIC_SET(svr, ECORE_MAGIC_CON_SERVER);
return svr;
error:
if (svr->name) free(svr->name);
if (svr->path) free(svr->path);
if (svr->fd >= 0) close(svr->fd);
if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
free(svr);
return NULL;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_con_server_del(Ecore_Con_Server *svr)
{
void *data;
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
"ecore_con_server_del");
return NULL;
}
data = svr->data;
_ecore_con_server_free(svr);
return data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_con_server_data_get(Ecore_Con_Server *svr)
{
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
"ecore_con_server_data_get");
return NULL;
}
return svr->data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_con_server_connected_get(Ecore_Con_Server *svr)
{
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
"ecore_con_server_connected_get");
return 0;
}
if (svr->connecting) return 0;
return 1;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_con_server_send(Ecore_Con_Server *svr, void *data, int size)
{
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
"ecore_con_server_send");
return 0;
}
if (svr->dead) return 1;
if (!data) return 0;
if (size < 1) return 0;
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
if (svr->buf)
{
unsigned char *newbuf;
newbuf = realloc(svr->buf, svr->buf_size + size);
if (newbuf) svr->buf = newbuf;
else return 0;
memcpy(svr->buf + svr->buf_size, data, size);
svr->buf_size += size;
}
else
{
svr->buf = malloc(size);
if (!svr->buf) return 0;
svr->buf_size = size;
memcpy(svr->buf, data, size);
}
_ecore_con_server_flush(svr);
return 1;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_con_client_send(Ecore_Con_Client *cl, void *data, int size)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
"ecore_con_client_send");
return 0;
}
if (cl->dead) return 0;
if (!data) return 0;
if (size < 1) return 0;
ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE);
if (cl->buf)
{
unsigned char *newbuf;
newbuf = realloc(cl->buf, cl->buf_size + size);
if (newbuf) cl->buf = newbuf;
else return 0;
memcpy(cl->buf + cl->buf_size, data, size);
cl->buf_size += size;
}
else
{
cl->buf = malloc(size);
if (!cl->buf) return 0;
cl->buf_size = size;
memcpy(cl->buf, data, size);
}
_ecore_con_client_flush(cl);
return 1;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Con_Server *
ecore_con_client_server_get(Ecore_Con_Client *cl)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
"ecore_con_client_server_get");
return NULL;
}
return cl->server;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_con_client_del(Ecore_Con_Client *cl)
{
void *data;
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
"ecore_con_client_del");
return NULL;
}
data = cl->data;
_ecore_con_client_free(cl);
return cl->data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_con_client_data_set(Ecore_Con_Client *cl, const void *data)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
"ecore_con_client_data_set");
return;
}
cl->data = (void *)data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_con_client_data_get(Ecore_Con_Client *cl)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT,
"ecore_con_client_data_get");
return NULL;
}
return cl->data;
}
static void
_ecore_con_server_free(Ecore_Con_Server *svr)
{
ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE);
while ((svr->buf) && (!svr->dead)) _ecore_con_server_flush(svr);
if (svr->buf) free(svr->buf);
servers = _ecore_list_remove(servers, svr);
while (svr->clients)
_ecore_con_client_free((Ecore_Con_Client *)svr->clients);
if ((svr->created) && (svr->path)) unlink(svr->path);
if (svr->fd >= 0) close(svr->fd);
if (svr->name) free(svr->name);
if (svr->path) free(svr->path);
if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler);
free(svr);
}
static void
_ecore_con_client_free(Ecore_Con_Client *cl)
{
ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
while ((cl->buf) && (!cl->dead)) _ecore_con_client_flush(cl);
if (cl->buf) free(cl->buf);
cl->server->clients = _ecore_list_remove(cl->server->clients, cl);
if (cl->fd >= 0) close(cl->fd);
if (cl->fd_handler) ecore_main_fd_handler_del(cl->fd_handler);
free(cl);
}
static int
_ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler)
{
Ecore_Con_Server *svr;
int new_fd;
struct sockaddr_in incoming;
size_t size_in;
svr = data;
if (svr->dead) return 1;
/* a new client */
size_in = sizeof(struct sockaddr_in);
new_fd = accept(svr->fd, (struct sockaddr *)&incoming, &size_in);
if (new_fd >= 0)
{
Ecore_Con_Client *cl;
cl = calloc(1, sizeof(Ecore_Con_Client));
if (!cl)
{
close(new_fd);
return 1;
}
fcntl(new_fd, F_SETFL, O_NONBLOCK);
fcntl(new_fd, F_SETFD, FD_CLOEXEC);
cl->fd = new_fd;
cl->server = svr;
cl->fd_handler = ecore_main_fd_handler_add(cl->fd,
ECORE_FD_READ,
_ecore_con_svr_cl_handler, cl,
NULL, NULL);
ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT);
svr->clients = _ecore_list_append(svr->clients, cl);
{
Ecore_Con_Event_Client_Add *e;
e = calloc(1, sizeof(Ecore_Con_Event_Client_Add));
if (e)
{
e->client = cl;
ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, e,
_ecore_con_event_client_add_free, NULL);
}
}
}
return 1;
}
static int
_ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
{
Ecore_Con_Server *svr;
svr = data;
if (svr->dead) return 1;
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
{
unsigned char *inbuf = NULL;
int inbuf_num = 0;
for (;;)
{
char buf[65536];
int num;
num = read(svr->fd, buf, 65536);
if (num < 1)
{
if (inbuf)
{
Ecore_Con_Event_Server_Data *e;
e = calloc(1, sizeof(Ecore_Con_Event_Server_Data));
if (e)
{
e->server = svr;
e->data = inbuf;
e->size = inbuf_num;
ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e,
_ecore_con_event_server_data_free, NULL);
}
}
if ((errno == EIO) || (errno == EBADF) ||
(errno == EPIPE) || (errno == EINVAL) ||
(errno == ENOSPC) || (num == 0)/* is num == 0 right? */)
{
/* we lost our server! */
Ecore_Con_Event_Server_Del *e;
e = calloc(1, sizeof(Ecore_Con_Event_Server_Del));
if (e)
{
e->server = svr;
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
_ecore_con_event_server_del_free, NULL);
}
svr->dead = 1;
ecore_main_fd_handler_del(svr->fd_handler);
svr->fd_handler = NULL;
}
break;
}
else
{
inbuf = realloc(inbuf, inbuf_num + num);
memcpy(inbuf + inbuf_num, buf, num);
inbuf_num += num;
}
}
}
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE))
{
if (svr->connecting)
{
int so_err;
socklen_t size;
svr->connecting = 0;
so_err = 0;
size = sizeof(int);
if (getsockopt(svr->fd, SOL_SOCKET, SO_ERROR, &so_err, &size) < 0) so_err = -1;
if (so_err != 0)
{
/* we lost our server! */
Ecore_Con_Event_Server_Del *e;
e = calloc(1, sizeof(Ecore_Con_Event_Server_Del));
if (e)
{
e->server = svr;
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
_ecore_con_event_server_del_free, NULL);
}
svr->dead = 1;
ecore_main_fd_handler_del(svr->fd_handler);
svr->fd_handler = NULL;
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ);
return 1;
}
else
{
{
/* we got our server! */
Ecore_Con_Event_Server_Add *e;
e = calloc(1, sizeof(Ecore_Con_Event_Server_Add));
if (e)
{
e->server = svr;
ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e,
_ecore_con_event_server_add_free, NULL);
}
}
if (!svr->buf)
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ);
}
}
_ecore_con_server_flush(svr);
}
return 1;
}
static int
_ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
{
Ecore_Con_Client *cl;
cl = data;
if (cl->dead) return 1;
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
{
unsigned char *inbuf = NULL;
int inbuf_num = 0;
for (;;)
{
char buf[65536];
int num;
errno = 0;
num = read(cl->fd, buf, 65536);
if (num < 1)
{
if (inbuf)
{
Ecore_Con_Event_Client_Data *e;
e = calloc(1, sizeof(Ecore_Con_Event_Client_Data));
if (e)
{
e->client = cl;
e->data = inbuf;
e->size = inbuf_num;
ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e,
_ecore_con_event_client_data_free, NULL);
}
}
if ((errno == EIO) || (errno == EBADF) ||
(errno == EPIPE) || (errno == EINVAL) ||
(errno == ENOSPC) || (num == 0)/* is num == 0 right? */)
{
/* we lost our client! */
Ecore_Con_Event_Client_Del *e;
e = calloc(1, sizeof(Ecore_Con_Event_Client_Del));
if (e)
{
e->client = cl;
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
_ecore_con_event_client_del_free, NULL);
}
cl->dead = 1;
ecore_main_fd_handler_del(cl->fd_handler);
cl->fd_handler = NULL;
}
break;
}
else
{
inbuf = realloc(inbuf, inbuf_num + num);
memcpy(inbuf + inbuf_num, buf, num);
inbuf_num += num;
}
}
}
else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE))
_ecore_con_client_flush(cl);
return 1;
}
static void
_ecore_con_server_flush(Ecore_Con_Server *svr)
{
int count, num;
if (!svr->buf) return;
num = svr->buf_size - svr->buf_offset;
count = write(svr->fd, svr->buf + svr->buf_offset, num);
if (count < 1)
{
if ((errno == EIO) || (errno == EBADF) || (errno == EPIPE) ||
(errno == EINVAL) || (errno == ENOSPC))
{
/* we lost our server! */
Ecore_Con_Event_Server_Del *e;
e = calloc(1, sizeof(Ecore_Con_Event_Server_Del));
if (e)
{
e->server = svr;
ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
_ecore_con_event_server_del_free, NULL);
}
svr->dead = 1;
ecore_main_fd_handler_del(svr->fd_handler);
svr->fd_handler = NULL;
}
return;
}
svr->buf_offset += count;
if (svr->buf_offset >= svr->buf_size)
{
svr->buf_size = 0;
svr->buf_offset = 0;
free(svr->buf);
svr->buf = NULL;
ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ);
}
}
static void
_ecore_con_client_flush(Ecore_Con_Client *cl)
{
int count, num;
if (!cl->buf) return;
num = cl->buf_size - cl->buf_offset;
count = write(cl->fd, cl->buf + cl->buf_offset, num);
if (count < 1)
{
if ((errno == EIO) || (errno == EBADF) || (errno == EPIPE) ||
(errno == EINVAL) || (errno == ENOSPC))
{
/* we lost our client! */
Ecore_Con_Event_Client_Del *e;
e = calloc(1, sizeof(Ecore_Con_Event_Client_Del));
if (e)
{
e->client = cl;
ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
_ecore_con_event_client_del_free, NULL);
}
cl->dead = 1;
ecore_main_fd_handler_del(cl->fd_handler);
cl->fd_handler = NULL;
}
return;
}
cl->buf_offset += count;
if (cl->buf_offset >= cl->buf_size)
{
cl->buf_size = 0;
cl->buf_offset = 0;
free(cl->buf);
cl->buf = NULL;
ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ);
}
}
static void
_ecore_con_event_client_add_free(void *data, void *ev)
{
Ecore_Con_Event_Client_Add *e;
e = ev;
free(e);
}
static void
_ecore_con_event_client_del_free(void *data, void *ev)
{
Ecore_Con_Event_Client_Del *e;
e = ev;
free(e);
}
static void
_ecore_con_event_server_add_free(void *data, void *ev)
{
Ecore_Con_Event_Server_Add *e;
e = ev;
free(e);
}
static void
_ecore_con_event_server_del_free(void *data, void *ev)
{
Ecore_Con_Event_Server_Del *e;
e = ev;
free(e);
}
static void
_ecore_con_event_client_data_free(void *data, void *ev)
{
Ecore_Con_Event_Client_Data *e;
e = ev;
if (e->data) free(e->data);
free(e);
}
static void
_ecore_con_event_server_data_free(void *data, void *ev)
{
Ecore_Con_Event_Server_Data *e;
e = ev;
if (e->data) free(e->data);
free(e);
}

View File

@ -0,0 +1,51 @@
#ifndef _ECORE_CON_PRIVATE_H
#define _ECORE_CON_PRIVATE_H
#define ECORE_MAGIC_CON_SERVER 0x77665544
#define ECORE_MAGIC_CON_CLIENT 0x77556677
typedef struct _Ecore_Con_Client Ecore_Con_Client;
typedef struct _Ecore_Con_Server Ecore_Con_Server;
typedef enum _Ecore_Con_Type
{
ECORE_CON_LOCAL_USER,
ECORE_CON_LOCAL_SYSTEM,
ECORE_CON_REMOTE_SYSTEM,
} Ecore_Con_Type;
struct _Ecore_Con_Client
{
Ecore_List __list_data;
ECORE_MAGIC;
int fd;
Ecore_Con_Server *server;
void *data;
Ecore_Fd_Handler *fd_handler;
int buf_size;
int buf_offset;
unsigned char *buf;
char dead : 1;
};
struct _Ecore_Con_Server
{
Ecore_List __list_data;
ECORE_MAGIC;
int fd;
Ecore_Con_Type type;
char *name;
int port;
char *path;
void *data;
Ecore_Fd_Handler *fd_handler;
Ecore_Con_Client *clients;
int buf_size;
int buf_offset;
unsigned char *buf;
char dead : 1;
char created : 1;
char connecting : 1;
};
#endif

View File

@ -0,0 +1,107 @@
#ifndef _ECORE_EVAS_H
#define _ECORE_EVAS_H
/* FIXME:
* to do soon:
* - iconfication api needs to work
* - maximization api nees to work
* - attach keyed data to an ecore_evas canvas
* - document all calls
*
* later:
* - qt back-end ???
* - dfb back-end ??? (dfb's threads make this REALLY HARD)
*/
#include <Evas.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ECORE_X_H
#define _ECORE_X_WINDOW_PREDEF
typedef unsigned int Ecore_X_Window;
#endif
#ifndef _ECORE_EVAS_PRIVATE_H
/* basic data types */
typedef void Ecore_Evas;
#endif
/* module setup/shutdown calls */
int ecore_evas_init(void);
int ecore_evas_shutdown(void);
/* engine/target specific init calls */
Ecore_Evas *ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h);
Ecore_Evas *ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h);
Ecore_X_Window ecore_evas_software_x11_window_get(Ecore_Evas *ee);
Ecore_Evas *ecore_evas_fb_new(char *disp_name, int rotation, int w, int h);
/* generic manipulation calls */
void ecore_evas_free(Ecore_Evas *ee);
void ecore_evas_callback_resize_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_move_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_show_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_hide_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_destroy_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_focus_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_focus_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_mouse_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_pre_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void ecore_evas_callback_post_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
Evas *ecore_evas_get(Ecore_Evas *ee);
void ecore_evas_move(Ecore_Evas *ee, int x, int y);
void ecore_evas_resize(Ecore_Evas *ee, int w, int h);
void ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h);
void ecore_evas_geometry_get(Ecore_Evas *ee, int *x, int *y, int *w, int *h);
void ecore_evas_rotation_set(Ecore_Evas *ee, int rot);
int ecore_evas_rotation_get(Ecore_Evas *ee);
void ecore_evas_shaped_set(Ecore_Evas *ee, int shaped);
int ecore_evas_shaped_get(Ecore_Evas *ee);
void ecore_evas_show(Ecore_Evas *ee);
void ecore_evas_hide(Ecore_Evas *ee);
int ecore_evas_visibility_get(Ecore_Evas *ee);
void ecore_evas_raise(Ecore_Evas *ee);
void ecore_evas_lower(Ecore_Evas *ee);
void ecore_evas_title_set(Ecore_Evas *ee, const char *t);
const char *ecore_evas_title_get(Ecore_Evas *ee);
void ecore_evas_name_class_set(Ecore_Evas *ee, const char *n, const char *c);
void ecore_evas_name_class_get(Ecore_Evas *ee, const char **n, const char **c);
void ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h);
void ecore_evas_size_min_get(Ecore_Evas *ee, int *w, int *h);
void ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h);
void ecore_evas_size_max_get(Ecore_Evas *ee, int *w, int *h);
void ecore_evas_size_base_set(Ecore_Evas *ee, int w, int h);
void ecore_evas_size_base_get(Ecore_Evas *ee, int *w, int *h);
void ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h);
void ecore_evas_size_step_get(Ecore_Evas *ee, int *w, int *h);
void ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y);
void ecore_evas_cursor_get(Ecore_Evas *ee, char **file, int *layer, int *hot_x, int *hot_y);
void ecore_evas_layer_set(Ecore_Evas *ee, int layer);
int ecore_evas_layer_get(Ecore_Evas *ee);
void ecore_evas_focus_set(Ecore_Evas *ee, int on);
int ecore_evas_focus_get(Ecore_Evas *ee);
void ecore_evas_iconified_set(Ecore_Evas *ee, int on);
int ecore_evas_iconified_get(Ecore_Evas *ee);
void ecore_evas_borderless_set(Ecore_Evas *ee, int on);
int ecore_evas_borderless_get(Ecore_Evas *ee);
void ecore_evas_override_set(Ecore_Evas *ee, int on);
int ecore_evas_override_get(Ecore_Evas *ee);
void ecore_evas_maximized_set(Ecore_Evas *ee, int on);
int ecore_evas_maximized_get(Ecore_Evas *ee);
void ecore_evas_fullscreen_set(Ecore_Evas *ee, int on);
int ecore_evas_fullscreen_get(Ecore_Evas *ee);
void ecore_evas_avoid_damage_set(Ecore_Evas *ee, int on);
int ecore_evas_avoid_damage_get(Ecore_Evas *ee);
void ecore_evas_withdrawn_set(Ecore_Evas *ee, int withdrawn);
int ecore_evas_withdrawn_get(Ecore_Evas *ee);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,65 @@
## Process this file with automake to produce Makefile.in
if BUILD_ECORE_X
ECORE_X_INC = -I$(top_srcdir)/src/lib/ecore_x
ECORE_X_LIB = $(top_builddir)/src/lib/ecore_x/libecore_x.la
ECORE_X_LDF = -L$(top_builddir)/src/lib/ecore_x/.libs
else
ECORE_X_INC =
ECORE_X_LIB =
ECORE_X_LDF =
endif
if BUILD_ECORE_FB
ECORE_FB_INC = -I$(top_srcdir)/src/lib/ecore_fb
ECORE_FB_LIB = $(top_builddir)/src/lib/ecore_fb/libecore_fb.la
ECORE_FB_LDF = -L$(top_builddir)/src/lib/ecore_fb/.libs
else
ECORE_FB_INC =
ECORE_FB_LIB =
ECORE_FB_LDF =
endif
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore \
$(ECORE_X_INC) \
$(ECORE_FB_INC) \
@evas_cflags@
libecore_evas_la_LDFLAGS = -version-info 1:0:0 \
$(ECORE_X_LDF) \
$(ECORE_FB_LDF) \
-L$(top_builddir)/src/lib/ecore/.libs
if BUILD_ECORE_EVAS
lib_LTLIBRARIES = libecore_evas.la
include_HEADERS = \
Ecore_Evas.h
libecore_evas_la_SOURCES = \
ecore_evas.c \
ecore_evas_x.c \
ecore_evas_fb.c \
ecore_evas_private.h
libecore_evas_la_LIBADD = \
$(ECORE_X_LIB) \
$(ECORE_FB_LIB) \
$(top_builddir)/src/lib/ecore/libecore.la \
@evas_libs@
libecore_evas_la_DEPENDENCIES = \
$(ECORE_X_LIB) \
$(ECORE_FB_LIB) \
$(top_builddir)/src/lib/ecore/libecore.la
endif
EXTRA_DIST = \
Ecore_Evas.h \
ecore_evas.c \
ecore_evas_x.c \
ecore_evas_fb.c \
ecore_evas_private.h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,507 @@
#include "config.h"
#include "Ecore.h"
#include "ecore_private.h"
#include "ecore_evas_private.h"
#include "Ecore_Evas.h"
#ifdef BUILD_ECORE_FB
#include "Ecore_Fb.h"
#endif
#ifdef BUILD_ECORE_FB
static int _ecore_evas_init_count = 0;
static Ecore_Evas *ecore_evases = NULL;
static Ecore_Event_Handler *ecore_evas_event_handlers[5];
static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
static void
_ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y)
{
int fbw, fbh;
ee->mouse.x = x;
ee->mouse.y = y;
ecore_fb_size_get(&fbw, &fbh);
if (ee->prop.cursor.object)
{
evas_object_show(ee->prop.cursor.object);
if (ee->rotation == 0)
evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y);
else if (ee->rotation == 90)
evas_object_move(ee->prop.cursor.object,
(fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.x,
x - ee->prop.cursor.hot.y);
else if (ee->rotation == 180)
evas_object_move(ee->prop.cursor.object,
(fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.x,
(fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.y);
else if (ee->rotation == 270)
evas_object_move(ee->prop.cursor.object,
y - ee->prop.cursor.hot.x,
(fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.y);
}
if (ee->rotation == 0)
evas_event_feed_mouse_move(ee->evas, x, y);
else if (ee->rotation == 90)
evas_event_feed_mouse_move(ee->evas, (fbh - ee->h) + ee->h - y - 1, x);
else if (ee->rotation == 180)
evas_event_feed_mouse_move(ee->evas, (fbw - ee->w) + ee->w - x - 1, (fbh - ee->h) + ee->h - y - 1);
else if (ee->rotation == 270)
evas_event_feed_mouse_move(ee->evas, y, (fbw - ee->w) + ee->w - x - 1);
}
static Ecore_Evas *
_ecore_evas_fb_match(void)
{
Ecore_List *l;
for (l = (Ecore_List *)ecore_evases; l; l = l->next)
{
Ecore_Evas *ee;
ee = (Ecore_Evas *)l;
return ee;
}
return NULL;
}
static void
_ecore_evas_fb_lose(void *data)
{
Ecore_List *l;
for (l = (Ecore_List *)ecore_evases; l; l = l->next)
{
Ecore_Evas *ee;
ee = (Ecore_Evas *)l;
ee->visible = 0;
}
}
static void
_ecore_evas_fb_gain(void *data)
{
Ecore_List *l;
for (l = (Ecore_List *)ecore_evases; l; l = l->next)
{
Ecore_Evas *ee;
ee = (Ecore_Evas *)l;
ee->visible = 1;
evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
}
}
static int
_ecore_evas_event_key_down(void *data, int type, void *event)
{
Ecore_Evas *ee;
Ecore_Fb_Event_Key_Down *e;
e = event;
ee = _ecore_evas_fb_match();
if (!ee) return 1; /* pass on event */
evas_event_feed_key_down(ee->evas, e->keyname);
return 0; /* dont pass it on */
}
static int
_ecore_evas_event_key_up(void *data, int type, void *event)
{
Ecore_Evas *ee;
Ecore_Fb_Event_Key_Up *e;
e = event;
ee = _ecore_evas_fb_match();
if (!ee) return 1; /* pass on event */
evas_event_feed_key_up(ee->evas, e->keyname);
return 0; /* dont pass it on */
}
static int
_ecore_evas_event_mouse_button_down(void *data, int type, void *event)
{
Ecore_Evas *ee;
Ecore_Fb_Event_Mouse_Button_Down *e;
e = event;
ee = _ecore_evas_fb_match();
if (!ee) return 1; /* pass on event */
_ecore_evas_mouse_move_process(ee, e->x, e->y);
evas_event_feed_mouse_down(ee->evas, e->button);
return 0; /* dont pass it on */
}
static int
_ecore_evas_event_mouse_button_up(void *data, int type, void *event)
{
Ecore_Evas *ee;
Ecore_Fb_Event_Mouse_Button_Up *e;
e = event;
ee = _ecore_evas_fb_match();
if (!ee) return 1; /* pass on event */
_ecore_evas_mouse_move_process(ee, e->x, e->y);
evas_event_feed_mouse_up(ee->evas, e->button);
return 0; /* dont pass it on */
}
static int
_ecore_evas_event_mouse_move(void *data, int type, void *event)
{
Ecore_Evas *ee;
Ecore_Fb_Event_Mouse_Move *e;
e = event;
ee = _ecore_evas_fb_match();
if (!ee) return 1; /* pass on event */
_ecore_evas_mouse_move_process(ee, e->x, e->y);
return 0; /* dont pass it on */
}
static int
_ecore_evas_idle_enter(void *data)
{
Ecore_List *l;
for (l = (Ecore_List *)ecore_evases; l; l = l->next)
{
Ecore_Evas *ee;
ee = (Ecore_Evas *)l;
if (ee->visible)
{
if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
evas_render(ee->evas);
if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
}
}
return 1;
}
static int
_ecore_evas_fb_init(void)
{
_ecore_evas_init_count++;
if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL);
ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_DOWN, _ecore_evas_event_key_down, NULL);
ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_UP, _ecore_evas_event_key_up, NULL);
ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL);
ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL);
ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL);
return _ecore_evas_init_count;
}
static void
_ecore_evas_fb_free(Ecore_Evas *ee)
{
ecore_evases = _ecore_list_remove(ecore_evases, ee);
_ecore_evas_fb_shutdown();
ecore_fb_shutdown();
}
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);
if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
static void
_ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, 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);
if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
static void
_ecore_evas_rotation_set(Ecore_Evas *ee, int rotation)
{
Evas_Engine_Info_FB *einfo;
int rot_dif;
if (ee->rotation == rotation) return;
einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(ee->evas);
if (!einfo) return;
rot_dif = ee->rotation - rotation;
if (rot_dif < 0) rot_dif = -rot_dif;
if (rot_dif != 180)
{
einfo->info.rotation = rotation;
evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
if (!ee->prop.fullscreen)
{
int tmp;
tmp = ee->w;
ee->w = ee->h;
ee->h = tmp;
}
else
{
if ((rotation == 0) || (rotation == 180))
{
evas_output_size_set(ee->evas, ee->w, ee->h);
evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
}
else
{
evas_output_size_set(ee->evas, ee->h, ee->w);
evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w);
}
}
ee->rotation = rotation;
}
else
{
einfo->info.rotation = rotation;
evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
ee->rotation = rotation;
}
if ((ee->rotation == 90) || (ee->rotation == 270))
evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w);
else
evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
_ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y);
if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
static void
_ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
{
int x, y;
if (!file)
{
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.object = NULL;
ee->prop.cursor.file = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
return;
}
if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.file = strdup(file);
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_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y);
evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
evas_object_resize(ee->prop.cursor.object, x, y);
evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, 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);
}
static void
_ecore_evas_fullscreen_set(Ecore_Evas *ee, int on)
{
int resized = 0;
if (((ee->prop.fullscreen) && (on)) ||
((!ee->prop.fullscreen) && (!on))) return;
if (on)
{
int w, h;
ee->engine.fb.real_w = ee->w;
ee->engine.fb.real_h = ee->h;
w = ee->w;
h = ee->h;
ecore_fb_size_get(&w, &h);
if ((w == 0) && (h == 0))
{
w = ee->w;
h = ee->h;
}
if ((w != ee->w) || (h != ee->h)) resized = 1;
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);
}
else
{
if ((ee->engine.fb.real_w != ee->w) || (ee->engine.fb.real_h != ee->h)) resized = 1;
ee->w = ee->engine.fb.real_w;
ee->h = ee->engine.fb.real_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);
}
ee->prop.fullscreen = on;
if (resized)
{
if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
}
int
_ecore_evas_fb_shutdown(void)
{
_ecore_evas_init_count--;
if (_ecore_evas_init_count == 0)
{
int i;
while (ecore_evases) ecore_evas_free(ecore_evases);
for (i = 0; i < 5; i++)
ecore_event_handler_del(ecore_evas_event_handlers[i]);
ecore_idle_enterer_del(ecore_evas_idle_enterer);
ecore_evas_idle_enterer = NULL;
}
if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
return _ecore_evas_init_count;
}
static const Ecore_Evas_Engine_Func _ecore_fb_engine_func =
{
_ecore_evas_fb_free,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
_ecore_evas_resize,
_ecore_evas_move_resize,
_ecore_evas_rotation_set,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
_ecore_evas_cursor_set,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
_ecore_evas_fullscreen_set,
NULL,
NULL
};
#endif
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Evas *
ecore_evas_fb_new(char *disp_name, int rotation, int w, int h)
{
#ifdef BUILD_ECORE_FB
Evas_Engine_Info_FB *einfo;
Ecore_Evas *ee;
int rmethod;
rmethod = evas_render_method_lookup("fb");
if (!rmethod) return NULL;
if (!ecore_fb_init(disp_name)) return NULL;
ecore_fb_callback_gain_set(_ecore_evas_fb_gain, NULL);
ecore_fb_callback_lose_set(_ecore_evas_fb_lose, NULL);
ee = calloc(1, sizeof(Ecore_Evas));
if (!ee) return NULL;
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
_ecore_evas_fb_init();
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_fb_engine_func;
ee->driver = strdup("fb");
if (disp_name) ee->name = strdup(disp_name);
if (w < 1) w = 1;
if (h < 1) h = 1;
ee->rotation = rotation;
ee->visible = 1;
ee->w = w;
ee->h = h;
ee->prop.max.w = 240;
ee->prop.max.h = 320;
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;
/* init evas here */
ee->evas = evas_new();
evas_output_method_set(ee->evas, rmethod);
evas_output_size_set(ee->evas, w, h);
evas_output_viewport_set(ee->evas, 0, 0, w, h);
einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(ee->evas);
if (einfo)
{
einfo->info.virtual_terminal = 0;
einfo->info.device_number = 0;
einfo->info.refresh = 0;
einfo->info.rotation = ee->rotation;
evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
}
evas_key_modifier_add(ee->evas, "Shift");
evas_key_modifier_add(ee->evas, "Control");
evas_key_modifier_add(ee->evas, "Alt");
evas_key_modifier_add(ee->evas, "Meta");
evas_key_modifier_add(ee->evas, "Hyper");
evas_key_modifier_add(ee->evas, "Super");
evas_key_lock_add(ee->evas, "Caps_Lock");
evas_key_lock_add(ee->evas, "Num_Lock");
evas_key_lock_add(ee->evas, "Scroll_Lock");
evas_event_feed_mouse_in(ee->evas);
ecore_evases = _ecore_list_prepend(ecore_evases, ee);
return ee;
#else
return NULL;
#endif
}

View File

@ -0,0 +1,164 @@
#ifndef _ECORE_EVAS_PRIVATE_H
#define _ECORE_EVAS_PRIVATE_H
#include <Evas.h>
#define ECORE_MAGIC_EVAS 0x76543211
#ifdef BUILD_ECORE_X
#include "Ecore_X.h"
#include <Evas_Engine_Software_X11.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef BUILD_ECORE_EVAS_GL
#include <Evas_Engine_GL_X11.h>
#endif
#endif
#ifdef BUILD_ECORE_FB
#include <Evas_Engine_FB.h>
#endif
typedef struct _Ecore_Evas Ecore_Evas;
typedef struct _Ecore_Evas_Engine Ecore_Evas_Engine;
typedef struct _Ecore_Evas_Engine_Func Ecore_Evas_Engine_Func;
struct _Ecore_Evas_Engine_Func
{
void (*fn_free) (Ecore_Evas *ee);
void (*fn_callback_resize_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_move_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_show_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_hide_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_delete_request_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_destroy_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_focus_in_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_focus_out_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_mouse_in_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_mouse_out_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_pre_render_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_callback_post_render_set) (Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
void (*fn_move) (Ecore_Evas *ee, int x, int y);
void (*fn_resize) (Ecore_Evas *ee, int w, int h);
void (*fn_move_resize) (Ecore_Evas *ee, int x, int y, int w, int h);
void (*fn_rotation_set) (Ecore_Evas *ee, int rot);
void (*fn_shaped_set) (Ecore_Evas *ee, int shaped);
void (*fn_show) (Ecore_Evas *ee);
void (*fn_hide) (Ecore_Evas *ee);
void (*fn_raise) (Ecore_Evas *ee);
void (*fn_lower) (Ecore_Evas *ee);
void (*fn_title_set) (Ecore_Evas *ee, const char *t);
void (*fn_name_class_set) (Ecore_Evas *ee, const char *n, const char *c);
void (*fn_size_min_set) (Ecore_Evas *ee, int w, int h);
void (*fn_size_max_set) (Ecore_Evas *ee, int w, int h);
void (*fn_size_base_set) (Ecore_Evas *ee, int w, int h);
void (*fn_size_step_set) (Ecore_Evas *ee, int w, int h);
void (*fn_cursor_set) (Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y);
void (*fn_layer_set) (Ecore_Evas *ee, int layer);
void (*fn_focus_set) (Ecore_Evas *ee, int on);
void (*fn_iconified_set) (Ecore_Evas *ee, int on);
void (*fn_borderless_set) (Ecore_Evas *ee, int on);
void (*fn_override_set) (Ecore_Evas *ee, int on);
void (*fn_maximized_set) (Ecore_Evas *ee, int on);
void (*fn_fullscreen_set) (Ecore_Evas *ee, int on);
void (*fn_avoid_damage_set) (Ecore_Evas *ee, int on);
void (*fn_withdrawn_set) (Ecore_Evas *ee, int withdrawn);
};
struct _Ecore_Evas_Engine
{
Ecore_Evas_Engine_Func *func;
#ifdef BUILD_ECORE_X
struct {
Ecore_X_Window win_container;
Ecore_X_Window win;
Ecore_X_Pixmap pmap;
Ecore_X_Pixmap mask;
Ecore_X_GC gc;
Region damages;
} x;
#endif
#ifdef BUILD_ECORE_FB
struct {
int real_w;
int real_h;
} fb;
#endif
};
struct _Ecore_Evas
{
Ecore_List __list_data;
ECORE_MAGIC;
Evas *evas;
char *driver;
char *name;
int x, y, w, h;
short rotation;
char shaped : 1;
char visible : 1;
char should_be_visible : 1;
struct {
int x, y;
} mouse;
struct {
int w, h;
} expecting_resize;
struct {
char *title;
char *name;
char *clas;
struct {
int w, h;
} min,
max,
base,
step;
struct {
Evas_Object *object;
char *file;
int layer;
struct {
int x, y;
} hot;
} cursor;
int layer;
char focused : 1;
char iconified : 1;
char borderless : 1;
char override : 1;
char maximized : 1;
char fullscreen : 1;
char avoid_damage : 1;
char withdrawn : 1;
} prop;
struct {
void (*fn_resize) (Ecore_Evas *ee);
void (*fn_move) (Ecore_Evas *ee);
void (*fn_show) (Ecore_Evas *ee);
void (*fn_hide) (Ecore_Evas *ee);
void (*fn_delete_request) (Ecore_Evas *ee);
void (*fn_destroy) (Ecore_Evas *ee);
void (*fn_focus_in) (Ecore_Evas *ee);
void (*fn_focus_out) (Ecore_Evas *ee);
void (*fn_mouse_in) (Ecore_Evas *ee);
void (*fn_mouse_out) (Ecore_Evas *ee);
void (*fn_pre_render) (Ecore_Evas *ee);
void (*fn_post_render) (Ecore_Evas *ee);
} func;
Ecore_Evas_Engine engine;
};
#ifdef BUILD_ECORE_X
int _ecore_evas_x_shutdown(void);
#endif
#ifdef BUILD_ECORE_FB
int _ecore_evas_fb_shutdown(void);
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,90 @@
#ifndef _ECORE_FB_H
#define _ECORE_FB_H
/* FIXME:
* maybe a new module?
* - code to get battery info
* - code to get thermal info
*/
#ifdef __cplusplus
extern "C" {
#endif
extern int ECORE_FB_EVENT_KEY_DOWN; /**< FB Key Down event */
extern int ECORE_FB_EVENT_KEY_UP; /**< FB Key Up event */
extern int ECORE_FB_EVENT_MOUSE_BUTTON_DOWN; /**< FB Mouse Down event */
extern int ECORE_FB_EVENT_MOUSE_BUTTON_UP; /**< FB Mouse Up event */
extern int ECORE_FB_EVENT_MOUSE_MOVE; /**< FB Mouse Move event */
typedef struct _Ecore_Fb_Event_Key_Down Ecore_Fb_Event_Key_Down; /**< FB Key Down event */
typedef struct _Ecore_Fb_Event_Key_Up Ecore_Fb_Event_Key_Up; /**< FB Key Up event */
typedef struct _Ecore_Fb_Event_Mouse_Button_Down Ecore_Fb_Event_Mouse_Button_Down; /**< FB Mouse Down event */
typedef struct _Ecore_Fb_Event_Mouse_Button_Up Ecore_Fb_Event_Mouse_Button_Up; /**< FB Mouse Up event */
typedef struct _Ecore_Fb_Event_Mouse_Move Ecore_Fb_Event_Mouse_Move; /**< FB Mouse Move event */
struct _Ecore_Fb_Event_Key_Down /** FB Key Down event */
{
char *keyname; /**< The name of the key that was prerssed */
};
struct _Ecore_Fb_Event_Key_Up /** FB Key Up event */
{
char *keyname; /**< The name of the key that was released */
};
struct _Ecore_Fb_Event_Mouse_Button_Down /** FB 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 */
};
struct _Ecore_Fb_Event_Mouse_Button_Up /** FB 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 */
};
struct _Ecore_Fb_Event_Mouse_Move /** FB 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 */
};
int ecore_fb_init(const char *name);
int ecore_fb_shutdown(void);
void ecore_fb_double_click_time_set(double t);
double ecore_fb_double_click_time_get(void);
void ecore_fb_size_get(int *w, int *h);
void ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytrans, int xyswap);
void ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int *ytrans, int *xyswap);
void ecore_fb_backlight_set(int on);
int ecore_fb_backlight_get(void);
void ecore_fb_backlight_brightness_set(double br);
double ecore_fb_backlight_brightness_get(void);
void ecore_fb_led_set(int on);
void ecore_fb_led_blink_set(double speed);
void ecore_fb_contrast_set(double cr);
double ecore_fb_contrast_get(void);
double ecore_fb_light_sensor_get(void);
void ecore_fb_callback_gain_set(void (*func) (void *data), void *data);
void ecore_fb_callback_lose_set(void (*func) (void *data), void *data);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,30 @@
## Process this file with automake to produce Makefile.in
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore
libecore_fb_la_LDFLAGS = -version-info 1:0:0 \
-L$(top_builddir)/src/lib/ecore/.libs
if BUILD_ECORE_FB
lib_LTLIBRARIES = libecore_fb.la
include_HEADERS = \
Ecore_Fb.h
libecore_fb_la_SOURCES = \
ecore_fb.c \
ecore_fb_private.h
libecore_fb_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la
libecore_fb_la_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la
endif
EXTRA_DIST = \
Ecore_Fb.h \
ecore_fb.c \
ecore_fb_private.h

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
#ifndef _ECORE_FB_PRIVATE_H
#define _ECORE_FB_PRIVATE_H
/* hacks to stop people NEEDING #include <linux/h3600_ts.h> */
#ifndef TS_SET_CAL
#define TS_SET_CAL 0x4014660b
#endif
#ifndef TS_GET_CAL
#define TS_GET_CAL 0x8014660a
#endif
#ifndef TS_SET_BACKLIGHT
#define TS_SET_BACKLIGHT 0x40086614
#endif
#ifndef TS_GET_BACKLIGHT
#define TS_GET_BACKLIGHT 0x80086614
#endif
#ifndef LED_ON
#define LED_ON 0x40046605
#endif
#ifndef TS_SET_CONTRAST
#define TS_SET_CONTRAST 0x40046615
#endif
#ifndef TS_GET_CONTRAST
#define TS_GET_CONTRAST 0x80046615
#endif
#ifndef FLITE_ON
#define FLITE_ON 0x40046607
#endif
#endif

View File

@ -0,0 +1,105 @@
#ifndef _ECORE_IPC_H
#define _ECORE_IPC_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ECORE_IPC_PRIVATE_H
typedef void Ecore_Ipc_Server; /**< An IPC connection handle */
typedef void Ecore_Ipc_Client; /**< An IPC connection handle */
#endif
typedef enum _Ecore_Ipc_Type
{
ECORE_IPC_LOCAL_USER,
ECORE_IPC_LOCAL_SYSTEM,
ECORE_IPC_REMOTE_SYSTEM,
} Ecore_Ipc_Type;
typedef struct _Ecore_Ipc_Event_Client_Add Ecore_Ipc_Event_Client_Add;
typedef struct _Ecore_Ipc_Event_Client_Del Ecore_Ipc_Event_Client_Del;
typedef struct _Ecore_Ipc_Event_Server_Add Ecore_Ipc_Event_Server_Add;
typedef struct _Ecore_Ipc_Event_Server_Del Ecore_Ipc_Event_Server_Del;
typedef struct _Ecore_Ipc_Event_Client_Data Ecore_Ipc_Event_Client_Data;
typedef struct _Ecore_Ipc_Event_Server_Data Ecore_Ipc_Event_Server_Data;
struct _Ecore_Ipc_Event_Client_Add
{
Ecore_Ipc_Client *client;
};
struct _Ecore_Ipc_Event_Client_Del
{
Ecore_Ipc_Client *client;
};
struct _Ecore_Ipc_Event_Server_Add
{
Ecore_Ipc_Server *server;
};
struct _Ecore_Ipc_Event_Server_Del
{
Ecore_Ipc_Server *server;
};
struct _Ecore_Ipc_Event_Client_Data
{
Ecore_Ipc_Client *client;
/* FIXME: this needs to become an ipc message */
int major;
int minor;
int ref;
int ref_to;
int response;
void *data;
int size;
};
struct _Ecore_Ipc_Event_Server_Data
{
Ecore_Ipc_Server *server;
/* FIXME: this needs to become an ipc message */
int major;
int minor;
int ref;
int ref_to;
int response;
void *data;
int size;
};
extern int ECORE_IPC_EVENT_CLIENT_ADD;
extern int ECORE_IPC_EVENT_CLIENT_DEL;
extern int ECORE_IPC_EVENT_SERVER_ADD;
extern int ECORE_IPC_EVENT_SERVER_DEL;
extern int ECORE_IPC_EVENT_CLIENT_DATA;
extern int ECORE_IPC_EVENT_SERVER_DATA;
int ecore_ipc_init(void);
int ecore_ipc_shutdown(void);
/* FIXME: need to add protocol type parameter */
Ecore_Ipc_Server *ecore_ipc_server_add(Ecore_Ipc_Type type, char *name, int port, const void *data);
/* FIXME: need to add protocol type parameter */
Ecore_Ipc_Server *ecore_ipc_server_connect(Ecore_Ipc_Type type, char *name, int port, const void *data);
void *ecore_ipc_server_del(Ecore_Ipc_Server *svr);
void *ecore_ipc_server_data_get(Ecore_Ipc_Server *svr);
int ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr);
/* FIXME: this needs to become an ipc message */
int ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, void *data, int size);
/* FIXME: this needs to become an ipc message */
int ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, void *data, int size);
Ecore_Ipc_Server *ecore_ipc_client_server_get(Ecore_Ipc_Client *cl);
void *ecore_ipc_client_del(Ecore_Ipc_Client *cl);
void ecore_ipc_client_data_set(Ecore_Ipc_Client *cl, const void *data);
void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,34 @@
## Process this file with automake to produce Makefile.in
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/ecore_con
libecore_ipc_la_LDFLAGS = -version-info 1:0:0 \
-L$(top_builddir)/src/lib/ecore/.libs \
-L$(top_builddir)/src/lib/ecore_con/.libs
if BUILD_ECORE_IPC
lib_LTLIBRARIES = libecore_ipc.la
include_HEADERS = \
Ecore_Ipc.h
libecore_ipc_la_SOURCES = \
ecore_ipc.c \
ecore_ipc_private.h
libecore_ipc_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_con/libecore_con.la
libecore_ipc_la_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_con/libecore_con.la
endif
EXTRA_DIST = \
Ecore_Ipc.h \
ecore_ipc.c \
ecore_ipc_private.h

View File

@ -0,0 +1,790 @@
#include "Ecore.h"
#include "Ecore_Con.h"
#include "ecore_private.h"
#include "ecore_ipc_private.h"
#include "Ecore_Ipc.h"
#include <netinet/in.h>
typedef struct _Ecore_Ipc_Msg_Head Ecore_Ipc_Msg_Head;
struct _Ecore_Ipc_Msg_Head
{
int major;
int minor;
int ref;
int ref_to;
int response;
int size;
} __attribute__ ((packed));
static int _ecore_ipc_event_client_add(void *data, int ev_type, void *ev);
static int _ecore_ipc_event_client_del(void *data, int ev_type, void *ev);
static int _ecore_ipc_event_server_add(void *data, int ev_type, void *ev);
static int _ecore_ipc_event_server_del(void *data, int ev_type, void *ev);
static int _ecore_ipc_event_client_data(void *data, int ev_type, void *ev);
static int _ecore_ipc_event_server_data(void *data, int ev_type, void *ev);
static void _ecore_ipc_event_client_add_free(void *data, void *ev);
static void _ecore_ipc_event_client_del_free(void *data, void *ev);
static void _ecore_ipc_event_server_add_free(void *data, void *ev);
static void _ecore_ipc_event_server_del_free(void *data, void *ev);
static void _ecore_ipc_event_client_data_free(void *data, void *ev);
static void _ecore_ipc_event_server_data_free(void *data, void *ev);
int ECORE_IPC_EVENT_CLIENT_ADD = 0;
int ECORE_IPC_EVENT_CLIENT_DEL = 0;
int ECORE_IPC_EVENT_SERVER_ADD = 0;
int ECORE_IPC_EVENT_SERVER_DEL = 0;
int ECORE_IPC_EVENT_CLIENT_DATA = 0;
int ECORE_IPC_EVENT_SERVER_DATA = 0;
static int init_count = 0;
static Ecore_Ipc_Server *servers = NULL;
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_ipc_init(void)
{
if (!init_count) ecore_con_init();
init_count++;
if (!ECORE_IPC_EVENT_CLIENT_ADD)
{
ECORE_IPC_EVENT_CLIENT_ADD = ecore_event_type_new();
ECORE_IPC_EVENT_CLIENT_DEL = ecore_event_type_new();
ECORE_IPC_EVENT_SERVER_ADD = ecore_event_type_new();
ECORE_IPC_EVENT_SERVER_DEL = ecore_event_type_new();
ECORE_IPC_EVENT_CLIENT_DATA = ecore_event_type_new();
ECORE_IPC_EVENT_SERVER_DATA = ecore_event_type_new();
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, _ecore_ipc_event_client_add, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, _ecore_ipc_event_client_del, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _ecore_ipc_event_server_add, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, _ecore_ipc_event_server_del, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, _ecore_ipc_event_client_data, NULL);
ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, _ecore_ipc_event_server_data, NULL);
}
return init_count;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_ipc_shutdown(void)
{
if (init_count > 0)
{
init_count--;
if (init_count > 0) return init_count;
while (servers) ecore_ipc_server_del(servers);
ecore_con_shutdown();
}
return 0;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Ipc_Server *
ecore_ipc_server_add(Ecore_Ipc_Type type, char *name, int port, const void *data)
{
Ecore_Ipc_Server *svr;
svr = calloc(1, sizeof(Ecore_Ipc_Server));
if (!svr) return NULL;
switch (type)
{
case ECORE_IPC_LOCAL_USER:
svr->server = ecore_con_server_add(ECORE_CON_LOCAL_USER, name, port, svr);
break;
case ECORE_IPC_LOCAL_SYSTEM:
svr->server = ecore_con_server_add(ECORE_CON_LOCAL_SYSTEM, name, port, svr);
break;
case ECORE_IPC_REMOTE_SYSTEM:
svr->server = ecore_con_server_add(ECORE_CON_REMOTE_SYSTEM, name, port, svr);
break;
default:
free(svr);
return NULL;
}
if (!svr->server)
{
free(svr);
return NULL;
}
svr->data = (void *)data;
servers = _ecore_list_append(servers, svr);
ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER);
return svr;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Ipc_Server *
ecore_ipc_server_connect(Ecore_Ipc_Type type, char *name, int port, const void *data)
{
Ecore_Ipc_Server *svr;
svr = calloc(1, sizeof(Ecore_Ipc_Server));
if (!svr) return NULL;
switch (type)
{
case ECORE_IPC_LOCAL_USER:
svr->server = ecore_con_server_connect(ECORE_CON_LOCAL_USER, name, port, svr);
break;
case ECORE_IPC_LOCAL_SYSTEM:
svr->server = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM, name, port, svr);
break;
case ECORE_IPC_REMOTE_SYSTEM:
svr->server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, name, port, svr);
break;
default:
free(svr);
return NULL;
}
if (!svr->server)
{
free(svr);
return NULL;
}
svr->data = (void *)data;
servers = _ecore_list_append(servers, svr);
ECORE_MAGIC_SET(svr, ECORE_MAGIC_IPC_SERVER);
return svr;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_ipc_server_del(Ecore_Ipc_Server *svr)
{
void *data;
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
"ecore_ipc_server_del");
return NULL;
}
ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE);
data = svr->data;
while (svr->clients) ecore_ipc_client_del((Ecore_Ipc_Client *)svr->clients);
ecore_con_server_del(svr->server);
servers = _ecore_list_remove(servers, svr);
if (svr->buf) free(svr->buf);
free(svr);
return data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_ipc_server_data_get(Ecore_Ipc_Server *svr)
{
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
"ecore_ipc_server_data_get");
return NULL;
}
return svr->data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr)
{
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
"ecore_ipc_server_connected_get");
return 0;
}
return ecore_con_server_connected_get(svr->server);
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, void *data, int size)
{
Ecore_Ipc_Msg_Head msg;
int ret;
if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
{
ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER,
"ecore_ipc_server_send");
return 0;
}
if (size < 0) size = 0;
msg.major = htonl(major);
msg.minor = htonl(minor);
msg.ref = htonl(ref);
msg.ref_to = htonl(ref_to);
msg.response = htonl(response);
msg.size = htonl(size);
ret = ecore_con_server_send(svr->server, &msg, sizeof(Ecore_Ipc_Msg_Head));
if (size > 0) ret |= ecore_con_server_send(svr->server, data, size);
return ret;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
int
ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, void *data, int size)
{
Ecore_Ipc_Msg_Head msg;
int ret;
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
"ecore_ipc_client_send");
return 0;
}
if (size < 0) size = 0;
msg.major = htonl(major);
msg.minor = htonl(minor);
msg.ref = htonl(ref);
msg.ref_to = htonl(ref_to);
msg.response = htonl(response);
msg.size = htonl(size);
ret = ecore_con_client_send(cl->client, &msg, sizeof(Ecore_Ipc_Msg_Head));
if (size > 0) ret |= ecore_con_client_send(cl->client, data, size);
return ret;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Ipc_Server *
ecore_ipc_client_server_get(Ecore_Ipc_Client *cl)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
"ecore_ipc_client_server_get");
return NULL;
}
return (ecore_con_server_data_get(ecore_con_client_server_get(cl->client)));
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_ipc_client_del(Ecore_Ipc_Client *cl)
{
void *data;
Ecore_Ipc_Server *svr;
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
"ecore_ipc_client_del");
return NULL;
}
ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
data = cl->data;
svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client));
ecore_con_client_del(cl->client);
svr->clients = _ecore_list_remove(svr->clients, cl);
if (cl->buf) free(cl->buf);
free(cl);
return data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_ipc_client_data_set(Ecore_Ipc_Client *cl, const void *data)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
"ecore_ipc_client_data_set");
return;
}
cl->data = (void *)data;
}
/**
* To be documented.
*
* FIXME: To be fixed.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_ipc_client_data_get(Ecore_Ipc_Client *cl)
{
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT))
{
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT,
"ecore_ipc_client_data_get");
return NULL;
}
return cl->data;
}
static int
_ecore_ipc_event_client_add(void *data, int ev_type, void *ev)
{
Ecore_Con_Event_Client_Add *e;
e = ev;
if (!_ecore_list_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1;
/* handling code here */
{
Ecore_Ipc_Client *cl;
Ecore_Ipc_Server *svr;
cl = calloc(1, sizeof(Ecore_Ipc_Client));
if (!cl) return 0;
svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT);
cl->client = e->client;
ecore_con_client_data_set(cl->client, (void *)cl);
svr->clients = _ecore_list_append(svr->clients, cl);
{
Ecore_Ipc_Event_Client_Add *e2;
e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Add));
if (e2)
{
e2->client = cl;
ecore_event_add(ECORE_IPC_EVENT_CLIENT_ADD, e2,
_ecore_ipc_event_client_add_free, NULL);
}
}
}
return 0;
}
static int
_ecore_ipc_event_client_del(void *data, int ev_type, void *ev)
{
Ecore_Con_Event_Client_Del *e;
e = ev;
if (!_ecore_list_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1;
/* handling code here */
{
Ecore_Ipc_Client *cl;
cl = ecore_con_client_data_get(e->client);
{
Ecore_Ipc_Event_Client_Del *e2;
e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Del));
if (e2)
{
e2->client = cl;
ecore_event_add(ECORE_IPC_EVENT_CLIENT_DEL, e2,
_ecore_ipc_event_client_del_free, NULL);
}
}
}
return 0;
}
static int
_ecore_ipc_event_server_add(void *data, int ev_type, void *ev)
{
Ecore_Con_Event_Server_Add *e;
e = ev;
if (!_ecore_list_find(servers, ecore_con_server_data_get(e->server))) return 1;
/* handling code here */
{
Ecore_Ipc_Server *svr;
svr = ecore_con_server_data_get(e->server);
{
Ecore_Ipc_Event_Server_Add *e2;
e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Add));
if (e2)
{
e2->server = svr;
ecore_event_add(ECORE_IPC_EVENT_SERVER_ADD, e2,
_ecore_ipc_event_server_add_free, NULL);
}
}
}
return 0;
}
static int
_ecore_ipc_event_server_del(void *data, int ev_type, void *ev)
{
Ecore_Con_Event_Server_Del *e;
e = ev;
if (!_ecore_list_find(servers, ecore_con_server_data_get(e->server))) return 1;
/* handling code here */
{
Ecore_Ipc_Server *svr;
svr = ecore_con_server_data_get(e->server);
{
Ecore_Ipc_Event_Server_Del *e2;
e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Del));
if (e2)
{
e2->server = svr;
ecore_event_add(ECORE_IPC_EVENT_SERVER_DEL, e2,
_ecore_ipc_event_server_del_free, NULL);
}
}
}
return 0;
}
static int
_ecore_ipc_event_client_data(void *data, int ev_type, void *ev)
{
Ecore_Con_Event_Client_Data *e;
e = ev;
if (!_ecore_list_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return 1;
/* handling code here */
{
Ecore_Ipc_Client *cl;
Ecore_Ipc_Msg_Head *msg;
cl = ecore_con_client_data_get(e->client);
if (!cl->buf)
{
cl->buf_size = e->size;
cl->buf = e->data;
e->data = NULL; /* take it out of the old event */
}
else
{
unsigned char *buf;
buf = realloc(cl->buf, cl->buf_size + e->size);
if (!buf)
{
free(cl->buf);
cl->buf = 0;
cl->buf_size = 0;
return 0;
}
cl->buf = buf;
memcpy(cl->buf + cl->buf_size, e->data, e->size);
cl->buf_size += e->size;
}
/* examine header */
if (cl->buf_size >= sizeof(Ecore_Ipc_Msg_Head))
{
int major, minor, ref, ref_to, response, size;
int offset = 0;
msg = (Ecore_Ipc_Msg_Head *)(cl->buf + offset);
major = ntohl(msg->major);
minor = ntohl(msg->minor);
ref = ntohl(msg->ref);
ref_to = ntohl(msg->ref_to);
response = ntohl(msg->response);
size = ntohl(msg->size);
if (size < 0) size = 0;
/* there is enough data in the buffer for a full message */
if (cl->buf_size >= (sizeof(Ecore_Ipc_Msg_Head) + size))
{
unsigned char *buf;
Ecore_Ipc_Event_Client_Data *e2;
redo:
buf = NULL;
if (size > 0)
{
buf = malloc(size);
if (!buf) return 0;
memcpy(buf, cl->buf + offset + sizeof(Ecore_Ipc_Msg_Head), size);
}
e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Data));
if (e2)
{
e2->client = cl;
e2->major = major;
e2->minor = minor;
e2->ref = ref;
e2->ref_to = ref_to;
e2->response = response;
e2->size = size;
e2->data = buf;
ecore_event_add(ECORE_IPC_EVENT_CLIENT_DATA, e2,
_ecore_ipc_event_client_data_free, NULL);
}
offset += (sizeof(Ecore_Ipc_Msg_Head) + size);
if (cl->buf_size - offset >= sizeof(Ecore_Ipc_Msg_Head))
{
msg = (Ecore_Ipc_Msg_Head *)(cl->buf + offset);
major = ntohl(msg->major);
minor = ntohl(msg->minor);
ref = ntohl(msg->ref);
ref_to = ntohl(msg->ref_to);
response = ntohl(msg->response);
size = ntohl(msg->size);
if (size < 0) size = 0;
if (cl->buf_size - offset >= (sizeof(Ecore_Ipc_Msg_Head) + size))
goto redo;
}
/* remove data from our buffer and "scoll" the rest down */
size = cl->buf_size - offset;
/* if amount left after scroll is > 0 */
if (size > 0)
{
buf = malloc(size);
if (!buf)
{
free(cl->buf);
cl->buf = NULL;
cl->buf_size = 0;
return 0;
}
memcpy(buf, cl->buf + offset + sizeof(Ecore_Ipc_Msg_Head), size);
free(cl->buf);
cl->buf = buf;
cl->buf_size = size;
}
else
{
free(cl->buf);
cl->buf = NULL;
cl->buf_size = 0;
}
}
}
}
return 0;
}
static int
_ecore_ipc_event_server_data(void *data, int ev_type, void *ev)
{
Ecore_Con_Event_Server_Data *e;
e = ev;
if (!_ecore_list_find(servers, ecore_con_server_data_get(e->server))) return 1;
/* handling code here */
{
Ecore_Ipc_Server *svr;
Ecore_Ipc_Msg_Head *msg;
svr = ecore_con_server_data_get(e->server);
if (!svr->buf)
{
svr->buf_size = e->size;
svr->buf = e->data;
e->data = NULL; /* take it out of the old event */
}
else
{
unsigned char *buf;
buf = realloc(svr->buf, svr->buf_size + e->size);
if (!buf)
{
free(svr->buf);
svr->buf = 0;
svr->buf_size = 0;
return 0;
}
svr->buf = buf;
memcpy(svr->buf + svr->buf_size, e->data, e->size);
svr->buf_size += e->size;
}
/* examine header */
if (svr->buf_size >= sizeof(Ecore_Ipc_Msg_Head))
{
int major, minor, ref, ref_to, response, size;
int offset = 0;
msg = (Ecore_Ipc_Msg_Head *)(svr->buf + offset);
major = ntohl(msg->major);
minor = ntohl(msg->minor);
ref = ntohl(msg->ref);
ref_to = ntohl(msg->ref_to);
response = ntohl(msg->response);
size = ntohl(msg->size);
if (size < 0) size = 0;
/* there is enough data in the buffer for a full message */
if (svr->buf_size >= (sizeof(Ecore_Ipc_Msg_Head) + size))
{
unsigned char *buf;
Ecore_Ipc_Event_Server_Data *e2;
redo:
buf = NULL;
if (size > 0)
{
buf = malloc(size);
if (!buf) return 0;
memcpy(buf, svr->buf + offset + sizeof(Ecore_Ipc_Msg_Head), size);
}
e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Data));
if (e2)
{
e2->server = svr;
e2->major = major;
e2->minor = minor;
e2->ref = ref;
e2->ref_to = ref_to;
e2->response = response;
e2->size = size;
e2->data = buf;
ecore_event_add(ECORE_IPC_EVENT_SERVER_DATA, e2,
_ecore_ipc_event_server_data_free, NULL);
}
offset += (sizeof(Ecore_Ipc_Msg_Head) + size);
if (svr->buf_size - offset >= sizeof(Ecore_Ipc_Msg_Head))
{
msg = (Ecore_Ipc_Msg_Head *)(svr->buf + offset);
major = ntohl(msg->major);
minor = ntohl(msg->minor);
ref = ntohl(msg->ref);
ref_to = ntohl(msg->ref_to);
response = ntohl(msg->response);
size = ntohl(msg->size);
if (size < 0) size = 0;
if (svr->buf_size - offset >= (sizeof(Ecore_Ipc_Msg_Head) + size))
goto redo;
}
/* remove data from our buffer and "scoll" the rest down */
size = svr->buf_size - offset;
/* if amount left after scroll is > 0 */
if (size > 0)
{
buf = malloc(size);
if (!buf)
{
free(svr->buf);
svr->buf = NULL;
svr->buf_size = 0;
return 0;
}
memcpy(buf, svr->buf + offset + sizeof(Ecore_Ipc_Msg_Head), size);
free(svr->buf);
svr->buf = buf;
svr->buf_size = size;
}
else
{
free(svr->buf);
svr->buf = NULL;
svr->buf_size = 0;
}
}
}
}
return 0;
}
static void
_ecore_ipc_event_client_add_free(void *data, void *ev)
{
Ecore_Ipc_Event_Client_Add *e;
e = ev;
free(e);
}
static void
_ecore_ipc_event_client_del_free(void *data, void *ev)
{
Ecore_Ipc_Event_Client_Del *e;
e = ev;
free(e);
}
static void
_ecore_ipc_event_server_add_free(void *data, void *ev)
{
Ecore_Ipc_Event_Server_Add *e;
e = ev;
free(e);
}
static void
_ecore_ipc_event_server_del_free(void *data, void *ev)
{
Ecore_Ipc_Event_Server_Del *e;
e = ev;
free(e);
}
static void
_ecore_ipc_event_client_data_free(void *data, void *ev)
{
Ecore_Ipc_Event_Client_Data *e;
e = ev;
if (e->data) free(e->data);
free(e);
}
static void
_ecore_ipc_event_server_data_free(void *data, void *ev)
{
Ecore_Ipc_Event_Server_Data *e;
e = ev;
if (e->data) free(e->data);
free(e);
}

View File

@ -0,0 +1,31 @@
#ifndef _ECORE_IPC_PRIVATE_H
#define _ECORE_IPC_PRIVATE_H
#define ECORE_MAGIC_IPC_SERVER 0x87786556
#define ECORE_MAGIC_IPC_CLIENT 0x78875665
typedef struct _Ecore_Ipc_Client Ecore_Ipc_Client;
typedef struct _Ecore_Ipc_Server Ecore_Ipc_Server;
struct _Ecore_Ipc_Client
{
Ecore_List __list_data;
ECORE_MAGIC;
Ecore_Con_Client *client;
void *data;
unsigned char *buf;
int buf_size;
};
struct _Ecore_Ipc_Server
{
Ecore_List __list_data;
ECORE_MAGIC;
Ecore_Con_Server *server;
Ecore_Ipc_Client *clients;
void *data;
unsigned char *buf;
int buf_size;
};
#endif

View File

@ -0,0 +1,19 @@
#ifndef _ECORE_JOB_H
#define _ECORE_JOB_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ECORE_JOB_PRIVATE_H
typedef void Ecore_Job; /**< A job handle */
#endif
Ecore_Job *ecore_job_add(void (*func) (void *data), const void *data);
void *ecore_job_del(Ecore_Job *job);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,30 @@
## Process this file with automake to produce Makefile.in
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore
libecore_job_la_LDFLAGS = -version-info 1:0:0 \
-L$(top_builddir)/src/lib/ecore/.libs
if BUILD_ECORE_JOB
lib_LTLIBRARIES = libecore_job.la
include_HEADERS = \
Ecore_Job.h
libecore_job_la_SOURCES = \
ecore_job.c \
ecore_job_private.h
libecore_job_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la
libecore_job_la_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la
endif
EXTRA_DIST = \
Ecore_Job.h \
ecore_job.c \
ecore_job_private.h

View File

@ -0,0 +1,91 @@
#include "Ecore.h"
#include "ecore_private.h"
#include "ecore_job_private.h"
#include "Ecore_Job.h"
static void _ecore_job_free(void *data, void *ev);
static int _ecore_job_event_handler(void *data, int type, void *ev);
static int ecore_event_job_type = 0;
/**
* Add a job to the event queue
* @param func The function to be called when the job gets handled
* @param data The data to be passed to the job function
* @return A job handle
*
* Add a job to the queue to be executed by the event system later on and
* return a pointer to the job handle. When the job is to be executed, the
* function @p func is called and passed the pointer @p data. once the job has
* been executed the job handle is no longer valid.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
Ecore_Job *
ecore_job_add(void (*func) (void *data), const void *data)
{
Ecore_Job *job;
if (!func) return NULL;
if (!ecore_event_job_type)
{
ecore_event_job_type = ecore_event_type_new();
ecore_event_handler_add(ecore_event_job_type, _ecore_job_event_handler, NULL);
}
job = calloc(1, sizeof(Ecore_Job));
if (!job) return NULL;
ECORE_MAGIC_SET(job, ECORE_MAGIC_JOB);
job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_free, NULL);
if (!job->event)
{
free(job);
return NULL;
}
job->func = func;
job->data = (void *)data;
return job;
}
/**
* Delete a queued job
* @param job The job to delete
* @return The data pointer to be passed to the job
*
* This removed a job from the queue (if it hasn't been executed yet) and
* returns the data pointer that was to be passed to it.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void *
ecore_job_del(Ecore_Job *job)
{
void *data;
if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_JOB))
{
ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB,
"ecore_job_del");
return NULL;
}
data = job->data;
ECORE_MAGIC_SET(job, ECORE_MAGIC_NONE);
ecore_event_del(job->event);
return data;
}
static void
_ecore_job_free(void *data, void *ev)
{
Ecore_Job *job;
job = ev;
free(job);
}
static int
_ecore_job_event_handler(void *data, int type, void *ev)
{
Ecore_Job *job;
job = ev;
job->func(job->data);
return 0;
}

Some files were not shown because too many files have changed in this diff Show More