mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 12:58:08 +01:00
fixed timerhandler cpu eater
This commit is contained in:
@@ -80,7 +80,7 @@ main(int argc, char **argv)
|
||||
|
||||
WMInitializeApplication("test", &argc, argv);
|
||||
|
||||
scr = WMOpenScreen();
|
||||
scr = WMOpenScreen(NULL);
|
||||
|
||||
|
||||
win = WMCreateWindow(scr, "eweq");
|
||||
|
||||
@@ -345,7 +345,6 @@ checkIdleHandlers()
|
||||
WMBag *handlerCopy;
|
||||
WMBagIterator iter;
|
||||
|
||||
|
||||
if (!idleHandler || WMGetBagItemCount(idleHandler)==0) {
|
||||
W_FlushIdleNotificationQueue();
|
||||
/* make sure an observer in queue didn't added an idle handler */
|
||||
@@ -420,8 +419,12 @@ static void
|
||||
delayUntilNextTimerEvent(struct timeval *delay)
|
||||
{
|
||||
struct timeval now;
|
||||
TimerHandler *handler;
|
||||
|
||||
if (!timerHandler) {
|
||||
handler = timerHandler;
|
||||
while (handler && IS_ZERO(handler->when)) handler = handler->next;
|
||||
|
||||
if (!handler) {
|
||||
/* The return value of this function is only valid if there _are_
|
||||
timers active. */
|
||||
delay->tv_sec = 0;
|
||||
@@ -430,12 +433,12 @@ delayUntilNextTimerEvent(struct timeval *delay)
|
||||
}
|
||||
|
||||
rightNow(&now);
|
||||
if (IS_AFTER(now, timerHandler->when)) {
|
||||
if (IS_AFTER(now, handler->when)) {
|
||||
delay->tv_sec = 0;
|
||||
delay->tv_usec = 0;
|
||||
} else {
|
||||
delay->tv_sec = timerHandler->when.tv_sec - now.tv_sec;
|
||||
delay->tv_usec = timerHandler->when.tv_usec - now.tv_usec;
|
||||
delay->tv_sec = handler->when.tv_sec - now.tv_sec;
|
||||
delay->tv_usec = handler->when.tv_usec - now.tv_usec;
|
||||
if (delay->tv_usec < 0) {
|
||||
delay->tv_usec += 1000000;
|
||||
delay->tv_sec--;
|
||||
|
||||
@@ -472,6 +472,7 @@ extern Display *dpy;
|
||||
extern char *ProgName;
|
||||
extern unsigned int ValidModMask;
|
||||
extern char WProgramState;
|
||||
extern char WProgramSigState;
|
||||
|
||||
/****** Global Functions ******/
|
||||
extern void wAbort(Bool dumpCore);
|
||||
|
||||
@@ -228,9 +228,10 @@ handleXIO(Display *xio_dpy)
|
||||
static void
|
||||
delayedAction(void *cdata)
|
||||
{
|
||||
if (WDelatedActionSet == 0)
|
||||
if (WDelayedActionSet == 0) {
|
||||
return;
|
||||
WDelayedActionSet = 0;
|
||||
}
|
||||
WDelayedActionSet--;
|
||||
/*
|
||||
* Make the event dispatcher do whatever it needs to do,
|
||||
* including handling zombie processes, restart and exit
|
||||
@@ -265,7 +266,7 @@ handleExitSig(int sig)
|
||||
/* setup idle handler, so that this will be handled when
|
||||
* the select() is returned becaused of the signal, even if
|
||||
* there are no X events in the queue */
|
||||
WDelayedActionSet = 1;
|
||||
WDelayedActionSet++;
|
||||
} else if (sig == SIGUSR2) {
|
||||
#ifdef SYS_SIGLIST_DECLARED
|
||||
wwarning(_("got signal %i (%s) - rereading defaults\n"), sig, sys_siglist[sig]);
|
||||
@@ -277,7 +278,7 @@ handleExitSig(int sig)
|
||||
/* setup idle handler, so that this will be handled when
|
||||
* the select() is returned becaused of the signal, even if
|
||||
* there are no X events in the queue */
|
||||
WDelayedActionSet = 1;
|
||||
WDelayedActionSet++;
|
||||
} else if (sig == SIGINT || sig == SIGHUP) {
|
||||
#ifdef SYS_SIGLIST_DECLARED
|
||||
wwarning(_("got signal %i (%s) - exiting...\n"), sig, sys_siglist[sig]);
|
||||
@@ -287,7 +288,7 @@ handleExitSig(int sig)
|
||||
|
||||
SIG_WCHANGE_STATE(WSTATE_NEED_EXIT);
|
||||
|
||||
WDelayedActionSet = 1;
|
||||
WDelayedActionSet++;
|
||||
}
|
||||
|
||||
sigprocmask(SIG_UNBLOCK, &sigs, NULL);
|
||||
@@ -418,7 +419,7 @@ buryChild(int foo)
|
||||
NotifyDeadProcess(pid, WEXITSTATUS(status));
|
||||
}
|
||||
|
||||
WDelayedActionSet = 1;
|
||||
WDelayedActionSet++;
|
||||
|
||||
sigprocmask(SIG_UNBLOCK, &sigs, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user