forked from enlightenment/efl
Initial event abstraction for e17. More work needed.
SVN revision: 3663
This commit is contained in:
parent
f984e4ab77
commit
8685930a75
|
@ -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
|
||||
{
|
||||
Window win, root;
|
||||
int x, y;
|
||||
int rx, ry;
|
||||
Ev_Key_Modifiers mods;
|
||||
Time time;
|
||||
};
|
||||
|
||||
struct _ev_window_focus_in
|
||||
{
|
||||
Window win, root;
|
||||
Time time;
|
||||
};
|
||||
|
||||
struct _ev_window_focus_out
|
||||
{
|
||||
Window win, root;
|
||||
Time time;
|
||||
};
|
||||
|
||||
struct _ev_window_expose
|
||||
{
|
||||
Window win, root;
|
||||
int x, y, w, h;
|
||||
};
|
||||
|
||||
struct _ev_window_visibility
|
||||
{
|
||||
Window win, root;
|
||||
int fully_obscured;
|
||||
};
|
||||
|
||||
struct _ev_window_create
|
||||
{
|
||||
Window win, root;
|
||||
int override;
|
||||
};
|
||||
|
||||
struct _ev_window_destroy
|
||||
{
|
||||
Window win, root;
|
||||
};
|
||||
|
||||
struct _ev_window_map
|
||||
{
|
||||
Window win, root;
|
||||
};
|
||||
|
||||
struct _ev_window_unmap
|
||||
{
|
||||
Window win, root;
|
||||
};
|
||||
|
||||
struct _ev_window_map_request
|
||||
{
|
||||
Window win, root;
|
||||
};
|
||||
|
||||
struct _ev_window_reparent
|
||||
{
|
||||
Window win, root;
|
||||
Window parent_from, parent;
|
||||
};
|
||||
|
||||
struct _ev_window_configure
|
||||
{
|
||||
Window win, root;
|
||||
int x, y, w, h;
|
||||
int wm_generated;
|
||||
};
|
||||
|
||||
struct _ev_window_configure_request
|
||||
{
|
||||
Window win, root;
|
||||
int x, y, w, h;
|
||||
int border;
|
||||
Window stack_win;
|
||||
Ev_Stack_Detail detail;
|
||||
Ev_Confgure_Value_Mask mask;
|
||||
};
|
||||
|
||||
struct _ev_window_circulate
|
||||
{
|
||||
Window win, root;
|
||||
int lower;
|
||||
};
|
||||
|
||||
struct _ev_window_circulate_request
|
||||
{
|
||||
Window win, root;
|
||||
int lower;
|
||||
};
|
||||
|
||||
struct _ev_window_property
|
||||
{
|
||||
Window win, root;
|
||||
Atom atom;
|
||||
Time time;
|
||||
};
|
||||
|
||||
struct _ev_window_shape
|
||||
{
|
||||
Window win, root;
|
||||
Time time;
|
||||
};
|
||||
|
||||
struct _ev_client_message
|
||||
{
|
||||
Window win;
|
||||
int format;
|
||||
Atom atom;
|
||||
union
|
||||
{
|
||||
char b[20];
|
||||
short s[10];
|
||||
long l[5];
|
||||
}
|
||||
data;
|
||||
};
|
||||
|
||||
struct _ev_colormap
|
||||
{
|
||||
Window win, root;
|
||||
Colormap cmap;
|
||||
int installed;
|
||||
};
|
||||
|
||||
struct _ev_window_delete
|
||||
{
|
||||
Window win, root;
|
||||
};
|
||||
|
||||
struct _ev_dnd_drop_request
|
||||
{
|
||||
Window win, root, source_win;
|
||||
int num_files;
|
||||
char **files;
|
||||
int copy, link, move;
|
||||
};
|
||||
|
||||
struct _ev_dnd_drop_end
|
||||
{
|
||||
Window win, root, source_win;
|
||||
};
|
||||
|
||||
struct _ev_dnd_drop_position
|
||||
{
|
||||
Window win, root, source_win;
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct _ev_dnd_drop
|
||||
{
|
||||
Window win, root, source_win;
|
||||
};
|
||||
|
||||
struct _ev_dnd_drop_status
|
||||
{
|
||||
Window win, root, source_win;
|
||||
int x, y, w, h;
|
||||
int ok;
|
||||
};
|
||||
|
||||
struct _ev_dnd_data_request
|
||||
{
|
||||
Window win, root, source_win;
|
||||
int plain_text;
|
||||
Atom destination_atom;
|
||||
};
|
||||
|
||||
struct _ev_child
|
||||
{
|
||||
pid_t pid;
|
||||
int exit_code;
|
||||
};
|
||||
|
||||
struct _ev_user
|
||||
{
|
||||
int num;
|
||||
int hup;
|
||||
};
|
||||
|
||||
void e_add_event(Eevent_Type type, void *event,
|
||||
void (*ev_free) (void *event));
|
||||
void e_del_event(void *event);
|
||||
void e_del_all_events(void);
|
||||
Eevent *e_get_last_event(void);
|
||||
|
||||
void e_add_event_fd(int fd, void (*func) (int fd));
|
||||
void e_del_event_fd(int fd);
|
||||
void e_add_event_pid(pid_t pid, void (*func) (pid_t pid));
|
||||
void e_del_event_pid(pid_t pid);
|
||||
void e_add_event_ipc(int ipc, void (*func) (int ipc));
|
||||
void e_del_event_ipc(int ipc);
|
||||
|
||||
void e_event_loop(void);
|
||||
|
||||
void e_add_event_timer(char *name, double in,
|
||||
void (*func) (int val, void *data),
|
||||
int val, void *data);
|
||||
void *e_del_event_timer(char *name);
|
||||
|
||||
#endif
|
|
@ -0,0 +1 @@
|
|||
#include "e_mem.h"
|
|
@ -0,0 +1,60 @@
|
|||
#ifndef E_MEM_H
|
||||
#define E_MEM_H 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MEMCPY(src, dst, type, num) memcpy(dst, src, sizeof(type) * (num))
|
||||
|
||||
#if 1
|
||||
#define NEW(dat, num) malloc(sizeof(dat) * (num))
|
||||
#define NEW_PTR(num) malloc(sizeof(void *) * (num))
|
||||
#define FREE(dat) {if (dat) {free(dat); dat = NULL;} else {printf("eek - NULL free\n");sleep(30);}}
|
||||
#define IF_FREE(dat) {if (dat) FREE(dat);}
|
||||
#define REALLOC(dat, type, num) {if (dat) dat = realloc(dat, sizeof(type) * (num)); else dat = malloc(sizeof(type) * (num));}
|
||||
#define REALLOC_PTR(dat, num) {if (dat) dat = realloc(dat, sizeof(void *) * (num)); else dat = malloc(sizeof(void *) * (num));}
|
||||
|
||||
#else
|
||||
static void *
|
||||
_NEW(int size, int num)
|
||||
{
|
||||
void *dat;
|
||||
|
||||
dat = malloc(size * num);
|
||||
printf("NEW(%i) = %p\n", size * num, dat);
|
||||
return dat;
|
||||
}
|
||||
static void *
|
||||
_NEW_PTR(int num)
|
||||
{
|
||||
void *dat;
|
||||
|
||||
dat = malloc(sizeof(void *) * num);
|
||||
printf("NEW(%i) = %p\n", sizeof(void *) * num, dat);
|
||||
|
||||
return dat;
|
||||
}
|
||||
static void
|
||||
_IF_FREE(void *dat)
|
||||
{
|
||||
printf("IF_FREE(%p)\n", dat);
|
||||
if (dat)
|
||||
free(dat);
|
||||
}
|
||||
static void
|
||||
_FREE(void *dat)
|
||||
{
|
||||
printf("FREE(%p)\n", dat);
|
||||
free(dat);
|
||||
}
|
||||
#define NEW(dat, num) _NEW(sizeof(dat), (num))
|
||||
#define NEW_PTR(num) _NEW(sizeof(void *), (num))
|
||||
#define IF_FREE(dat) {_IF_FREE(dat);}
|
||||
#define FREE(dat) {_FREE(dat);}
|
||||
|
||||
#define REALLOC(dat, type, num) {dat = realloc(dat, sizeof(type) * (num)); printf("REALLOC(%i) = %p\n", sizeof(type) * (num), dat);}
|
||||
#define REALLOC_PTR(dat, num) {dat = realloc(dat, sizeof(void *) * (num)); printf("REALLOC_PTR(%i) = %p\n", sizeof(void *) * (num), dat);}
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,151 @@
|
|||
#include "e_str.h"
|
||||
#include "e_mem.h"
|
||||
|
||||
/* string manipulation conveience calls */
|
||||
|
||||
void
|
||||
e_string_free_list(char **slist, int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
FREE(slist[i]);
|
||||
FREE(slist);
|
||||
}
|
||||
|
||||
char *
|
||||
e_string_dup(char *str)
|
||||
{
|
||||
if (!str)
|
||||
return NULL;
|
||||
return strdup(str);
|
||||
}
|
||||
|
||||
int
|
||||
e_string_cmp(char *s1, char *s2)
|
||||
{
|
||||
if ((!s1) || (!s2))
|
||||
return 0;
|
||||
if (!strcmp(s1, s2))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
e_string_case_cmp(char *s1, char *s2)
|
||||
{
|
||||
if ((!s1) || (!s2))
|
||||
return 0;
|
||||
if (!strcasecmp(s1, s2))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
e_string_length(char *str)
|
||||
{
|
||||
return strlen(str);
|
||||
}
|
||||
|
||||
void
|
||||
e_string_clear(char *str)
|
||||
{
|
||||
str[0] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
e_string_cat(char *str, char *cat)
|
||||
{
|
||||
strcat(str, cat);
|
||||
}
|
||||
|
||||
void
|
||||
e_string_cat_n(char *str, char *cat, int start, int len)
|
||||
{
|
||||
strncat(str, &(cat[start]), len);
|
||||
}
|
||||
|
||||
char *
|
||||
e_string_escape(char *str)
|
||||
{
|
||||
char buf[8192];
|
||||
int i, j, len;
|
||||
|
||||
e_string_clear(buf);
|
||||
len = e_string_length(str);
|
||||
for (i = 0, j = 0; i < len; i++)
|
||||
{
|
||||
switch (str[i])
|
||||
{
|
||||
case ' ':
|
||||
case '"':
|
||||
case '\'':
|
||||
case '\\':
|
||||
case '(':
|
||||
case ')':
|
||||
case '[':
|
||||
case ']':
|
||||
case '$':
|
||||
case '`':
|
||||
case '~':
|
||||
case '!':
|
||||
case '#':
|
||||
case '&':
|
||||
case '*':
|
||||
case '?':
|
||||
case '|':
|
||||
case ';':
|
||||
case '<':
|
||||
case '>':
|
||||
buf[j++] = '\\';
|
||||
buf[j++] = str[i];
|
||||
break;
|
||||
default:
|
||||
buf[j++] = str[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
buf[j] = 0;
|
||||
return e_string_dup(buf);
|
||||
}
|
||||
|
||||
char *
|
||||
e_string_build(char *format, char **rep_list, int rep_num)
|
||||
{
|
||||
char buf[16384], *s;
|
||||
int i;
|
||||
|
||||
e_string_clear(buf);
|
||||
s = format;
|
||||
i = 0;
|
||||
while (*s)
|
||||
{
|
||||
if (s[0] == '%')
|
||||
{
|
||||
if (s[1] == '%')
|
||||
e_string_cat(buf, "%");
|
||||
else
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < rep_num; j += 2)
|
||||
{
|
||||
if (s[1] == rep_list[j][0])
|
||||
{
|
||||
char *ss;
|
||||
|
||||
ss = e_string_escape(rep_list[j + 1]);
|
||||
e_string_cat(buf, ss);
|
||||
FREE(ss);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
s++;
|
||||
}
|
||||
else
|
||||
strncat(buf, s, 1);
|
||||
s++;
|
||||
}
|
||||
return e_string_dup(buf);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef E_STR_H
|
||||
#define E_STR_H 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void e_string_free_list(char **slist, int num);
|
||||
char *e_string_dup(char *str);
|
||||
int e_string_cmp(char *s1, char *s2);
|
||||
int e_string_case_cmp(char *s1, char *s2);
|
||||
int e_string_length(char *str);
|
||||
void e_string_clear(char *str);
|
||||
void e_string_cat(char *str, char *cat);
|
||||
void e_string_cat_n(char *str, char *cat, int start, int len);
|
||||
char *e_string_escape(char *str);
|
||||
char *e_string_build(char *format, char **rep_list, int rep_num);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,164 @@
|
|||
#include "e_util.h"
|
||||
#include "e_mem.h"
|
||||
#include "e_str.h"
|
||||
|
||||
static void sort_alpha_internal(char **a, int l, int r);
|
||||
|
||||
double
|
||||
e_get_time(void)
|
||||
{
|
||||
struct timeval timev;
|
||||
|
||||
gettimeofday(&timev, NULL);
|
||||
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
|
||||
}
|
||||
|
||||
pid_t
|
||||
e_run(char *exe)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
pid = fork();
|
||||
if (pid)
|
||||
return pid;
|
||||
setsid();
|
||||
execl("/bin/sh", "/bin/sh", "-c", exe, NULL);
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pid_t
|
||||
e_run_in_dir(char *exe, char *dir)
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
pid = fork();
|
||||
if (pid)
|
||||
return pid;
|
||||
chdir(dir);
|
||||
setsid();
|
||||
execl("/bin/sh", "/bin/sh", "-c", exe, NULL);
|
||||
exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
e_set_env(char *variable, char *content)
|
||||
{
|
||||
char env[4096];
|
||||
|
||||
sprintf(env, "%s=%s", variable, content);
|
||||
putenv(env);
|
||||
}
|
||||
|
||||
uid_t
|
||||
e_user_id(void)
|
||||
{
|
||||
static uid_t uid = 0xffffffff;
|
||||
|
||||
if (uid != 0xffffffff)
|
||||
return uid;
|
||||
uid = getuid();
|
||||
return uid;
|
||||
}
|
||||
|
||||
gid_t
|
||||
e_group_id(void)
|
||||
{
|
||||
static gid_t gid = 0xffffffff;
|
||||
|
||||
if (gid != 0xffffffff)
|
||||
return gid;
|
||||
gid = getgid();
|
||||
return gid;
|
||||
}
|
||||
|
||||
static void
|
||||
sort_alpha_internal(char **a, int l, int r)
|
||||
{
|
||||
int i, j, m;
|
||||
char *v, *t;
|
||||
|
||||
if (r > l)
|
||||
{
|
||||
m = ((r + l) >> 1) + 1;
|
||||
if (strcmp(a[l], a[r]) > 0)
|
||||
{
|
||||
t = a[l];
|
||||
a[l] = a[r];
|
||||
a[r] = t;
|
||||
}
|
||||
if (strcmp(a[l], a[m]) > 0)
|
||||
{
|
||||
t = a[l];
|
||||
a[l] = a[m];
|
||||
a[m] = t;
|
||||
}
|
||||
if (strcmp(a[r], a[m]) > 0)
|
||||
{
|
||||
t = a[r];
|
||||
a[r] = a[m];
|
||||
a[m] = t;
|
||||
}
|
||||
v = a[r];
|
||||
i = l - 1;
|
||||
j = r;
|
||||
for (;;)
|
||||
{
|
||||
while (strcmp(a[++i], v) < 0);
|
||||
while (strcmp(a[--j], v) > 0);
|
||||
if (i >= j)
|
||||
break;
|
||||
t = a[i];
|
||||
a[i] = a[j];
|
||||
a[j] = t;
|
||||
}
|
||||
t = a[i];
|
||||
a[i] = a[r];
|
||||
a[r] = t;
|
||||
sort_alpha_internal(a, l, i - 1);
|
||||
sort_alpha_internal(a, i + 1, r);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sort_alpha(char **list, int num)
|
||||
{
|
||||
sort_alpha_internal(list, 0, num - 1);
|
||||
}
|
||||
|
||||
char *
|
||||
e_home_dir(void)
|
||||
{
|
||||
char *home;
|
||||
|
||||
home = getenv("HOME");
|
||||
if (!home)
|
||||
home = getenv("TMPDIR");
|
||||
if (!home)
|
||||
home = "/tmp";
|
||||
return home;
|
||||
}
|
||||
|
||||
const char *
|
||||
e_get_basename(const char *s)
|
||||
{
|
||||
const char *b;
|
||||
|
||||
b = strrchr(s, '/');
|
||||
return ((b) ? (++b) : (s));
|
||||
}
|
||||
|
||||
void
|
||||
spawn_info_window(char *path)
|
||||
{
|
||||
|
||||
char runline[8192];
|
||||
char *realline;
|
||||
|
||||
realline = e_string_escape(path);
|
||||
sprintf(runline, "efileinfo %s", realline);
|
||||
e_run(runline);
|
||||
IF_FREE(realline);
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef E_UTIL_H
|
||||
#define E_UTIL_H 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef EFM_DEBUG
|
||||
# define D(x) do {printf(__FILE__ ":%d: ", __LINE__); printf x; fflush(stdout);} while (0)
|
||||
#else
|
||||
# define D(x) ((void) 0)
|
||||
#endif
|
||||
|
||||
#define XY_IN_RECT(x, y, rx, ry, rw, rh) \
|
||||
(((x) >= (rx)) && ((y) >= (ry)) && ((x) < ((rx) + (rw))) && ((y) < ((ry) + (rh))))
|
||||
#define CLIP(x, y, w, h, xx, yy, ww, hh) \
|
||||
if (x < (xx)) {w += (x - (xx)); x = (xx);} \
|
||||
if (y < (yy)) {h += (y - (yy)); y = (yy);} \
|
||||
if ((x + w) > ((xx) + (ww))) {w = (ww) - x;} \
|
||||
if ((y + h) > ((yy) + (hh))) {h = (hh) - y;}
|
||||
#define BOUND_RECTS(cx, cy, cw, ch, x, y, w, h, d) \
|
||||
if (d) { \
|
||||
if ((x) < cx) {cw += (cx - (x)); cx = x;} \
|
||||
if ((y) < cy) {ch += (cy - (y)); cy = y;} \
|
||||
if (((x) + (w)) > (cx + cw)) cw += (((x) + (w)) - (cx + cw)); \
|
||||
if (((y) + (h)) > (cy + ch)) ch += (((y) + (h)) - (cy + ch)); } \
|
||||
else { cx = x; cy = y; cw = w; ch = h; (d) = 1; }
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define SPANS_COMMON(x1, w1, x2, w2) \
|
||||
(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
|
||||
#define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \
|
||||
((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh))))
|
||||
#define RECT_INSIDE(x, y, w, h, xx, yy, ww, hh) \
|
||||
(((xx) >= (x)) && (((xx) + (ww)) <= ((x) + (w))) && \
|
||||
((yy) >= (y)) && (((yy) + (hh)) <= ((y) + (h))))
|
||||
#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 IC(name) e_path_find(path_icons, name)
|
||||
|
||||
double e_get_time(void);
|
||||
pid_t e_run(char *exe);
|
||||
pid_t e_run_in_dir(char *exe, char *dir);
|
||||
void e_set_env(char *variable, char *content);
|
||||
uid_t e_user_id(void);
|
||||
gid_t e_group_id(void);
|
||||
void sort_alpha(char **list, int num);
|
||||
char *e_home_dir(void);
|
||||
const char *e_get_basename(const char *);
|
||||
void spawn_info_window(char *path);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,230 @@
|
|||
#ifndef E_X_H
|
||||
#define E_X_H 1
|
||||
|
||||
#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>
|
||||
|
||||
#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
|
||||
|
||||
typedef struct _e_xid E_XID;
|
||||
typedef struct _e_keygrab E_KeyGrab;
|
||||
|
||||
enum _ev_modifiers
|
||||
{
|
||||
EV_KEY_MODIFIER_NONE = 0,
|
||||
EV_KEY_MODIFIER_SHIFT = (1 << 0),
|
||||
EV_KEY_MODIFIER_CTRL = (1 << 1),
|
||||
EV_KEY_MODIFIER_ALT = (1 << 2),
|
||||
EV_KEY_MODIFIER_WIN = (1 << 3)
|
||||
};
|
||||
|
||||
typedef enum _ev_modifiers Ev_Key_Modifiers;
|
||||
|
||||
struct _e_xid
|
||||
{
|
||||
Window win;
|
||||
Window parent;
|
||||
Window root;
|
||||
int children_num;
|
||||
Window *children;
|
||||
int x, y, w, h;
|
||||
int mapped;
|
||||
int mouse_in;
|
||||
int depth;
|
||||
};
|
||||
|
||||
void e_del_child(Window win, Window child);
|
||||
void e_add_child(Window win, Window child);
|
||||
void e_raise_child(Window win, Window child);
|
||||
void e_lower_child(Window win, Window child);
|
||||
E_XID *e_add_xid(Window win, int x, int y, int w, int h, int depth,
|
||||
Window parent);
|
||||
E_XID *e_validate_xid(Window win);
|
||||
void e_unvalidate_xid(Window win);
|
||||
void e_sync(void);
|
||||
void e_flush(void);
|
||||
Window e_window_new(Window parent, int x, int y, int w, int h);
|
||||
Window e_window_override_new(Window parent, int x, int y, int w,
|
||||
|
||||
int h);
|
||||
Window e_window_input_new(Window parent, int x, int y, int w,
|
||||
|
||||
int h);
|
||||
void e_window_show(Window win);
|
||||
void e_window_hide(Window win);
|
||||
Pixmap e_pixmap_new(Window win, int w, int h, int dep);
|
||||
void e_pixmap_free(Pixmap pmap);
|
||||
void e_window_set_background_pixmap(Window win, Pixmap pmap);
|
||||
void e_window_set_shape_mask(Window win, Pixmap mask);
|
||||
void e_window_clear(Window win);
|
||||
void e_window_clear_area(Window win, int x, int y, int w, int h);
|
||||
void e_pointer_xy(Window win, int *x, int *y);
|
||||
void e_pointer_xy_set(int x, int y);
|
||||
void e_pointer_xy_get(int *x, int *y);
|
||||
void e_window_set_events(Window win, long mask);
|
||||
void e_window_remove_events(Window win, long mask);
|
||||
void e_window_add_events(Window win, long mask);
|
||||
void e_window_move(Window win, int x, int y);
|
||||
void e_window_resize(Window win, int w, int h);
|
||||
void e_window_move_resize(Window win, int x, int y, int w,
|
||||
|
||||
int h);
|
||||
int e_x_get_fd(void);
|
||||
void e_display_init(char *display);
|
||||
int e_events_pending(void);
|
||||
void e_get_next_event(XEvent * event);
|
||||
int e_event_shape_get_id(void);
|
||||
KeySym e_key_get_keysym_from_keycode(KeyCode keycode);
|
||||
char *e_key_get_string_from_keycode(KeyCode keycode);
|
||||
void e_event_allow(int mode, Time t);
|
||||
int e_lock_mask_scroll_get(void);
|
||||
int e_lock_mask_num_get(void);
|
||||
int e_lock_mask_caps_get(void);
|
||||
int e_mod_mask_shift_get(void);
|
||||
int e_mod_mask_ctrl_get(void);
|
||||
int e_mod_mask_alt_get(void);
|
||||
int e_mod_mask_win_get(void);
|
||||
int e_lock_mask_get(void);
|
||||
int e_modifier_mask_get(void);
|
||||
Window e_get_key_grab_win(void);
|
||||
void e_key_grab(char *key, Ev_Key_Modifiers mods, int anymod,
|
||||
|
||||
int sync);
|
||||
void e_key_ungrab(char *key, Ev_Key_Modifiers mods, int anymod);
|
||||
KeyCode e_key_get_keycode(char *key);
|
||||
void e_window_destroy(Window win);
|
||||
void e_window_reparent(Window win, Window parent, int x, int y);
|
||||
void e_window_raise(Window win);
|
||||
void e_window_lower(Window win);
|
||||
void e_window_get_geometry(Window win, int *x, int *y, int *w,
|
||||
|
||||
int *h);
|
||||
int e_window_get_depth(Window win);
|
||||
int e_window_exists(Window win);
|
||||
Window e_window_get_parent(Window win);
|
||||
Window *e_window_get_children(Window win, int *num);
|
||||
int e_window_mouse_in(Window win);
|
||||
void e_window_mouse_set_in(Window win, int in);
|
||||
Display *e_display_get(void);
|
||||
Window e_window_get_root(Window win);
|
||||
void e_lock_scroll_set(int onoff);
|
||||
int e_lock_scroll_get(void);
|
||||
void e_lock_num_set(int onoff);
|
||||
int e_lock_num_get(void);
|
||||
void e_lock_caps_set(int onoff);
|
||||
int e_lock_caps_get(void);
|
||||
void e_mod_shift_set(int onoff);
|
||||
int e_mod_shift_get(void);
|
||||
void e_mod_ctrl_set(int onoff);
|
||||
int e_mod_ctrl_get(void);
|
||||
void e_mod_alt_set(int onoff);
|
||||
int e_mod_alt_get(void);
|
||||
void e_mod_win_set(int onoff);
|
||||
int e_mod_win_get(void);
|
||||
void e_focus_window_set(Window win);
|
||||
Window e_focus_window_get(void);
|
||||
void e_focus_to_window(Window win);
|
||||
Atom e_atom_get(char *name);
|
||||
void e_window_set_delete_inform(Window win);
|
||||
void e_window_property_set(Window win, Atom type, Atom format,
|
||||
int size, void *data, int number);
|
||||
void *e_window_property_get(Window win, Atom type, Atom format,
|
||||
|
||||
int *size);
|
||||
void e_window_dnd_advertise(Window win);
|
||||
void e_grab(void);
|
||||
void e_ungrab(void);
|
||||
void e_window_ignore(Window win);
|
||||
void e_window_no_ignore(Window win);
|
||||
int e_window_is_ignored(Window win);
|
||||
Window e_window_get_at_xy(int x, int y);
|
||||
int e_window_dnd_capable(Window win);
|
||||
void e_window_dnd_handle_motion(Window source_win, int x, int y,
|
||||
|
||||
int dragging);
|
||||
int e_dnd_selection_convert(Window win, Window req, Atom type);
|
||||
void *e_dnd_selection_get(Window win, Window req, Atom type,
|
||||
|
||||
int *size);
|
||||
void e_window_dnd_ok(int ok);
|
||||
void e_window_dnd_finished(void);
|
||||
void e_window_dnd_send_status_ok(Window source_win, Window win,
|
||||
int x, int y, int w, int h);
|
||||
void e_window_dnd_send_finished(Window source_win, Window win);
|
||||
void e_dnd_set_data(Window win);
|
||||
void e_dnd_send_data(Window win, Window source_win, void *data,
|
||||
int size, Atom dest_atom, int plain_text);
|
||||
void e_window_set_title(Window win, char *title);
|
||||
void e_window_set_name_class(Window win, char *name,
|
||||
|
||||
char *class);
|
||||
void e_window_set_min_size(Window win, int w, int h);
|
||||
void e_window_set_max_size(Window win, int w, int h);
|
||||
void e_window_set_xy_hints(Window win, int x, int y);
|
||||
void e_window_get_frame_size(Window win, int *l, int *r, int *t,
|
||||
|
||||
int *b);
|
||||
int e_window_save_under(Window win);
|
||||
GC e_gc_new(Drawable d);
|
||||
void e_gc_free(GC gc);
|
||||
void e_gc_set_fg(GC gc, int val);
|
||||
void e_fill_rectangle(Drawable d, GC gc, int x, int y, int w,
|
||||
|
||||
int h);
|
||||
void e_draw_rectangle(Drawable d, GC gc, int x, int y, int w,
|
||||
|
||||
int h);
|
||||
void e_draw_line(Drawable d, GC gc, int x1, int y1, int x2,
|
||||
|
||||
int y2);
|
||||
void e_window_hint_set_layer(Window win, int layer);
|
||||
void e_window_hint_set_sticky(Window win, int sticky);
|
||||
void e_window_hint_set_borderless(Window win);
|
||||
void e_grab_mouse(Window win, int confine, Cursor cursor);
|
||||
void e_ungrab_mouse(void);
|
||||
Window e_grab_window_get(void);
|
||||
void e_dnd_set_mode_copy(void);
|
||||
void e_dnd_set_mode_link(void);
|
||||
void e_dnd_set_mode_move(void);
|
||||
void e_dnd_set_mode_ask(void);
|
||||
void e_dnd_own_selection(Window win);
|
||||
void e_dnd_send_drop(Window win, Window source_win);
|
||||
void e_window_gravity_reset(Window win);
|
||||
void e_pointer_warp_by(int dx, int dy);
|
||||
void e_pointer_warp_to(int x, int y);
|
||||
void e_gc_set_include_inferiors(GC gc);
|
||||
void e_area_copy(Drawable src, Drawable dest, GC gc,
|
||||
int sx, int sy, int sw, int sh, int dx, int dy);
|
||||
Window e_window_root(void);
|
||||
void e_window_get_virtual_area(Window win, int *area_x,
|
||||
|
||||
int *area_y);
|
||||
void e_get_virtual_area(int *area_x, int *area_y);
|
||||
|
||||
#define E_ATOM(atom, name) \
|
||||
if (!atom) atom = e_atom_get(name);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue