From 1a3fd2f79571828a10c99a396b6f2e969801dd25 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 22 Mar 2001 00:56:09 +0000 Subject: [PATCH] - better and more robust handling of events (timer, idle, input, X) in WMMaskEvent() - fixed a bug where input and timer events were not treated for undefined periods of time under some circumstances. --- WINGs/ChangeLog | 4 +++- WINGs/wevent.c | 36 +++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index 645443af..400f5930 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -13,7 +13,9 @@ Changes since wmaker 0.64.0: and X events (also fixed some problems the old handling logic had) - moved timer, dile and input handler definitions and prototypes from WINGs.h to WUtil.h because they're not GUI related. - +- better and more robust handling of events (timer, idle, input, X) in + WMMaskEvent(). Also fixed a bug where input and timer events were not + treated for undefined periods of time under some circumstances. changes since wmaker 0.63.1: ............................ diff --git a/WINGs/wevent.c b/WINGs/wevent.c index a4884c99..f2f8fa9c 100644 --- a/WINGs/wevent.c +++ b/WINGs/wevent.c @@ -382,9 +382,19 @@ WMIsDoubleClick(XEvent *event) /* - * If waitForInput is False, it will just peek to see if input is available - * then return without processing input but the return value will show - * if input is available or not. + * Check for X and input events. If X events are present input events will + * not be checked. + * + * Return value: True if a X event is available or any input event was + * processed, false otherwise (including return because of + * some timer handler expired). + * + * If waitForInput is False, it will just peek for available input and return + * without processing. Return vaue will be True if input is available. + * + * If waitForInput is True, it will wait until an input event arrives on the + * registered input handlers and ConnectionNumber(dpy), or will return when + * a timer handler expires if no input event arrived until then. */ static Bool waitForEvent(Display *dpy, unsigned long xeventmask, Bool waitForInput) @@ -407,12 +417,12 @@ waitForEvent(Display *dpy, unsigned long xeventmask, Bool waitForInput) void WMNextEvent(Display *dpy, XEvent *event) -{ +{ /* Check any expired timers */ W_CheckTimerHandlers(); while (XPending(dpy) == 0) { - /* Do idle and timer stuff while there are no timer or X events */ + /* Do idle and timer stuff while there are no input or X events */ while (!waitForEvent(dpy, 0, False) && W_CheckIdleHandlers()) { /* dispatch timer events */ W_CheckTimerHandlers(); @@ -435,6 +445,9 @@ WMNextEvent(Display *dpy, XEvent *event) /* + * Is this comment still valid? + * waitForEvent seems now to understand masked events. -Dan + * * Cant use this because XPending() will make waitForEvent * return even if the event in the queue is not what we want, * and if we block until some new event arrives from the @@ -444,13 +457,18 @@ WMNextEvent(Display *dpy, XEvent *event) void WMMaskEvent(Display *dpy, long mask, XEvent *event) { + /* Check any expired timers */ + W_CheckTimerHandlers(); + while (!XCheckMaskEvent(dpy, mask, event)) { - /* Do idle stuff while there are no timer or X events */ - while (W_CheckIdleHandlers()) { - if (XCheckMaskEvent(dpy, mask, event)) - return; + /* Do idle and timer stuff while there are no input or X events */ + while (!waitForEvent(dpy, mask, False) && W_CheckIdleHandlers()) { + W_CheckTimerHandlers(); } + if (XCheckMaskEvent(dpy, mask, event)) + return; + /* Wait for input on the X connection socket or another input handler */ waitForEvent(dpy, mask, True); -- 2.11.4.GIT