Initial event abstraction for e17. More work needed.


			
			
				devs/devilhorns/wayland_egl
			
			
		
Tom Gilbert 22 years ago
parent f984e4ab77
commit 8685930a75
  1. 29
      legacy/ecore/.cvsignore
  2. 2
      legacy/ecore/AUTHORS
  3. 20
      legacy/ecore/COPYING
  4. 0
      legacy/ecore/ChangeLog
  5. 0
      legacy/ecore/INSTALL
  6. 31
      legacy/ecore/Makefile.am
  7. 0
      legacy/ecore/NEWS
  8. 0
      legacy/ecore/README
  9. 3
      legacy/ecore/acconfig.h
  10. 148
      legacy/ecore/autogen.sh
  11. 61
      legacy/ecore/configure.in
  12. 29
      legacy/ecore/src/.cvsignore
  13. 19
      legacy/ecore/src/Makefile.am
  14. 128
      legacy/ecore/src/e_ev_filter.c
  15. 15
      legacy/ecore/src/e_ev_filter.h
  16. 323
      legacy/ecore/src/e_ev_signal.c
  17. 5
      legacy/ecore/src/e_ev_signal.h
  18. 1029
      legacy/ecore/src/e_ev_x.c
  19. 5
      legacy/ecore/src/e_ev_x.h
  20. 404
      legacy/ecore/src/e_events.c
  21. 430
      legacy/ecore/src/e_events.h
  22. 1
      legacy/ecore/src/e_mem.c
  23. 60
      legacy/ecore/src/e_mem.h
  24. 151
      legacy/ecore/src/e_str.c
  25. 18
      legacy/ecore/src/e_str.h
  26. 164
      legacy/ecore/src/e_util.c
  27. 56
      legacy/ecore/src/e_util.h
  28. 2306
      legacy/ecore/src/e_x.c
  29. 230
      legacy/ecore/src/e_x.h

@ -0,0 +1,29 @@
*.lo
*.la
.deps
.libs
Makefile
Makefile.in
aclocal.m4
confdefs.h
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
install-sh
libtool
ltconfig
ltmain.sh
missing
mkinstalldirs
stamp-h
stamp-h.in
*.tar.gz
macros
*~
*.spec
.icons

@ -0,0 +1,2 @@
The Rasterman <raster@rasterman.com>
Tom Gilbert <tom@linuxbrit.co.uk>

