Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/src
Modified Files:
E.h events.c
Log Message:
Fix delay in main event loop, cleanups.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.454
retrieving revision 1.455
diff -u -3 -r1.454 -r1.455
--- E.h 12 Jun 2005 13:09:10 -0000 1.454
+++ E.h 14 Jun 2005 22:52:24 -0000 1.455
@@ -1562,7 +1562,6 @@
#define EventDebugSet(type, value)
#endif
void EventsInit(void);
-void CheckEvent(void);
void WaitEvent(void);
void EventDebugInit(const char *s);
void EventShow(const XEvent * ev);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/events.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -3 -r1.92 -r1.93
--- events.c 9 Jun 2005 18:28:11 -0000 1.92
+++ events.c 14 Jun 2005 22:52:24 -0000 1.93
@@ -57,13 +57,6 @@
static int error_base_render = 0;
#endif
-static int evq_num = 0;
-static XEvent *evq_ptr = NULL;
-
-static int evq_num2 = 0;
-static int evq_cur2 = 0;
-static XEvent *evq_ptr2 = NULL;
-
#define DOUBLE_CLICK_TIME 250 /* Milliseconds */
static void
@@ -473,7 +466,7 @@
int qsz = *evq_n;
/* Fetch the entire event queue */
- for (i = count = qsz; (n = XPending(disp)) > 0;)
+ for (i = count = 0; (n = XPending(disp)) > 0;)
{
count += n;
if (count > qsz)
@@ -509,94 +502,39 @@
}
static int
-EventsProcess(XEvent ** evq_p, int *evq_n)
+EventsProcess(XEvent ** evq_p, int *evq_n, int *evq_f)
{
- int i;
+ int i, n, count;
XEvent *evq;
- int qsz;
/* Fetch the entire event queue */
- EventsFetch(evq_p, evq_n);
+ n = EventsFetch(evq_p, evq_n);
evq = *evq_p;
- qsz = *evq_n;
- again:
if (EventDebug(EDBUG_TYPE_EVENTS))
- Eprintf("EventsProcess-B %d\n", qsz);
+ Eprintf("EventsProcess-B %d\n", n);
- for (i = 0; i < qsz; i++)
+ for (i = count = 0; i < n; i++)
{
if (evq[i].type == 0)
continue;
- if (EventDebug(EDBUG_TYPE_EVENTS))
+ if (EventDebug(EDBUG_TYPE_EVENTS) > 1)
Eprintf("EventsProcess %d type=%d\n", i, evq[i].type);
+ count++;
HandleEvent(evq + i);
evq[i].type = 0;
}
- if (evq_num2)
- {
- /* Process leftovers */
- Efree(evq_ptr);
- evq = evq_ptr = evq_ptr2;
- qsz = evq_num = evq_num2;
- evq_ptr2 = 0;
- evq_num2 = evq_cur2 = 0;
- goto again;
- }
-
if (EventDebug(EDBUG_TYPE_EVENTS))
- Eprintf("EventsProcess-E %d\n", qsz);
-
- return qsz;
-}
-
-#if 0 /* FIXME - Remove? */
-void
-CheckEvent(void)
-{
- int i;
- XEvent *evq;
- int qsz;
-
- /* Fetch the entire event queue */
- EventsFetch(&evq_ptr2, &evq_num2);
- evq = evq_ptr2;
- qsz = evq_num2;
-
- if (EventDebug(EDBUG_TYPE_EVENTS))
- Eprintf("CheckEvent-B %d/%d\n", evq_cur2, evq_num2);
-
- for (i = evq_cur2; i < qsz; i++)
- {
- evq_cur2 = i;
- switch (evq[i].type)
- {
- case CreateNotify:
- case DestroyNotify:
- case ReparentNotify:
- case UnmapNotify:
- case MapNotify:
- case ConfigureNotify:
- case Expose:
- case EX_EVENT_DAMAGE_NOTIFY:
- if (EventDebug(EDBUG_TYPE_EVENTS))
- Eprintf("CheckEvent %d type=%d\n", i, evq[i].type);
-
- HandleEvent(evq + i);
- evq[i].type = 0;
- break;
- }
- }
+ Eprintf("EventsProcess-E %d/%d\n", count, n);
- if (EventDebug(EDBUG_TYPE_EVENTS))
- Eprintf("CheckEvent-E\n");
+ if (n > *evq_f)
+ *evq_f = n;
- ModulesSignal(ESIGNAL_IDLE, NULL);
+ return count;
}
-#endif
/*
* This is the primary event loop. Everything that is going to happen in the
@@ -606,12 +544,15 @@
void
WaitEvent(void)
{
+ static int evq_alloc = 0;
+ static int evq_fetch = 0;
+ static XEvent *evq_ptr = NULL;
fd_set fdset;
struct timeval tval;
static struct timeval tval_last = { 0, 0 };
double time1, time2;
Qentry *qe;
- int count, pcount;
+ int count, pcount, pfetch;
int fdsize;
int xfd, smfd;
@@ -636,28 +577,40 @@
time2 = 0.0;
/* time2 = time spent since we last were here */
- evq_num = 0;
- count = EventsProcess(&evq_ptr, &evq_num);
-
- DialogsCheckUpdate();
- ModulesSignal(ESIGNAL_IDLE, NULL);
+ pcount = pfetch = 0;
+ for (;;)
+ {
+ count = EventsProcess(&evq_ptr, &evq_alloc, &pfetch);
- XFlush(disp);
- pcount = count;
+ if (count > pcount)
+ pcount = count;
+ if (!pcount)
+ break;
+ if (XPending(disp))
+ continue;
- evq_num = 0;
- count = EventsProcess(&evq_ptr, &evq_num);
+ if (EventDebug(EDBUG_TYPE_EVENTS))
+ Eprintf("WaitEvent - Idlers\n");
+ DialogsCheckUpdate(); /* FIXME - Shouldn't be here */
+ ModulesSignal(ESIGNAL_IDLE, NULL);
- if (count > 0)
- XFlush(disp);
+ if (!XPending(disp))
+ break;
+ }
- if (pcount > count)
- count = pcount;
- if ((evq_ptr) && ((evq_num - count) > 64))
+ if (pfetch)
{
- evq_num = 0;
- Efree(evq_ptr);
- evq_ptr = NULL;
+ evq_fetch =
+ (pfetch > evq_fetch) ? pfetch : (3 * evq_fetch + pfetch) / 4;
+ if (EventDebug(EDBUG_TYPE_EVENTS))
+ Eprintf("WaitEvent - Alloc/fetch/pfetch/peak=%d/%d/%d/%d)\n",
+ evq_alloc, evq_fetch, pfetch, pcount);
+ if ((evq_ptr) && ((evq_alloc - evq_fetch) > 64))
+ {
+ evq_alloc = 0;
+ Efree(evq_ptr);
+ evq_ptr = NULL;
+ }
}
FD_ZERO(&fdset);
@@ -691,11 +644,19 @@
return;
if ((smfd >= 0) && (count > 0) && (FD_ISSET(smfd, &fdset)))
- ProcessICEMSGS();
+ {
+ if (EventDebug(EDBUG_TYPE_EVENTS))
+ Eprintf("WaitEvent - ICE\n");
+ ProcessICEMSGS();
+ }
if ((!(FD_ISSET(xfd, &fdset))) && (qe) && (count == 0)
&& (((smfd >= 0) && (!(FD_ISSET(smfd, &fdset)))) || (smfd < 0)))
- HandleTimerEvent();
+ {
+ if (EventDebug(EDBUG_TYPE_EVENTS))
+ Eprintf("WaitEvent - Timers (%s)\n", qe->name);
+ HandleTimerEvent();
+ }
}
#if ENABLE_DEBUG_EVENTS
@@ -729,7 +690,12 @@
if (ix < 0)
ix = -ix;
if (ix < N_DEBUG_FLAGS)
- ev_debug_flags[ix] = onoff;
+ {
+ if (onoff)
+ ev_debug_flags[ix]++;
+ else
+ ev_debug_flags[ix] = 0;
+ }
if (!s)
break;
param = s + 1;
@@ -739,7 +705,8 @@
int
EventDebug(unsigned int type)
{
- return ev_debug && (type < sizeof(ev_debug_flags)) && ev_debug_flags[type];
+ return (ev_debug &&
+ (type < sizeof(ev_debug_flags))) ? ev_debug_flags[type] : 0;
}
void
@@ -749,7 +716,7 @@
return;
ev_debug = 1;
- ev_debug_flags[type] = value;
+ ev_debug_flags[type] += value;
}
static const char *const TxtEventNames[] = {
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs