By popular demand, I'm committing the collisionless naming scheme now, even

though E17 itself hasn't been updated. I don't like having to hand-merge
raster's changes anyway. :)


SVN revision: 5498
This commit is contained in:
Term 2001-10-16 15:45:29 +00:00
parent 40d7049b65
commit 7f12c5c062
9 changed files with 4992 additions and 4861 deletions

View File

@ -2,3 +2,4 @@ The Rasterman <raster@rasterman.com>
Tom Gilbert <tom@linuxbrit.co.uk>
Burra <burra@colorado.edu>
Chris Ross <chris@darkrock.co.uk>
Term <term@twistedpath.org>

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -5,25 +5,25 @@
#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);
static void ecore_event_signal_free(void *event);
static void ecore_event_signal_handle_sigchld(int num);
static void ecore_event_signal_handle_sigusr1(int num);
static void ecore_event_signal_handle_sigusr2(int num);
static void ecore_event_signal_handle_sighup(int num);
static void ecore_event_signal_handle_sigpipe(int num);
static void ecore_event_signal_handle_sigsegv(int num);
static void ecore_event_signal_handle_sigfpe(int num);
static void ecore_event_signal_handle_sigill(int num);
static void ecore_event_signal_handle_sigbus(int num);
#ifdef HAVE_SIGSTKFLT
static void e_ev_signal_handle_sigstkflt(int num);
static void ecore_event_signal_handle_sigstkflt(int num);
#endif
#ifdef HAVE_SIGPWR
static void e_ev_signal_handle_sigpwr(int num);
static void ecore_event_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 void ecore_event_signal_handle_sigchld(int num);
static void ecore_event_signal_handle_all(pid_t pid);
static int signal_chld_count = 0;
static int signal_usr1_count = 0;
@ -32,289 +32,289 @@ static int signal_hup_count = 0;
/* freeing stuff */
static void
e_ev_signal_free(void *event)
ecore_event_signal_free(void *event)
{
FREE(event);
FREE(event);
}
/* signal handlers we can return from and add to signal recieved counts */
static void
e_ev_signal_handle_sigchld(int num)
ecore_event_signal_handle_sigchld(int num)
{
signal_chld_count++;
return;
num = 0;
signal_chld_count++;
return;
num = 0;
}
static void
e_ev_signal_handle_sigusr1(int num)
ecore_event_signal_handle_sigusr1(int num)
{
signal_usr1_count++;
return;
num = 0;
signal_usr1_count++;
return;
num = 0;
}
static void
e_ev_signal_handle_sigusr2(int num)
ecore_event_signal_handle_sigusr2(int num)
{
signal_usr2_count++;
return;
num = 0;
signal_usr2_count++;
return;
num = 0;
}
static void
e_ev_signal_handle_sighup(int num)
ecore_event_signal_handle_sighup(int num)
{
signal_hup_count++;
return;
num = 0;
signal_hup_count++;
return;
num = 0;
}
/* signals to ignore */
static void
e_ev_signal_handle_sigpipe(int num)
ecore_event_signal_handle_sigpipe(int num)
{
return;
num = 0;
return;
num = 0;
}
/* signal handlers we cant return from - so handle here */
static void
e_ev_signal_handle_sigsegv(int num)
ecore_event_signal_handle_sigsegv(int num)
{
for (;;)
{
fprintf(stderr, "EEEEEEEEK SEGV - waiting 10 seconds\n");
sleep(10);
}
/* EEK - can't return - bad */
abort();
num = 0;
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)
ecore_event_signal_handle_sigfpe(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
/* EEK - can't return - bad */
abort();
num = 0;
}
static void
e_ev_signal_handle_sigill(int num)
ecore_event_signal_handle_sigill(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
/* EEK - can't return - bad */
abort();
num = 0;
}
static void
e_ev_signal_handle_sigbus(int num)
ecore_event_signal_handle_sigbus(int num)
{
/* EEK - can't return - bad */
abort();
num = 0;
/* EEK - can't return - bad */
abort();
num = 0;
}
#ifdef HAVE_SIGSTKFLT
static void
e_ev_signal_handle_sigstkflt(int num)
ecore_event_signal_handle_sigstkflt(int num)
{
/* EEK - can't return - bad */
abort();
return;
num = 0;
/* EEK - can't return - bad */
abort();
return;
num = 0;
}
#endif
static void
e_ev_signal_handle_sigint(int num)
ecore_event_signal_handle_sigint(int num)
{
exit(0);
return;
num = 0;
exit(0);
return;
num = 0;
}
static void
e_ev_signal_handle_sigquit(int num)
ecore_event_signal_handle_sigquit(int num)
{
exit(0);
return;
num = 0;
exit(0);
return;
num = 0;
}
static void
e_ev_signal_handle_sigabrt(int num)
ecore_event_signal_handle_sigabrt(int num)
{
abort();
return;
num = 0;
abort();
return;
num = 0;
}
static void
e_ev_signal_handle_sigalrm(int num)
ecore_event_signal_handle_sigalrm(int num)
{
return;
num = 0;
return;
num = 0;
}
static void
e_ev_signal_handle_sigterm(int num)
ecore_event_signal_handle_sigterm(int num)
{
exit(0);
return;
num = 0;
exit(0);
return;
num = 0;
}
#ifdef HAVE_SIGPWR
static void
e_ev_signal_handle_sigpwr(int num)
ecore_event_signal_handle_sigpwr(int num)
{
exit(0);
return;
num = 0;
exit(0);
return;
num = 0;
}
#endif
static void
e_ev_signal_handle_all(pid_t pid_pass)
ecore_event_signal_handle_all(pid_t pid_pass)
{
int status;
pid_t pid;
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;
if (signal_chld_count > 0)
{
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
{
if (WIFEXITED(status))
{
Ecore_Event_Child *e;
int code;
code = WEXITSTATUS(status);
e = NEW(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;
code = WEXITSTATUS(status);
e = NEW(Ecore_Event_Child, 1);
e->pid = pid;
e->exit_code = code;
ecore_add_event(ECORE_EVENT_CHILD, e, ecore_event_signal_free);
}
}
signal_chld_count = 0;
}
while (signal_usr1_count > 0)
{
Ecore_Event_User *e;
e = NEW(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(Ecore_Event_User, 1);
e->num = 0;
e->hup = 0;
ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free);
signal_usr1_count--;
}
while (signal_hup_count > 0)
{
Ecore_Event_User *e;
e = NEW(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;
e = NEW(Ecore_Event_User, 1);
e->num = 0;
e->hup = 1;
ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free);
signal_hup_count--;
}
return;
pid_pass = 0;
}
int
e_ev_signal_events_pending(void)
ecore_event_signal_events_pending(void)
{
return (signal_chld_count + signal_usr1_count + signal_hup_count);
return (signal_chld_count + signal_usr1_count + signal_hup_count);
}
void
e_ev_signal_init(void)
ecore_event_signal_init(void)
{
struct sigaction sa;
struct sigaction sa;
e_add_event_pid(0, e_ev_signal_handle_all);
ecore_add_event_pid(0, ecore_event_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 = ecore_event_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 = ecore_event_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 = ecore_event_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 = ecore_event_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 = ecore_event_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_handler = ecore_event_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 = ecore_event_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 = ecore_event_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);
sa.sa_handler = ecore_event_signal_handle_sigbus;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGBUS, &sa, (struct sigaction *)0);
#ifdef HAVE_SIGSTKFLT
sa.sa_handler = e_ev_signal_handle_sigstkflt;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGSTKFLT, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigstkflt;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGSTKFLT, &sa, (struct sigaction *)0);
#endif
sa.sa_handler = e_ev_signal_handle_sigint;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_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 = ecore_event_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 = ecore_event_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 = ecore_event_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);
sa.sa_handler = ecore_event_signal_handle_sigterm;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGTERM, &sa, (struct sigaction *)0);
#ifdef HAVE_SIGPWR
sa.sa_handler = e_ev_signal_handle_sigpwr;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGPWR, &sa, (struct sigaction *)0);
sa.sa_handler = ecore_event_signal_handle_sigpwr;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGPWR, &sa, (struct sigaction *)0);
#endif
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -5,28 +5,28 @@
#include <fcntl.h>
#include <stdio.h>
void e_ipc_init(char *path);
void e_ipc_cleanup(void);
static void e_ipc_connect_handler(int fd);
static void e_ipc_client_handler(int fd);
void e_ipc_get_data(int fd, void *buf);
void e_ipc_send_data(int fd, void *buf, int size);
void e_add_ipc_service(int service, void (*func) (int fd));
void e_del_ipc_service(int service);
void ecore_ipc_init(char *path);
void ecore_ipc_cleanup(void);
static void ecore_ipc_connect_handler(int fd);
static void ecore_ipc_client_handler(int fd);
void ecore_ipc_get_data(int fd, void *buf);
void ecore_ipc_send_data(int fd, void *buf, int size);
void ecore_add_ipc_service(int service, void (*func) (int fd));
void ecore_del_ipc_service(int service);
Ev_Ipc_Service *ipc_services = NULL;
Ecore_Event_Ipc_Service *ipc_services = NULL;
void
e_ev_ipc_init(char *path)
ecore_ev_ipc_init(char *path)
{
int fd, len;
struct sockaddr_un saun;
int fd, len;
struct sockaddr_un saun;
if(path == NULL)
if (path == NULL)
return;
/* a UNIX domain, stream socket */
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
printf("Cannot create ipc socket... disabling ipc.\n");
return;
@ -40,7 +40,7 @@ e_ev_ipc_init(char *path)
unlink(path);
len = sizeof(saun.sun_family) + strlen(saun.sun_path);
if (bind(fd, &saun, len) < 0)
if (bind(fd, (struct sockaddr *)&saun, len) < 0)
{
printf("Cannot bind ipc socket... disabling ipc.\n");
return;
@ -54,126 +54,134 @@ e_ev_ipc_init(char *path)
}
/* add ipc listener */
e_add_event_ipc(fd, e_ipc_connect_handler);
ecore_add_event_ipc(fd, ecore_ipc_connect_handler);
}
void
e_ev_ipc_cleanup(void)
void
ecore_ev_ipc_cleanup(void)
{
Ev_Ipc_Service *ipc_s;
Ecore_Event_Ipc_Service *ipc_s;
/* cleanup services list */
for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next)
{
e_del_ipc_service(ipc_s->service);
}
{
ecore_del_ipc_service(ipc_s->service);
}
}
static void
e_ipc_connect_handler(int fd)
ecore_ipc_connect_handler(int fd)
{
struct sockaddr_un fsaun;
int fromlen, nfd;
struct sockaddr_un fsaun;
int fromlen, nfd;
/* accept ipc connection */
fromlen = sizeof(fsaun);
if ((nfd = accept(fd, &fsaun, &fromlen)) < 0)
if ((nfd = accept(fd, (struct sockaddr *)&fsaun, &fromlen)) < 0)
{
printf("Cannot accept ipc connection... ignoring connection attempt.\n");
return;
}
/* add ipc client */
e_add_event_ipc(nfd, e_ipc_client_handler);
ecore_add_event_ipc(nfd, ecore_ipc_client_handler);
}
static void
e_ipc_client_handler(int fd)
ecore_ipc_client_handler(int fd)
{
int nread, service;
Ev_Ipc_Service *ipc_s;
int nread, service;
Ecore_Event_Ipc_Service *ipc_s;
if ((nread = read(fd, &service, sizeof(service))) == 0)
{
close(fd);
e_del_event_ipc(fd);
ecore_del_event_ipc(fd);
}
else if (nread > 0)
{
/* call the service function */
for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next)
{
if (ipc_s->service == service)
{
ipc_s->func(fd);
break;
}
}
{
if (ipc_s->service == service)
{
ipc_s->func(fd);
break;
}
}
}
else
{
printf("ipc error in read service.\n"); fflush(stdout);
printf("ipc error in read service.\n");
fflush(stdout);
}
}
void
e_ipc_get_data(int fd, void *buf)
ecore_ipc_get_data(int fd, void *buf)
{
int readn, nread;
int readn, nread;
/* read number of bytes being sent */
if ((nread = read(fd, &readn, sizeof(readn))) == -1)
if ((nread = read(fd, &readn, sizeof(readn))) == -1)
{
printf("ipc error in get data.\n"); fflush(stdout);
printf("ipc error in get data.\n");
fflush(stdout);
return;
}
/* get data structure */
if ((nread = read(fd, buf, readn)) == -1)
if ((nread = read(fd, buf, readn)) == -1)
{
printf("ipc error in get data.\n"); fflush(stdout);
printf("ipc error in get data.\n");
fflush(stdout);
return;
}
}
void
e_ipc_send_data(int fd, void *buf, int size)
ecore_ipc_send_data(int fd, void *buf, int size)
{
int n;
int n;
/* send length of data being sent */
if ((n = write(fd, &size, sizeof(size))) == -1)
{
printf("ipc error in send data length.\n"); fflush(stdout);
printf("ipc error in send data length.\n");
fflush(stdout);
return;
}
/* send data */
if ((n = write(fd, buf, size)) == -1)
{
printf("ipc error in send data.\n"); fflush(stdout);
printf("ipc error in send data.\n");
fflush(stdout);
return;
}
}
void
e_add_ipc_service(int service, void (*func) (int fd))
ecore_add_ipc_service(int service, void (*func) (int fd))
{
Ev_Ipc_Service *ipc_s;
Ecore_Event_Ipc_Service *ipc_s;
/* delete the old service */
e_del_ipc_service(service);
/* new service struct */
ipc_s = NEW(Ev_Ipc_Service, 1);
ipc_s->next = ipc_services;
ipc_s->service = service;
ipc_s->func = func;
ipc_services = ipc_s;
/* delete the old service */
ecore_del_ipc_service(service);
/* new service struct */
ipc_s = NEW(Ecore_Event_Ipc_Service, 1);
ipc_s->next = ipc_services;
ipc_s->service = service;
ipc_s->func = func;
ipc_services = ipc_s;
}
void e_del_ipc_service(int service)
void
ecore_del_ipc_service(int service)
{
START_LIST_DEL(Ev_Ipc_Service, ipc_services, (_p->service == service));
FREE(_p);
END_LIST_DEL;
START_LIST_DEL(Ecore_Event_Ipc_Service, ipc_services,
(_p->service == service));
FREE(_p);
END_LIST_DEL;
}

View File

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

File diff suppressed because it is too large Load Diff