@ -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,0 +1,31 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = src
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)/pixmaps; \
for file in $(srcdir)/data/*; do \
if test -f $$file; then \
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/; \
fi \
done \
fi
dist-hook:
if test -d data; then \
mkdir $(distdir)/data; \
for file in data/*; do \
if test -f $$file; then \
cp -p $$file $(distdir)/data; \
fi \
done \
fi
EXTRA_DIST = README AUTHORS COPYING

@ -0,0 +1,3 @@
#undef PACKAGE_LOCALE_DIR
#undef PACKAGE_DATA_DIR
#undef PACKAGE_SOURCE_DIR

@ -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

@ -0,0 +1,61 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(configure.in)
AM_INIT_AUTOMAKE(libecore, 0.1)
AM_CONFIG_HEADER(config.h)
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AM_PROG_LIBTOOL
AM_WITH_DMALLOC
dnl Set PACKAGE_LOCALE_DIR in config.h.
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${ac_default_prefix}/${DATADIRNAME}/locale")
else
AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${prefix}/${DATADIRNAME}/locale")
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
evas_cflags=`evas-config --cflags`
evas_libs=`evas-config --libs`
edb_cflags=`edb-config --cflags`
edb_libs=`edb-config --libs`
AC_SUBST(evas_cflags)
AC_SUBST(evas_libs)
AC_SUBST(edb_cflags)
AC_SUBST(edb_libs)
AC_OUTPUT([
Makefile
src/Makefile
])

@ -0,0 +1,29 @@
*.lo
*.la
.deps
.libs
Makefile
Makefile.in
aclocal.m4
confdefs.h
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
install-sh
libtool
ltconfig
ltmain.sh
missing
mkinstalldirs
stamp-h
stamp-h.in
*.tar.gz
macros
*~
*.spec
.icons

@ -0,0 +1,19 @@
## Process this file with automake to produce Makefile.in
INCLUDES = \
@evas_cflags@ @edb_cflags@
lib_LTLIBRARIES = libecore.la
libecore_la_SOURCES = \
e_ev_filter.c e_ev_filter.h \
e_ev_signal.c e_ev_signal.h \
e_ev_x.c e_ev_x.h \
e_events.c e_events.h \
e_mem.c e_mem.h \
e_str.c e_str.h \
e_util.c e_util.h \
e_x.c e_x.h
libecore_la_LIBADD = @evas_libs@ @edb_libs@ -lm

@ -0,0 +1,128 @@
#include "e_ev_filter.h"
#include "e_str.h"
#include "e_mem.h"
#include "e_util.h"
typedef struct _ev_handler Ev_Handler;
typedef struct _ev_idle_handler Ev_Idle_Handler;
struct _ev_handler
{
void (*func) (Eevent * ev);
Ev_Handler *next;
};
struct _ev_idle_handler
{
void (*func) (void *data);
void *data;
Ev_Idle_Handler *next;
};
static Ev_Handler *handler[EV_MAX];
static Ev_Idle_Handler *idle_handlers = NULL;
void
e_event_filter(Eevent * ev)
{
Eevent *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 == EV_MOUSE_MOVE)
motion_events++;
if (evp->type == EV_DND_DROP_POSITION)
dnd_pos_events++;
if (evp->type == EV_DND_DROP_STATUS)
dnd_status_events++;
}
for (evp = ev; evp; evp = evp->next)
{
if (evp->type == EV_MOUSE_MOVE)
{
if (motion_events > 1)
{
evp->ignore = 1;
motion_events--;
}
}
else if (evp->type == EV_DND_DROP_POSITION)
{
if (dnd_pos_events > 1)
{
evp->ignore = 1;
dnd_pos_events--;
}
}
else if (evp->type == EV_DND_DROP_STATUS)
{
if (dnd_status_events > 1)
{
evp->ignore = 1;
dnd_status_events--;
}
}
}
}
void
e_event_filter_events_handle(Eevent * ev)
{
Eevent *evp;
for (evp = ev; evp; evp = evp->next)
{
Ev_Handler *h;
for (h = handler[evp->type]; h; h = h->next)
{
if ((!evp->ignore) && (h->func))
h->func(evp);
}
}
}
void
e_event_filter_idle_handle(void)
{
Ev_Idle_Handler *h;
for (h = idle_handlers; h; h = h->next)
h->func(h->data);
}
void
e_event_filter_init(void)
{
int i;
for (i = 0; i < EV_MAX; i++)
handler[i] = NULL;
}
void
e_event_filter_handler_add(Eevent_Type type, void (*func) (Eevent * ev))
{
Ev_Handler *h;
h = NEW(Ev_Handler, 1);
h->func = func;
h->next = handler[type];
handler[type] = h;
}
void
e_event_filter_idle_handler_add(void (*func) (void *data), void *data)
{
Ev_Idle_Handler *h;
h = NEW(Ev_Idle_Handler, 1);
h->func = func;
h->data = data;
h->next = idle_handlers;
idle_handlers = h;
}

@ -0,0 +1,15 @@
#ifndef E_EV_FILTER_H
#define E_EV_FILTER_H 1
#include "e_events.h"
void e_event_filter(Eevent * ev);
void e_event_filter_events_handle(Eevent * ev);
void e_event_filter_idle_handle(void);
void e_event_filter_init(void);
void e_event_filter_handler_add(Eevent_Type type,
void (*func) (Eevent * ev));
void e_event_filter_idle_handler_add(void (*func) (void *data),
void *data);
#endif

@ -0,0 +1,323 @@
#include "e_events.h"
#include "e_ev_signal.h"
#include "e_str.h"
#include "e_mem.h"
#include "e_util.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>
static void e_ev_signal_free(void *event);
static void e_ev_signal_handle_sigchld(int num);
static void e_ev_signal_handle_sigusr1(int num);
static void e_ev_signal_handle_sigusr2(int num);
static void e_ev_signal_handle_sighup(int num);
static void e_ev_signal_handle_sigpipe(int num);
static void e_ev_signal_handle_sigsegv(int num);
static void e_ev_signal_handle_sigfpe(int num);
static void e_ev_signal_handle_sigill(int num);
static void e_ev_signal_handle_sigbus(int num);
#ifdef HAVE_SIGSTKFLT
static void e_ev_signal_handle_sigstkflt(int num);
#endif
#ifdef HAVE_SIGPWR
static void e_ev_signal_handle_sigpwr(int num);
#endif
static void e_ev_signal_handle_sigchld(int num);
static void e_ev_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
e_ev_signal_free(void *event)
{
FREE(event);
}
/* signal handlers we can return from and add to signal recieved counts */
static void
e_ev_signal_handle_sigchld(int num)
{
signal_chld_count++;
return;
num = 0;
}
static void
e_ev_signal_handle_sigusr1(int num)
{
signal_usr1_count++;
return;
num = 0;
}
static void
e_ev_signal_handle_sigusr2(int num)
{
signal_usr2_count++;
return;
num = 0;
}
static void
e_ev_signal_handle_sighup(int num)
{
signal_hup_count++;
return;
num = 0;
}
/* signals to ignore */
static void
e_ev_signal_handle_sigpipe(int num)
{
return;
num = 0;
}
/* signal handlers we cant return from - so handle here */
static void
e_ev_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
e_ev_signal_handle_sigfpe(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
}
static void
e_ev_signal_handle_sigill(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
}
static void
e_ev_signal_handle_sigbus(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
}
#ifdef HAVE_SIGSTKFLT
static void
e_ev_signal_handle_sigstkflt(int num)
{
/* EEK - can't return - bad */
abort();
return;
num = 0;
}
#endif
static void
e_ev_signal_handle_sigint(int num)
{
exit(0);
return;
num = 0;
}
static void
e_ev_signal_handle_sigquit(int num)
{
exit(0);
return;
num = 0;
}
static void
e_ev_signal_handle_sigabrt(int num)
{
abort();
return;
num = 0;
}
static void
e_ev_signal_handle_sigalrm(int num)
{
return;
num = 0;
}
static void
e_ev_signal_handle_sigterm(int num)
{
exit(0);
return;
num = 0;
}
#ifdef HAVE_SIGPWR
static void
e_ev_signal_handle_sigpwr(int num)
{
exit(0);
return;
num = 0;
}
#endif
static void
e_ev_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))
{
Ev_Child *e;
int code;
code = WEXITSTATUS(status);
e = NEW(Ev_Child, 1);
e->pid = pid;
e->exit_code = code;
e_add_event(EV_CHILD, e, e_ev_signal_free);
}
}
signal_chld_count = 0;
}
while (signal_usr1_count > 0)
{
Ev_User *e;
e = NEW(Ev_User, 1);
e->num = 0;
e->hup = 0;
e_add_event(EV_USER, e, e_ev_signal_free);
signal_usr1_count--;
}
while (signal_hup_count > 0)
{
Ev_User *e;
e = NEW(Ev_User, 1);
e->num = 0;
e->hup = 1;
e_add_event(EV_USER, e, e_ev_signal_free);
signal_hup_count--;
}
return;
pid_pass = 0;
}
int
e_ev_signal_events_pending(void)
{
return (signal_chld_count + signal_usr1_count + signal_hup_count);
}
void
e_ev_signal_init(void)
{
struct sigaction sa;
e_add_event_pid(0, e_ev_signal_handle_all);
sa.sa_handler = e_ev_signal_handle_sigchld;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigusr1;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR1, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigusr2;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR2, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sighup;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGHUP, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigpipe;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGPIPE, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigsegv;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigfpe;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGFPE, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigill;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGILL, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigbus;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGBUS, &sa, (struct sigaction *)0);
#ifdef HAVE_SIGSTKFLT
sa.sa_handler = e_ev_signal_handle_sigstkflt;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGSTKFLT, &sa, (struct sigaction *)0);
#endif
sa.sa_handler = e_ev_signal_handle_sigint;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigquit;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGQUIT, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigabrt;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGABRT, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigalrm;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGALRM, &sa, (struct sigaction *)0);
sa.sa_handler = e_ev_signal_handle_sigterm;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGTERM, &sa, (struct sigaction *)0);
#ifdef HAVE_SIGPWR
sa.sa_handler = e_ev_signal_handle_sigpwr;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGPWR, &sa, (struct sigaction *)0);
#endif
}

