forked from enlightenment/efl
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:
parent
40d7049b65
commit
7f12c5c062
|
@ -2,3 +2,4 @@ The Rasterman <raster@rasterman.com>
|
||||||
Tom Gilbert <tom@linuxbrit.co.uk>
|
Tom Gilbert <tom@linuxbrit.co.uk>
|
||||||
Burra <burra@colorado.edu>
|
Burra <burra@colorado.edu>
|
||||||
Chris Ross <chris@darkrock.co.uk>
|
Chris Ross <chris@darkrock.co.uk>
|
||||||
|
Term <term@twistedpath.org>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,130 +1,132 @@
|
||||||
#include "Ecore.h"
|
#include "Ecore.h"
|
||||||
|
|
||||||
typedef struct _ev_handler Ev_Handler;
|
typedef struct _ecore_event_handler Ecore_Event_Handler;
|
||||||
typedef struct _ev_idle_handler Ev_Idle_Handler;
|
typedef struct _ecore_event_idle_handler Ecore_Event_Idle_Handler;
|
||||||
|
|
||||||
struct _ev_handler
|
struct _ecore_event_handler
|
||||||
{
|
{
|
||||||
void (*func) (Eevent * ev);
|
void (*func) (Ecore_Event * ev);
|
||||||
Ev_Handler *next;
|
Ecore_Event_Handler *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ev_idle_handler
|
struct _ecore_event_idle_handler
|
||||||
{
|
{
|
||||||
void (*func) (void *data);
|
void (*func) (void *data);
|
||||||
void *data;
|
void *data;
|
||||||
Ev_Idle_Handler *next;
|
Ecore_Event_Idle_Handler *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Ev_Handler *handler[EV_MAX];
|
static Ecore_Event_Handler *handler[ECORE_EVENT_MAX];
|
||||||
static Ev_Idle_Handler *idle_handlers = NULL;
|
static Ecore_Event_Idle_Handler *idle_handlers = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
e_event_filter(Eevent * ev)
|
ecore_event_filter(Ecore_Event * ev)
|
||||||
{
|
{
|
||||||
Eevent *evp;
|
Ecore_Event *evp;
|
||||||
int motion_events = 0;
|
int motion_events = 0;
|
||||||
int dnd_pos_events = 0;
|
int dnd_pos_events = 0;
|
||||||
int dnd_status_events = 0;
|
int dnd_status_events = 0;
|
||||||
|
|
||||||
/* count events to only use last events of some types */
|
/* count events to only use last events of some types */
|
||||||
for (evp = ev; evp; evp = evp->next)
|
for (evp = ev; evp; evp = evp->next)
|
||||||
{
|
{
|
||||||
if (evp->type == EV_MOUSE_MOVE)
|
if (evp->type == ECORE_EVENT_MOUSE_MOVE)
|
||||||
motion_events++;
|
motion_events++;
|
||||||
if (evp->type == EV_DND_DROP_POSITION)
|
if (evp->type == ECORE_EVENT_DND_DROP_POSITION)
|
||||||
dnd_pos_events++;
|
dnd_pos_events++;
|
||||||
if (evp->type == EV_DND_DROP_STATUS)
|
if (evp->type == ECORE_EVENT_DND_DROP_STATUS)
|
||||||
dnd_status_events++;
|
dnd_status_events++;
|
||||||
}
|
}
|
||||||
for (evp = ev; evp; evp = evp->next)
|
for (evp = ev; evp; evp = evp->next)
|
||||||
{
|
{
|
||||||
if (evp->type == EV_MOUSE_MOVE)
|
if (evp->type == ECORE_EVENT_MOUSE_MOVE)
|
||||||
{
|
{
|
||||||
if (motion_events > 1)
|
if (motion_events > 1)
|
||||||
{
|
{
|
||||||
evp->ignore = 1;
|
evp->ignore = 1;
|
||||||
motion_events--;
|
motion_events--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (evp->type == EV_DND_DROP_POSITION)
|
else if (evp->type == ECORE_EVENT_DND_DROP_POSITION)
|
||||||
{
|
{
|
||||||
if (dnd_pos_events > 1)
|
if (dnd_pos_events > 1)
|
||||||
{
|
{
|
||||||
evp->ignore = 1;
|
evp->ignore = 1;
|
||||||
dnd_pos_events--;
|
dnd_pos_events--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (evp->type == EV_DND_DROP_STATUS)
|
else if (evp->type == ECORE_EVENT_DND_DROP_STATUS)
|
||||||
{
|
{
|
||||||
if (dnd_status_events > 1)
|
if (dnd_status_events > 1)
|
||||||
{
|
{
|
||||||
evp->ignore = 1;
|
evp->ignore = 1;
|
||||||
dnd_status_events--;
|
dnd_status_events--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
for (evp = ev; evp; evp = evp->next)
|
||||||
{
|
{
|
||||||
Ev_Handler *h;
|
Ecore_Event_Handler *h;
|
||||||
|
|
||||||
if (!evp->ignore)
|
if (!evp->ignore)
|
||||||
{
|
{
|
||||||
for (h = handler[evp->type]; h; h = h->next)
|
for (h = handler[evp->type]; h; h = h->next)
|
||||||
{
|
{
|
||||||
if (h->func) h->func(evp);
|
if (h->func)
|
||||||
}
|
h->func(evp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
for (h = idle_handlers; h; h = h->next)
|
||||||
h->func(h->data);
|
h->func(h->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int __quit_ev_loop;
|
extern int __quit_ev_loop;
|
||||||
|
|
||||||
void
|
void
|
||||||
e_event_filter_init(void)
|
ecore_event_filter_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
__quit_ev_loop = 0;
|
__quit_ev_loop = 0;
|
||||||
for (i = 0; i < EV_MAX; i++)
|
for (i = 0; i < ECORE_EVENT_MAX; i++)
|
||||||
handler[i] = NULL;
|
handler[i] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 = NEW(Ecore_Event_Handler, 1);
|
||||||
h->func = func;
|
h->func = func;
|
||||||
h->next = handler[type];
|
h->next = handler[type];
|
||||||
handler[type] = h;
|
handler[type] = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 = NEW(Ecore_Event_Idle_Handler, 1);
|
||||||
h->func = func;
|
h->func = func;
|
||||||
h->data = data;
|
h->data = data;
|
||||||
h->next = idle_handlers;
|
h->next = idle_handlers;
|
||||||
idle_handlers = h;
|
idle_handlers = h;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,25 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
static void e_ev_signal_free(void *event);
|
static void ecore_event_signal_free(void *event);
|
||||||
static void e_ev_signal_handle_sigchld(int num);
|
static void ecore_event_signal_handle_sigchld(int num);
|
||||||
static void e_ev_signal_handle_sigusr1(int num);
|
static void ecore_event_signal_handle_sigusr1(int num);
|
||||||
static void e_ev_signal_handle_sigusr2(int num);
|
static void ecore_event_signal_handle_sigusr2(int num);
|
||||||
static void e_ev_signal_handle_sighup(int num);
|
static void ecore_event_signal_handle_sighup(int num);
|
||||||
static void e_ev_signal_handle_sigpipe(int num);
|
static void ecore_event_signal_handle_sigpipe(int num);
|
||||||
static void e_ev_signal_handle_sigsegv(int num);
|
static void ecore_event_signal_handle_sigsegv(int num);
|
||||||
static void e_ev_signal_handle_sigfpe(int num);
|
static void ecore_event_signal_handle_sigfpe(int num);
|
||||||
static void e_ev_signal_handle_sigill(int num);
|
static void ecore_event_signal_handle_sigill(int num);
|
||||||
static void e_ev_signal_handle_sigbus(int num);
|
static void ecore_event_signal_handle_sigbus(int num);
|
||||||
|
|
||||||
#ifdef HAVE_SIGSTKFLT
|
#ifdef HAVE_SIGSTKFLT
|
||||||
static void e_ev_signal_handle_sigstkflt(int num);
|
static void ecore_event_signal_handle_sigstkflt(int num);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SIGPWR
|
#ifdef HAVE_SIGPWR
|
||||||
static void e_ev_signal_handle_sigpwr(int num);
|
static void ecore_event_signal_handle_sigpwr(int num);
|
||||||
#endif
|
#endif
|
||||||
static void e_ev_signal_handle_sigchld(int num);
|
static void ecore_event_signal_handle_sigchld(int num);
|
||||||
static void e_ev_signal_handle_all(pid_t pid);
|
static void ecore_event_signal_handle_all(pid_t pid);
|
||||||
|
|
||||||
static int signal_chld_count = 0;
|
static int signal_chld_count = 0;
|
||||||
static int signal_usr1_count = 0;
|
static int signal_usr1_count = 0;
|
||||||
|
@ -32,289 +32,289 @@ static int signal_hup_count = 0;
|
||||||
|
|
||||||
/* freeing stuff */
|
/* freeing stuff */
|
||||||
static void
|
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 */
|
/* signal handlers we can return from and add to signal recieved counts */
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigchld(int num)
|
ecore_event_signal_handle_sigchld(int num)
|
||||||
{
|
{
|
||||||
signal_chld_count++;
|
signal_chld_count++;
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigusr1(int num)
|
ecore_event_signal_handle_sigusr1(int num)
|
||||||
{
|
{
|
||||||
signal_usr1_count++;
|
signal_usr1_count++;
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigusr2(int num)
|
ecore_event_signal_handle_sigusr2(int num)
|
||||||
{
|
{
|
||||||
signal_usr2_count++;
|
signal_usr2_count++;
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sighup(int num)
|
ecore_event_signal_handle_sighup(int num)
|
||||||
{
|
{
|
||||||
signal_hup_count++;
|
signal_hup_count++;
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* signals to ignore */
|
/* signals to ignore */
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigpipe(int num)
|
ecore_event_signal_handle_sigpipe(int num)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* signal handlers we cant return from - so handle here */
|
/* signal handlers we cant return from - so handle here */
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigsegv(int num)
|
ecore_event_signal_handle_sigsegv(int num)
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "EEEEEEEEK SEGV - waiting 10 seconds\n");
|
fprintf(stderr, "EEEEEEEEK SEGV - waiting 10 seconds\n");
|
||||||
sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
/* EEK - can't return - bad */
|
/* EEK - can't return - bad */
|
||||||
abort();
|
abort();
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigfpe(int num)
|
ecore_event_signal_handle_sigfpe(int num)
|
||||||
{
|
{
|
||||||
/* EEK - can't return - bad */
|
/* EEK - can't return - bad */
|
||||||
abort();
|
abort();
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigill(int num)
|
ecore_event_signal_handle_sigill(int num)
|
||||||
{
|
{
|
||||||
/* EEK - can't return - bad */
|
/* EEK - can't return - bad */
|
||||||
abort();
|
abort();
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigbus(int num)
|
ecore_event_signal_handle_sigbus(int num)
|
||||||
{
|
{
|
||||||
/* EEK - can't return - bad */
|
/* EEK - can't return - bad */
|
||||||
abort();
|
abort();
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SIGSTKFLT
|
#ifdef HAVE_SIGSTKFLT
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigstkflt(int num)
|
ecore_event_signal_handle_sigstkflt(int num)
|
||||||
{
|
{
|
||||||
/* EEK - can't return - bad */
|
/* EEK - can't return - bad */
|
||||||
abort();
|
abort();
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigint(int num)
|
ecore_event_signal_handle_sigint(int num)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigquit(int num)
|
ecore_event_signal_handle_sigquit(int num)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigabrt(int num)
|
ecore_event_signal_handle_sigabrt(int num)
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigalrm(int num)
|
ecore_event_signal_handle_sigalrm(int num)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigterm(int num)
|
ecore_event_signal_handle_sigterm(int num)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SIGPWR
|
#ifdef HAVE_SIGPWR
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_sigpwr(int num)
|
ecore_event_signal_handle_sigpwr(int num)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
return;
|
return;
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ev_signal_handle_all(pid_t pid_pass)
|
ecore_event_signal_handle_all(pid_t pid_pass)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if (signal_chld_count > 0)
|
if (signal_chld_count > 0)
|
||||||
{
|
{
|
||||||
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
|
while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
|
||||||
{
|
{
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
{
|
{
|
||||||
Ev_Child *e;
|
Ecore_Event_Child *e;
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
code = WEXITSTATUS(status);
|
code = WEXITSTATUS(status);
|
||||||
e = NEW(Ev_Child, 1);
|
e = NEW(Ecore_Event_Child, 1);
|
||||||
e->pid = pid;
|
e->pid = pid;
|
||||||
e->exit_code = code;
|
e->exit_code = code;
|
||||||
e_add_event(EV_CHILD, e, e_ev_signal_free);
|
ecore_add_event(ECORE_EVENT_CHILD, e, ecore_event_signal_free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
signal_chld_count = 0;
|
signal_chld_count = 0;
|
||||||
}
|
}
|
||||||
while (signal_usr1_count > 0)
|
while (signal_usr1_count > 0)
|
||||||
{
|
{
|
||||||
Ev_User *e;
|
Ecore_Event_User *e;
|
||||||
|
|
||||||
e = NEW(Ev_User, 1);
|
e = NEW(Ecore_Event_User, 1);
|
||||||
e->num = 0;
|
e->num = 0;
|
||||||
e->hup = 0;
|
e->hup = 0;
|
||||||
e_add_event(EV_USER, e, e_ev_signal_free);
|
ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free);
|
||||||
signal_usr1_count--;
|
signal_usr1_count--;
|
||||||
}
|
}
|
||||||
while (signal_hup_count > 0)
|
while (signal_hup_count > 0)
|
||||||
{
|
{
|
||||||
Ev_User *e;
|
Ecore_Event_User *e;
|
||||||
|
|
||||||
e = NEW(Ev_User, 1);
|
e = NEW(Ecore_Event_User, 1);
|
||||||
e->num = 0;
|
e->num = 0;
|
||||||
e->hup = 1;
|
e->hup = 1;
|
||||||
e_add_event(EV_USER, e, e_ev_signal_free);
|
ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free);
|
||||||
signal_hup_count--;
|
signal_hup_count--;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
pid_pass = 0;
|
pid_pass = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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
|
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_handler = ecore_event_signal_handle_sigchld;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
|
sigaction(SIGCHLD, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigusr1;
|
sa.sa_handler = ecore_event_signal_handle_sigusr1;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGUSR1, &sa, (struct sigaction *)0);
|
sigaction(SIGUSR1, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigusr2;
|
sa.sa_handler = ecore_event_signal_handle_sigusr2;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGUSR2, &sa, (struct sigaction *)0);
|
sigaction(SIGUSR2, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sighup;
|
sa.sa_handler = ecore_event_signal_handle_sighup;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGHUP, &sa, (struct sigaction *)0);
|
sigaction(SIGHUP, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigpipe;
|
sa.sa_handler = ecore_event_signal_handle_sigpipe;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGPIPE, &sa, (struct sigaction *)0);
|
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;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGSEGV, &sa, (struct sigaction *)0);
|
sigaction(SIGSEGV, &sa, (struct sigaction *)0);
|
||||||
*/
|
*/
|
||||||
sa.sa_handler = e_ev_signal_handle_sigfpe;
|
sa.sa_handler = ecore_event_signal_handle_sigfpe;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGFPE, &sa, (struct sigaction *)0);
|
sigaction(SIGFPE, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigill;
|
sa.sa_handler = ecore_event_signal_handle_sigill;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGILL, &sa, (struct sigaction *)0);
|
sigaction(SIGILL, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigbus;
|
sa.sa_handler = ecore_event_signal_handle_sigbus;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGBUS, &sa, (struct sigaction *)0);
|
sigaction(SIGBUS, &sa, (struct sigaction *)0);
|
||||||
#ifdef HAVE_SIGSTKFLT
|
#ifdef HAVE_SIGSTKFLT
|
||||||
sa.sa_handler = e_ev_signal_handle_sigstkflt;
|
sa.sa_handler = ecore_event_signal_handle_sigstkflt;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGSTKFLT, &sa, (struct sigaction *)0);
|
sigaction(SIGSTKFLT, &sa, (struct sigaction *)0);
|
||||||
#endif
|
#endif
|
||||||
sa.sa_handler = e_ev_signal_handle_sigint;
|
sa.sa_handler = ecore_event_signal_handle_sigint;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGINT, &sa, (struct sigaction *)0);
|
sigaction(SIGINT, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigquit;
|
sa.sa_handler = ecore_event_signal_handle_sigquit;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGQUIT, &sa, (struct sigaction *)0);
|
sigaction(SIGQUIT, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigabrt;
|
sa.sa_handler = ecore_event_signal_handle_sigabrt;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGABRT, &sa, (struct sigaction *)0);
|
sigaction(SIGABRT, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigalrm;
|
sa.sa_handler = ecore_event_signal_handle_sigalrm;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGALRM, &sa, (struct sigaction *)0);
|
sigaction(SIGALRM, &sa, (struct sigaction *)0);
|
||||||
|
|
||||||
sa.sa_handler = e_ev_signal_handle_sigterm;
|
sa.sa_handler = ecore_event_signal_handle_sigterm;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGTERM, &sa, (struct sigaction *)0);
|
sigaction(SIGTERM, &sa, (struct sigaction *)0);
|
||||||
#ifdef HAVE_SIGPWR
|
#ifdef HAVE_SIGPWR
|
||||||
sa.sa_handler = e_ev_signal_handle_sigpwr;
|
sa.sa_handler = ecore_event_signal_handle_sigpwr;
|
||||||
sa.sa_flags = SA_RESTART;
|
sa.sa_flags = SA_RESTART;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
sigaction(SIGPWR, &sa, (struct sigaction *)0);
|
sigaction(SIGPWR, &sa, (struct sigaction *)0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,425 +6,424 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/* glocal (yes global/local) variabels for events */
|
/* glocal (yes global/local) variabels for events */
|
||||||
Ev_Fd_Handler *fd_handlers = NULL;
|
Ecore_Event_Fd_Handler *fd_handlers = NULL;
|
||||||
Ev_Ipc_Handler *ipc_handlers = NULL;
|
Ecore_Event_Ipc_Handler *ipc_handlers = NULL;
|
||||||
Ev_Pid_Handler *pid_handlers = NULL;
|
Ecore_Event_Pid_Handler *pid_handlers = NULL;
|
||||||
Ev_Timer *timers = NULL;
|
Ecore_Event_Timer *timers = NULL;
|
||||||
|
|
||||||
Eevent *events = NULL;
|
Ecore_Event *events = NULL;
|
||||||
Eevent *last_event = NULL;
|
Ecore_Event *last_event = NULL;
|
||||||
|
|
||||||
int __quit_ev_loop = 0;
|
int __quit_ev_loop = 0;
|
||||||
|
|
||||||
/* local functions for event handling */
|
/* local functions for event handling */
|
||||||
static void e_handle_event_timer(void);
|
static void ecore_handle_event_timer(void);
|
||||||
static void e_handle_zero_event_timer(void);
|
static void ecore_handle_zero_event_timer(void);
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
/* add an event to the end of the event queue */
|
/* add an event to the end of the event queue */
|
||||||
void
|
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 = NEW(Ecore_Event, 1);
|
||||||
ev->type = type;
|
ev->type = type;
|
||||||
ev->ignore = 0;
|
ev->ignore = 0;
|
||||||
ev->event = event;
|
ev->event = event;
|
||||||
ev->next = NULL;
|
ev->next = NULL;
|
||||||
ev->ev_free = ev_free;
|
ev->ev_free = ev_free;
|
||||||
if (!events)
|
if (!events)
|
||||||
events = ev;
|
events = ev;
|
||||||
else
|
else
|
||||||
last_event->next = ev;
|
last_event->next = ev;
|
||||||
last_event = ev;
|
last_event = ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete an event from the event queue */
|
/* delete an event from the event queue */
|
||||||
void
|
void
|
||||||
e_del_event(void *event)
|
ecore_del_event(void *event)
|
||||||
{
|
{
|
||||||
Eevent *ev, *pev;
|
Ecore_Event *ev, *pev;
|
||||||
|
|
||||||
pev = NULL;
|
pev = NULL;
|
||||||
ev = events;
|
ev = events;
|
||||||
while (ev)
|
while (ev)
|
||||||
{
|
{
|
||||||
if (ev->event == event)
|
if (ev->event == event)
|
||||||
{
|
{
|
||||||
if (pev)
|
if (pev)
|
||||||
pev->next = ev->next;
|
pev->next = ev->next;
|
||||||
else
|
else
|
||||||
events = ev->next;
|
events = ev->next;
|
||||||
if (!ev->next)
|
if (!ev->next)
|
||||||
last_event = pev;
|
last_event = pev;
|
||||||
if ((ev->event) && (ev->ev_free))
|
if ((ev->event) && (ev->ev_free))
|
||||||
(*ev->ev_free) (ev->event);
|
(*ev->ev_free) (ev->event);
|
||||||
FREE(ev);
|
FREE(ev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pev = ev;
|
pev = ev;
|
||||||
ev = ev->next;
|
ev = ev->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_del_all_events(void)
|
ecore_del_all_events(void)
|
||||||
{
|
{
|
||||||
Eevent *ev, *pev;
|
Ecore_Event *ev, *pev;
|
||||||
|
|
||||||
ev = events;
|
ev = events;
|
||||||
while (ev)
|
while (ev)
|
||||||
{
|
{
|
||||||
pev = ev;
|
pev = ev;
|
||||||
ev = ev->next;
|
ev = ev->next;
|
||||||
if ((pev->event) && (pev->ev_free))
|
if ((pev->event) && (pev->ev_free))
|
||||||
pev->ev_free(pev->event);
|
pev->ev_free(pev->event);
|
||||||
FREE(pev);
|
FREE(pev);
|
||||||
}
|
}
|
||||||
events = NULL;
|
events = NULL;
|
||||||
last_event = NULL;
|
last_event = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Eevent *
|
Ecore_Event *
|
||||||
e_get_last_event(void)
|
ecore_get_last_event(void)
|
||||||
{
|
{
|
||||||
return last_event;
|
return last_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add a callback handler if fd is active for reading */
|
/* add a callback handler if fd is active for reading */
|
||||||
void
|
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 */
|
/* new handler struct */
|
||||||
fd_h = NEW(Ev_Fd_Handler, 1);
|
fd_h = NEW(Ecore_Event_Fd_Handler, 1);
|
||||||
fd_h->next = fd_handlers;
|
fd_h->next = fd_handlers;
|
||||||
fd_h->fd = fd;
|
fd_h->fd = fd;
|
||||||
fd_h->func = func;
|
fd_h->func = func;
|
||||||
fd_handlers = fd_h;
|
fd_handlers = fd_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete handler for fd */
|
/* delete handler for fd */
|
||||||
void
|
void
|
||||||
e_del_event_fd(int fd)
|
ecore_del_event_fd(int fd)
|
||||||
{
|
{
|
||||||
START_LIST_DEL(Ev_Fd_Handler, fd_handlers, (_p->fd == fd));
|
START_LIST_DEL(Ecore_Event_Fd_Handler, fd_handlers, (_p->fd == fd));
|
||||||
FREE(_p);
|
FREE(_p);
|
||||||
END_LIST_DEL;
|
END_LIST_DEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 */
|
/* delete the old handler */
|
||||||
e_del_event_pid(pid);
|
ecore_del_event_pid(pid);
|
||||||
/* new handler struct */
|
/* new handler struct */
|
||||||
pid_h = NEW(Ev_Pid_Handler, 1);
|
pid_h = NEW(Ecore_Event_Pid_Handler, 1);
|
||||||
pid_h->next = pid_handlers;
|
pid_h->next = pid_handlers;
|
||||||
pid_h->pid = pid;
|
pid_h->pid = pid;
|
||||||
pid_h->func = func;
|
pid_h->func = func;
|
||||||
pid_handlers = pid_h;
|
pid_handlers = pid_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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));
|
START_LIST_DEL(Ecore_Event_Pid_Handler, pid_handlers, (_p->pid == pid));
|
||||||
FREE(_p);
|
FREE(_p);
|
||||||
END_LIST_DEL;
|
END_LIST_DEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 */
|
/* delete the old handler */
|
||||||
e_del_event_ipc(ipc);
|
ecore_del_event_ipc(ipc);
|
||||||
/* new handler struct */
|
/* new handler struct */
|
||||||
ipc_h = NEW(Ev_Ipc_Handler, 1);
|
ipc_h = NEW(Ecore_Event_Ipc_Handler, 1);
|
||||||
ipc_h->next = ipc_handlers;
|
ipc_h->next = ipc_handlers;
|
||||||
ipc_h->ipc = ipc;
|
ipc_h->ipc = ipc;
|
||||||
ipc_h->func = func;
|
ipc_h->func = func;
|
||||||
ipc_handlers = ipc_h;
|
ipc_handlers = ipc_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_del_event_ipc(int ipc)
|
ecore_del_event_ipc(int ipc)
|
||||||
{
|
{
|
||||||
START_LIST_DEL(Ev_Ipc_Handler, ipc_handlers, (_p->ipc == ipc));
|
START_LIST_DEL(Ecore_Event_Ipc_Handler, ipc_handlers, (_p->ipc == ipc));
|
||||||
FREE(_p);
|
FREE(_p);
|
||||||
END_LIST_DEL;
|
END_LIST_DEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sit in this loop forever and process events */
|
/* sit in this loop forever and process events */
|
||||||
void
|
void
|
||||||
e_event_loop(void)
|
ecore_event_loop(void)
|
||||||
{
|
{
|
||||||
int fdcount, fdsize, ipccount, ipcsize;
|
int fdcount, fdsize, ipccount, ipcsize;
|
||||||
int timed_out, were_events;
|
int timed_out, were_events;
|
||||||
double time1, time2, prev_time = 0.0;
|
double time1, time2, prev_time = 0.0;
|
||||||
struct timeval tval;
|
struct timeval tval;
|
||||||
fd_set fdset, ipcset;
|
fd_set fdset, ipcset;
|
||||||
Ev_Fd_Handler *fd_h;
|
Ecore_Event_Fd_Handler *fd_h;
|
||||||
Ev_Pid_Handler *pid_h;
|
Ecore_Event_Pid_Handler *pid_h;
|
||||||
Ev_Ipc_Handler *ipc_h;
|
Ecore_Event_Ipc_Handler *ipc_h;
|
||||||
|
|
||||||
/* init some of the time variables */
|
/* init some of the time variables */
|
||||||
time1 = e_get_time();
|
time1 = ecore_get_time();
|
||||||
time2 = time1 - prev_time;
|
time2 = time1 - prev_time;
|
||||||
prev_time = time1;
|
prev_time = time1;
|
||||||
while( __quit_ev_loop == 0 )
|
while (__quit_ev_loop == 0)
|
||||||
{
|
{
|
||||||
/* state setup */
|
/* state setup */
|
||||||
timed_out = 0;
|
timed_out = 0;
|
||||||
were_events = 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);
|
|
||||||
|
|
||||||
/* see if we have any new ipc connections */
|
/* setup fd array from list of listening fd's */
|
||||||
tval.tv_sec = 0;
|
fdsize = 0;
|
||||||
tval.tv_usec = 0;
|
FD_ZERO(&fdset);
|
||||||
ipccount += select(ipcsize + 1, &ipcset, NULL, NULL, &tval);
|
/* 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 */
|
/* see if we have any new ipc connections */
|
||||||
if (fdcount < 0)
|
tval.tv_sec = 0;
|
||||||
{
|
tval.tv_usec = 0;
|
||||||
/* error */
|
ipccount += select(ipcsize + 1, &ipcset, NULL, NULL, &tval);
|
||||||
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;
|
|
||||||
|
|
||||||
fdh = fd_h;
|
/* return < 0 - error or signal interrupt */
|
||||||
fd_h = fd_h->next;
|
if (fdcount < 0)
|
||||||
if (FD_ISSET(fdh->fd, &fdset))
|
{
|
||||||
fdh->func(fdh->fd);
|
/* 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 */
|
fdh = fd_h;
|
||||||
if (ipccount > 0)
|
fd_h = fd_h->next;
|
||||||
{
|
if (FD_ISSET(fdh->fd, &fdset))
|
||||||
for (ipc_h = ipc_handlers; ipc_h;)
|
fdh->func(fdh->fd);
|
||||||
{
|
}
|
||||||
Ev_Ipc_Handler *ipch;
|
}
|
||||||
|
|
||||||
ipch = ipc_h;
|
/* ipc clients are active */
|
||||||
ipc_h = ipc_h->next;
|
if (ipccount > 0)
|
||||||
if (FD_ISSET(ipch->ipc, &ipcset))
|
{
|
||||||
ipch->func(ipch->ipc);
|
for (ipc_h = ipc_handlers; ipc_h;)
|
||||||
}
|
{
|
||||||
}
|
Ecore_Event_Ipc_Handler *ipch;
|
||||||
if (events)
|
|
||||||
e_event_filter(events);
|
ipch = ipc_h;
|
||||||
if (events)
|
ipc_h = ipc_h->next;
|
||||||
{
|
if (FD_ISSET(ipch->ipc, &ipcset))
|
||||||
e_event_filter_events_handle(events);
|
ipch->func(ipch->ipc);
|
||||||
were_events = 1;
|
}
|
||||||
}
|
}
|
||||||
e_del_all_events();
|
if (events)
|
||||||
if ((timed_out) || (were_events))
|
ecore_event_filter(events);
|
||||||
e_event_filter_idle_handle();
|
if (events)
|
||||||
e_flush();
|
{
|
||||||
time1 = e_get_time();
|
ecore_event_filter_events_handle(events);
|
||||||
time2 = time1 - prev_time;
|
were_events = 1;
|
||||||
prev_time = time1;
|
}
|
||||||
}
|
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
|
/* set a flag to 0 so that we can quit the event loop and shutdown
|
||||||
* properly */
|
* properly */
|
||||||
void
|
void
|
||||||
e_event_loop_quit(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 */
|
/* add a timeout funcitont o be called in "in" seconds with name name */
|
||||||
void
|
void
|
||||||
e_add_event_timer(char *name, double in, void (*func) (int val, void *data),
|
ecore_add_event_timer(char *name, double in, void (*func) (int val, void *data),
|
||||||
int val, void *data)
|
int val, void *data)
|
||||||
{
|
{
|
||||||
Ev_Timer *timer, *ptr, *pptr;
|
Ecore_Event_Timer *timer, *ptr, *pptr;
|
||||||
double tally;
|
double tally;
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
e_del_event_timer(name);
|
ecore_del_event_timer(name);
|
||||||
timer = NEW(Ev_Timer, 1);
|
timer = NEW(Ecore_Event_Timer, 1);
|
||||||
timer->next = NULL;
|
timer->next = NULL;
|
||||||
timer->func = func;
|
timer->func = func;
|
||||||
timer->data = data;
|
timer->data = data;
|
||||||
timer->val = val;
|
timer->val = val;
|
||||||
timer->just_added = 1;
|
timer->just_added = 1;
|
||||||
timer->in = in;
|
timer->in = in;
|
||||||
timer->name = strdup(name);
|
timer->name = strdup(name);
|
||||||
if (!timers)
|
if (!timers)
|
||||||
timers = timer;
|
timers = timer;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pptr = NULL;
|
pptr = NULL;
|
||||||
ptr = timers;
|
ptr = timers;
|
||||||
tally = 0.0;
|
tally = 0.0;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
tally += ptr->in;
|
tally += ptr->in;
|
||||||
if (tally > in)
|
if (tally > in)
|
||||||
{
|
{
|
||||||
tally -= ptr->in;
|
tally -= ptr->in;
|
||||||
timer->next = ptr;
|
timer->next = ptr;
|
||||||
if (pptr)
|
if (pptr)
|
||||||
pptr->next = timer;
|
pptr->next = timer;
|
||||||
else
|
else
|
||||||
timers = timer;
|
timers = timer;
|
||||||
timer->in -= tally;
|
timer->in -= tally;
|
||||||
if (timer->next)
|
if (timer->next)
|
||||||
timer->next->in -= timer->in;
|
timer->next->in -= timer->in;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pptr = ptr;
|
pptr = ptr;
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
if (pptr)
|
if (pptr)
|
||||||
pptr->next = timer;
|
pptr->next = timer;
|
||||||
else
|
else
|
||||||
timers = timer;
|
timers = timer;
|
||||||
timer->in -= tally;
|
timer->in -= tally;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete a timer timeout entry named "name" */
|
/* delete a timer timeout entry named "name" */
|
||||||
void *
|
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;
|
pptr = NULL;
|
||||||
ptr = timers;
|
ptr = timers;
|
||||||
while (ptr)
|
while (ptr)
|
||||||
{
|
{
|
||||||
timer = ptr;
|
timer = ptr;
|
||||||
if (!strcmp(timer->name, name))
|
if (!strcmp(timer->name, name))
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
if (pptr)
|
if (pptr)
|
||||||
pptr->next = timer->next;
|
pptr->next = timer->next;
|
||||||
else
|
else
|
||||||
timers = timer->next;
|
timers = timer->next;
|
||||||
if (timer->next)
|
if (timer->next)
|
||||||
timer->next->in += timer->in;
|
timer->next->in += timer->in;
|
||||||
IF_FREE(timer->name);
|
IF_FREE(timer->name);
|
||||||
data = timer->data;
|
data = timer->data;
|
||||||
FREE(timer);
|
FREE(timer);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
pptr = ptr;
|
pptr = ptr;
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
static void
|
static void
|
||||||
e_handle_event_timer(void)
|
ecore_handle_event_timer(void)
|
||||||
{
|
{
|
||||||
Ev_Timer *timer;
|
Ecore_Event_Timer *timer;
|
||||||
|
|
||||||
if (!timers)
|
if (!timers)
|
||||||
return;
|
return;
|
||||||
timer = timers;
|
timer = timers;
|
||||||
timers = timer->next;
|
timers = timer->next;
|
||||||
(*(timer->func)) (timer->val, timer->data);
|
(*(timer->func)) (timer->val, timer->data);
|
||||||
IF_FREE(timer->name);
|
IF_FREE(timer->name);
|
||||||
FREE(timer);
|
FREE(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_handle_zero_event_timer(void)
|
ecore_handle_zero_event_timer(void)
|
||||||
{
|
{
|
||||||
while ((timers) && (timers->in == 0.0))
|
while ((timers) && (timers->in == 0.0))
|
||||||
e_handle_event_timer();
|
ecore_handle_event_timer();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,28 +5,28 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void e_ipc_init(char *path);
|
void ecore_ipc_init(char *path);
|
||||||
void e_ipc_cleanup(void);
|
void ecore_ipc_cleanup(void);
|
||||||
static void e_ipc_connect_handler(int fd);
|
static void ecore_ipc_connect_handler(int fd);
|
||||||
static void e_ipc_client_handler(int fd);
|
static void ecore_ipc_client_handler(int fd);
|
||||||
void e_ipc_get_data(int fd, void *buf);
|
void ecore_ipc_get_data(int fd, void *buf);
|
||||||
void e_ipc_send_data(int fd, void *buf, int size);
|
void ecore_ipc_send_data(int fd, void *buf, int size);
|
||||||
void e_add_ipc_service(int service, void (*func) (int fd));
|
void ecore_add_ipc_service(int service, void (*func) (int fd));
|
||||||
void e_del_ipc_service(int service);
|
void ecore_del_ipc_service(int service);
|
||||||
|
|
||||||
Ev_Ipc_Service *ipc_services = NULL;
|
Ecore_Event_Ipc_Service *ipc_services = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
e_ev_ipc_init(char *path)
|
ecore_ev_ipc_init(char *path)
|
||||||
{
|
{
|
||||||
int fd, len;
|
int fd, len;
|
||||||
struct sockaddr_un saun;
|
struct sockaddr_un saun;
|
||||||
|
|
||||||
if(path == NULL)
|
if (path == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* a UNIX domain, stream socket */
|
/* 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");
|
printf("Cannot create ipc socket... disabling ipc.\n");
|
||||||
return;
|
return;
|
||||||
|
@ -40,7 +40,7 @@ e_ev_ipc_init(char *path)
|
||||||
unlink(path);
|
unlink(path);
|
||||||
len = sizeof(saun.sun_family) + strlen(saun.sun_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");
|
printf("Cannot bind ipc socket... disabling ipc.\n");
|
||||||
return;
|
return;
|
||||||
|
@ -54,126 +54,134 @@ e_ev_ipc_init(char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add ipc listener */
|
/* add ipc listener */
|
||||||
e_add_event_ipc(fd, e_ipc_connect_handler);
|
ecore_add_event_ipc(fd, ecore_ipc_connect_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_ev_ipc_cleanup(void)
|
ecore_ev_ipc_cleanup(void)
|
||||||
{
|
{
|
||||||
Ev_Ipc_Service *ipc_s;
|
Ecore_Event_Ipc_Service *ipc_s;
|
||||||
|
|
||||||
/* cleanup services list */
|
/* cleanup services list */
|
||||||
for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next)
|
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
|
static void
|
||||||
e_ipc_connect_handler(int fd)
|
ecore_ipc_connect_handler(int fd)
|
||||||
{
|
{
|
||||||
struct sockaddr_un fsaun;
|
struct sockaddr_un fsaun;
|
||||||
int fromlen, nfd;
|
int fromlen, nfd;
|
||||||
|
|
||||||
/* accept ipc connection */
|
/* accept ipc connection */
|
||||||
fromlen = sizeof(fsaun);
|
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");
|
printf("Cannot accept ipc connection... ignoring connection attempt.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add ipc client */
|
/* add ipc client */
|
||||||
e_add_event_ipc(nfd, e_ipc_client_handler);
|
ecore_add_event_ipc(nfd, ecore_ipc_client_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
e_ipc_client_handler(int fd)
|
ecore_ipc_client_handler(int fd)
|
||||||
{
|
{
|
||||||
int nread, service;
|
int nread, service;
|
||||||
Ev_Ipc_Service *ipc_s;
|
Ecore_Event_Ipc_Service *ipc_s;
|
||||||
|
|
||||||
if ((nread = read(fd, &service, sizeof(service))) == 0)
|
if ((nread = read(fd, &service, sizeof(service))) == 0)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
e_del_event_ipc(fd);
|
ecore_del_event_ipc(fd);
|
||||||
}
|
}
|
||||||
else if (nread > 0)
|
else if (nread > 0)
|
||||||
{
|
{
|
||||||
/* call the service function */
|
/* call the service function */
|
||||||
for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next)
|
for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next)
|
||||||
{
|
{
|
||||||
if (ipc_s->service == service)
|
if (ipc_s->service == service)
|
||||||
{
|
{
|
||||||
ipc_s->func(fd);
|
ipc_s->func(fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("ipc error in read service.\n"); fflush(stdout);
|
printf("ipc error in read service.\n");
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 */
|
/* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get data structure */
|
/* 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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 */
|
/* send length of data being sent */
|
||||||
if ((n = write(fd, &size, sizeof(size))) == -1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send data */
|
/* send data */
|
||||||
if ((n = write(fd, buf, size)) == -1)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 */
|
/* delete the old service */
|
||||||
e_del_ipc_service(service);
|
ecore_del_ipc_service(service);
|
||||||
/* new service struct */
|
/* new service struct */
|
||||||
ipc_s = NEW(Ev_Ipc_Service, 1);
|
ipc_s = NEW(Ecore_Event_Ipc_Service, 1);
|
||||||
ipc_s->next = ipc_services;
|
ipc_s->next = ipc_services;
|
||||||
ipc_s->service = service;
|
ipc_s->service = service;
|
||||||
ipc_s->func = func;
|
ipc_s->func = func;
|
||||||
ipc_services = ipc_s;
|
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));
|
START_LIST_DEL(Ecore_Event_Ipc_Service, ipc_services,
|
||||||
FREE(_p);
|
(_p->service == service));
|
||||||
END_LIST_DEL;
|
FREE(_p);
|
||||||
|
END_LIST_DEL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "Ecore.h"
|
#include "Ecore.h"
|
||||||
|
|
||||||
double
|
double
|
||||||
e_get_time(void)
|
ecore_get_time(void)
|
||||||
{
|
{
|
||||||
struct timeval timev;
|
struct timeval timev;
|
||||||
|
|
||||||
gettimeofday(&timev, NULL);
|
gettimeofday(&timev, NULL);
|
||||||
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
|
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue