From 1d56ad7615e28bd0c02ff82546713af3d8a2cbdf Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 17 Nov 1999 22:01:33 +0000 Subject: [PATCH] - Fixed problem calling W_FlushIdleNotificationQueue() when there was no idle handler installed. - Fixed some problem with ASAP notification queues - fixed a memleak related to notification queues. --- WINGs/notification.c | 9 +++++---- WINGs/wevent.c | 20 ++++++++------------ WINGs/wutil.c | 18 +++++++++--------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/WINGs/notification.c b/WINGs/notification.c index d1475823..3c3e379b 100644 --- a/WINGs/notification.c +++ b/WINGs/notification.c @@ -217,8 +217,6 @@ WMPostNotification(WMNotification *notification) } WMReleaseNotification(notification); - - W_FlushASAPNotificationQueue(); } @@ -491,7 +489,8 @@ WMEnqueueCoalesceNotification(WMNotificationQueue *queue, switch (postingStyle) { case WMPostNow: WMPostNotification(notification); - break; + WMReleaseNotification(notification); + break; case WMPostASAP: WMPutInBag(queue->asapQueue, notification); @@ -514,7 +513,8 @@ W_FlushASAPNotificationQueue() WMNotification *tmp = WMGetFromBag(queue->asapQueue, 0); WMPostNotification(tmp); - WMDeleteFromBag(queue->asapQueue, 0); + WMReleaseNotification(tmp); + WMDeleteFromBag(queue->asapQueue, 0); } queue = queue->next; @@ -532,6 +532,7 @@ W_FlushIdleNotificationQueue() WMNotification *tmp = WMGetFromBag(queue->idleQueue, 0); WMPostNotification(tmp); + WMReleaseNotification(tmp); WMDeleteFromBag(queue->idleQueue, 0); } diff --git a/WINGs/wevent.c b/WINGs/wevent.c index 7d91e5d7..e5a19245 100644 --- a/WINGs/wevent.c +++ b/WINGs/wevent.c @@ -327,7 +327,9 @@ checkIdleHandlers() IdleHandler *handler, *tmp; if (!idleHandler) { - return False; + W_FlushIdleNotificationQueue(); + /* make sure an observer in queue didn't added an idle handler */ + return (idleHandler!=NULL); } handler = idleHandler; @@ -343,8 +345,11 @@ checkIdleHandlers() handler = tmp; } - - return True; + + W_FlushIdleNotificationQueue(); + + /* this is not necesarrily False, because one handler can re-add itself */ + return (idleHandler!=NULL); } @@ -922,9 +927,6 @@ WMNextEvent(Display *dpy, XEvent *event) /* Do idle stuff */ /* Do idle and timer stuff while there are no timer or X events */ while (!XPending(dpy) && checkIdleHandlers()) { - - W_FlushIdleNotificationQueue(); - /* dispatch timer events */ if (timerPending()) checkTimerHandlers(); @@ -959,9 +961,6 @@ WMMaskEvent(Display *dpy, long mask, XEvent *event) while (!XCheckMaskEvent(dpy, mask, event)) { /* Do idle stuff while there are no timer or X events */ while (checkIdleHandlers()) { - - W_FlushIdleNotificationQueue(); - if (XCheckMaskEvent(dpy, mask, event)) return; } @@ -1007,9 +1006,6 @@ WMMaskEvent(Display *dpy, long mask, XEvent *event) while (!XCheckMaskEvent(dpy, mask, event)) { /* Do idle stuff while there are no timer or X events */ while (checkIdleHandlers()) { - - W_FlushIdleNotificationQueue(); - if (XCheckMaskEvent(dpy, mask, event)) return; } diff --git a/WINGs/wutil.c b/WINGs/wutil.c index 81296387..3ab91e60 100644 --- a/WINGs/wutil.c +++ b/WINGs/wutil.c @@ -67,8 +67,6 @@ static InputHandler *inputHandler=NULL; #define timerPending() (timerHandler) -#define idlePending() (idleHandler) - static void rightNow(struct timeval *tv) { @@ -274,14 +272,15 @@ WMDeleteInputHandler(WMHandlerID handlerID) } -static void +static Bool checkIdleHandlers() { IdleHandler *handler, *tmp; if (!idleHandler) { W_FlushIdleNotificationQueue(); - return; + /* make sure an observer in queue didn't added an idle handler */ + return (idleHandler!=NULL); } handler = idleHandler; @@ -297,7 +296,11 @@ checkIdleHandlers() handler = tmp; } + W_FlushIdleNotificationQueue(); + + /* this is not necesarrily False, because one handler can re-add itself */ + return (idleHandler!=NULL); } @@ -563,16 +566,13 @@ WHandleEvents() */ if (inputHandler) { /* Do idle and timer stuff while there are no input events */ - while (idlePending() && inputHandler && !handleInputEvents(False)) { - if (idlePending()) - checkIdleHandlers(); + while (checkIdleHandlers() && inputHandler && !handleInputEvents(False)) { /* dispatch timer events */ if (timerPending()) checkTimerHandlers(); } } else { - if (idlePending()) - checkIdleHandlers(); + checkIdleHandlers(); /* dispatch timer events */ if (timerPending()) checkTimerHandlers(); -- 2.11.4.GIT