@ -0,0 +1,5 @@
#ifndef E_EV_SIGNAL_H
#define E_EV_SIGNAL_H 1
void e_ev_signal_init(void);
int e_ev_signal_events_pending(void);
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,5 @@
#ifndef E_EV_X_H
#define E_EV_X_H 1
void e_ev_x_init(void);
char *e_key_press_translate_into_typeable(Ev_Key_Down * e);
#endif

@ -0,0 +1,404 @@
#include "e_events.h"
#include "e_ev_filter.h"
#include "e_str.h"
#include "e_mem.h"
#include "e_util.h"
#include "e_ev_signal.h"
#include <Edb.h>
#include <errno.h>
/* glocal (yes global/local) variabels for events */
Ev_Fd_Handler *fd_handlers = NULL;
Ev_Ipc_Handler *ipc_handlers = NULL;
Ev_Pid_Handler *pid_handlers = NULL;
Ev_Timer *timers = NULL;
Eevent *events = NULL;
Eevent *last_event = NULL;
/* local functions for event handling */
static void e_handle_event_timer(void);
static void e_handle_zero_event_timer(void);
/* public functions */
/* add an event to the end of the event queue */
void
e_add_event(Eevent_Type type, void *event, void (*ev_free) (void *event))
{
Eevent *ev;
ev = NEW(Eevent, 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
e_del_event(void *event)
{
Eevent *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
e_del_all_events(void)
{
Eevent *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;
}
Eevent *
e_get_last_event(void)
{
return last_event;
}
/* add a callback handler if fd is active for reading */
void
e_add_event_fd(int fd, void (*func) (int fd))
{
Ev_Fd_Handler *fd_h;
/* new handler struct */
fd_h = NEW(Ev_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
e_del_event_fd(int fd)
{
START_LIST_DEL(Ev_Fd_Handler, fd_handlers, (_p->fd == fd));
FREE(_p);
END_LIST_DEL;
}
void
e_add_event_pid(pid_t pid, void (*func) (pid_t pid))
{
Ev_Pid_Handler *pid_h;
/* delete the old handler */
e_del_event_pid(pid);
/* new handler struct */
pid_h = NEW(Ev_Pid_Handler, 1);
pid_h->next = pid_handlers;
pid_h->pid = pid;
pid_h->func = func;
pid_handlers = pid_h;
}
void
e_del_event_pid(pid_t pid)
{
START_LIST_DEL(Ev_Pid_Handler, pid_handlers, (_p->pid == pid));
FREE(_p);
END_LIST_DEL;
}
void
e_add_event_ipc(int ipc, void (*func) (int ipc))
{
Ev_Ipc_Handler *ipc_h;
/* delete the old handler */
e_del_event_ipc(ipc);
/* new handler struct */
ipc_h = NEW(Ev_Ipc_Handler, 1);
ipc_h->next = ipc_handlers;
ipc_h->ipc = ipc;
ipc_h->func = func;
ipc_handlers = ipc_h;
}
void
e_del_event_ipc(int ipc)
{
START_LIST_DEL(Ev_Ipc_Handler, ipc_handlers, (_p->ipc == ipc));
FREE(_p);
END_LIST_DEL;
}
/* sit in this loop forever and process events */
void
e_event_loop(void)
{
int count, fdsize, timed_out, were_events;
double time1, time2, prev_time = 0.0;
struct timeval tval;
fd_set fdset;
Ev_Fd_Handler *fd_h;
Ev_Pid_Handler *pid_h;
Ev_Ipc_Handler *ipc_h;
/* init some of the time variables */
time1 = e_get_time();
time2 = time1 - prev_time;
prev_time = time1;
for (;;)
{
/* 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;
}
count = 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;
e_handle_zero_event_timer();
if ((!e_events_pending()) &&
(!e_ev_signal_events_pending()))
count = select(fdsize + 1, &fdset, NULL, NULL, &tval);
}
/* no timers - just sit and block */
else
{
if (e_db_runtime_flush())
{
if ((!e_events_pending()) &&
(!e_ev_signal_events_pending()))
count = select(fdsize + 1, &fdset, NULL, NULL, NULL);
}
else
{
tval.tv_sec = 1;
tval.tv_usec = 0;
if ((!e_events_pending()) &&
(!e_ev_signal_events_pending()))
count = select(fdsize + 1, &fdset, NULL, NULL, &tval);
}
}
for (pid_h = pid_handlers; pid_h; pid_h = pid_h->next)
pid_h->func(pid_h->pid);
for (ipc_h = ipc_handlers; ipc_h; ipc_h = ipc_h->next)
ipc_h->func(ipc_h->ipc);
/* return < 0 - error or signal interrupt */
if (count < 0)
{
/* error */
if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF))
{
fprintf(stderr, "EEEEEEEEEEEEEEEEEEEEK\n");
exit(1);
}
}
/* timers are available and its a timeout */
if ((timers) && (count == 0))
{
e_handle_event_timer();
timed_out = 1;
}
if (count < 0)
count = 0;
if (e_events_pending())
{
count++;
FD_SET(e_x_get_fd(), &fdset);
}
/* fd's are active */
if (count > 0)
{
/* for every fd handler - if its fd si set - call the func */
for (fd_h = fd_handlers; fd_h;)
{
Ev_Fd_Handler *fdh;
fdh = fd_h;
fd_h = fd_h->next;
if (FD_ISSET(fdh->fd, &fdset))
fdh->func(fdh->fd);
}
}
if (events)
e_event_filter(events);
if (events)
{
e_event_filter_events_handle(events);
were_events = 1;
}
e_del_all_events();
if ((timed_out) || (were_events))
e_event_filter_idle_handle();
e_flush();
time1 = e_get_time();
time2 = time1 - prev_time;
prev_time = time1;
}
}
/* add a timeout funcitont o be called in "in" seconds with name name */
void
e_add_event_timer(char *name, double in, void (*func) (int val, void *data),
int val, void *data)
{
Ev_Timer *timer, *ptr, *pptr;
double tally;
if (name)
e_del_event_timer(name);
timer = NEW(Ev_Timer, 1);
timer->next = NULL;
timer->func = func;
timer->data = data;
timer->val = val;
timer->just_added = 1;
timer->in = in;
timer->name = e_string_dup(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 *
e_del_event_timer(char *name)
{
Ev_Timer *timer, *ptr, *pptr;
pptr = NULL;
ptr = timers;
while (ptr)
{
timer = ptr;
if (e_string_cmp(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
e_handle_event_timer(void)
{
Ev_Timer *timer;
if (!timers)
return;
timer = timers;
timers = timer->next;
(*(timer->func)) (timer->val, timer->data);
IF_FREE(timer->name);
FREE(timer);
}
static void
e_handle_zero_event_timer(void)
{
while ((timers) && (timers->in == 0.0))
e_handle_event_timer();
}

@ -0,0 +1,430 @@
#ifndef E_EVENTS_H
#define E_EVENTS_H 1
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include "e_x.h"
typedef struct _eev Eevent;
typedef struct _ev_fd_handler Ev_Fd_Handler;
typedef struct _ev_pid_handler Ev_Pid_Handler;
typedef struct _ev_ipc_handler Ev_Ipc_Handler;
typedef struct _ev_timer Ev_Timer;
typedef struct _ev_key_down Ev_Key_Down;
typedef struct _ev_key_up Ev_Key_Up;
typedef struct _ev_mouse_down Ev_Mouse_Down;
typedef struct _ev_mouse_up Ev_Mouse_Up;
typedef struct _ev_wheel Ev_Wheel;
typedef struct _ev_mouse_move Ev_Mouse_Move;
typedef struct _ev_window_enter Ev_Window_Enter;
typedef struct _ev_window_leave Ev_Window_Leave;
typedef struct _ev_window_focus_in Ev_Window_Focus_In;
typedef struct _ev_window_focus_out Ev_Window_Focus_Out;
typedef struct _ev_window_expose Ev_Window_Expose;
typedef struct _ev_window_visibility Ev_Window_Visibility;
typedef struct _ev_window_create Ev_Window_Create;
typedef struct _ev_window_destroy Ev_Window_Destroy;
typedef struct _ev_window_map Ev_Window_Map;
typedef struct _ev_window_unmap Ev_Window_Unmap;
typedef struct _ev_window_map_request Ev_Window_Map_Request;
typedef struct _ev_window_reparent Ev_Window_Reparent;
typedef struct _ev_window_configure Ev_Window_Configure;
typedef struct _ev_window_configure_request Ev_Window_Configure_Request;
typedef struct _ev_window_circulate Ev_Window_Circulate;
typedef struct _ev_window_circulate_request Ev_Window_Circulate_Request;
typedef struct _ev_window_property Ev_Window_Property;
typedef struct _ev_window_shape Ev_Window_Shape;
typedef struct _ev_client_message Ev_Message;
typedef struct _ev_colormap Ev_Colormap;
typedef struct _ev_window_delete Ev_Window_Delete;
typedef struct _ev_child Ev_Child;
typedef struct _ev_user Ev_User;
typedef struct _ev_file_progress Ev_File_Progress;
typedef struct _ev_file_update Ev_File_Update;
typedef struct _ev_dnd_drop_request Ev_Dnd_Drop_Request;
typedef struct _ev_dnd_drop_end Ev_Dnd_Drop_End;
typedef struct _ev_dnd_drop_position Ev_Dnd_Drop_Position;
typedef struct _ev_dnd_drop Ev_Dnd_Drop;
typedef struct _ev_dnd_drop_status Ev_Dnd_Drop_Status;
typedef struct _ev_dnd_data_request Ev_Dnd_Data_Request;
enum _eev_stack_detail
{
EV_STACK_ABOVE = Above,
EV_STACK_BELOW = Below,
EV_STACK_TOP_IF = TopIf,
EV_STACK_BOTTOM_IF = BottomIf,
EV_STACK_OPPOSITE = Opposite
};
enum _eev_value_mask
{
EV_VALUE_X = CWX,
EV_VALUE_Y = CWY,
EV_VALUE_W = CWWidth,
EV_VALUE_H = CWHeight,
EV_VALUE_BORDER = CWBorderWidth,
EV_VALUE_SIBLING = CWSibling,
EV_VALUE_STACKING = CWStackMode
};
enum _eev_type
{
EV_MOUSE_MOVE,
EV_MOUSE_DOWN,
EV_MOUSE_UP,
EV_MOUSE_IN,
EV_MOUSE_OUT,
EV_MOUSE_WHEEL,
EV_KEY_DOWN,
EV_KEY_UP,
EV_WINDOW_MAP,
EV_WINDOW_UNMAP,
EV_WINDOW_CREATE,
EV_WINDOW_DESTROY,
EV_WINDOW_CONFIGURE,
EV_WINDOW_CONFIGURE_REQUEST,
EV_WINDOW_MAP_REQUEST,
EV_WINDOW_PROPERTY,
EV_WINDOW_CIRCULATE,
EV_WINDOW_CIRCULATE_REQUEST,
EV_WINDOW_REPARENT,
EV_WINDOW_EXPOSE,
EV_WINDOW_VISIBILITY,
EV_WINDOW_SHAPE,
EV_WINDOW_FOCUS_IN,
EV_WINDOW_FOCUS_OUT,
EV_MESSAGE,
EV_WINDOW_DELETE,
EV_COLORMAP,
EV_DND_DROP_REQUEST,
EV_DND_DROP_END,
EV_DND_DROP_POSITION,
EV_DND_DROP,
EV_DND_DROP_STATUS,
EV_DND_DATA_REQUEST,
EV_CHILD,
EV_USER,
EV_MAX
};
typedef enum _eev_type Eevent_Type;
typedef enum _eev_stack_detail Ev_Stack_Detail;
typedef enum _eev_value_mask Ev_Confgure_Value_Mask;
struct _eev
{
Eevent_Type type;
char ignore;
void *event;
void (*ev_free) (void *evnt);
Eevent *next;
};
struct _ev_fd_handler
{
int fd;
void (*func) (int fd);
Ev_Fd_Handler *next;
};
struct _ev_pid_handler
{
pid_t pid;
void (*func) (pid_t pid);
Ev_Pid_Handler *next;
};
struct _ev_ipc_handler
{
int ipc;
void (*func) (int ipc);
Ev_Ipc_Handler *next;
};
struct _ev_timer
{
char *name;
void (*func) (int val, void *data);
int val;
void *data;
double in;
char just_added;
Ev_Timer *next;
};
struct _ev_key_down
{
Window win, root;
Ev_Key_Modifiers mods;
char *key;
char *compose;
Time time;
};
struct _ev_key_up
{
Window win, root;
Ev_Key_Modifiers mods;
char *key;
char *compose;
Time time;
};
struct _ev_mouse_down
{
Window win, root;
Ev_Key_Modifiers mods;
int button;
int x, y;
int rx, ry;
int double_click, triple_click;
Time time;
};
struct _ev_mouse_up
{
Window win, root;
Ev_Key_Modifiers mods;
int button;
int x, y;
int rx, ry;
Time time;
};
struct _ev_wheel
{
Window win, root;
Ev_Key_Modifiers mods;
int x, y, z;
int rx, ry;
Time time;
};
struct _ev_mouse_move
{
Window win, root;
Ev_Key_Modifiers mods;
int x, y;
int rx, ry;
Time time;
};
struct _ev_window_enter
{
Window win, root;
int x, y;
int rx, ry;
Ev_Key_Modifiers mods;
Time time;
};
struct _ev_window_leave
{