The patch attached to my previous mail was incorrect -- it was based
on diffing against a work-in-progress file. Here's the real patch.
--- /ms/dev/fsf/xemacs/21.1.14/src/src/extw-Xt.c Wed Dec 18 17:44:05 1996
+++ extw-Xt.c Fri May 25 17:28:17 2001
@@ -23,6 +23,7 @@
#ifdef emacs
#include <config.h>
+#include <stdio.h>
#ifndef EXTERNAL_WIDGET
ERROR! This ought not be getting compiled if EXTERNAL_WIDGET is undefined
@@ -34,47 +35,10 @@
#endif
#include <X11/Intrinsic.h>
-#include <X11/IntrinsicP.h>
#include <stdlib.h>
#include <stdio.h>
#include "extw-Xt.h"
-/* Yeah, that's portable!
-
- Why the hell didn't the Xt people just export this function
- for real? */
-
-#if (XT_REVISION > 5)
-int _XtWaitForSomething(
- XtAppContext app,
- _XtBoolean ignoreEvents,
- _XtBoolean ignoreTimers,
- _XtBoolean ignoreInputs,
- _XtBoolean ignoreSignals,
- _XtBoolean block,
-#ifdef XTHREADS
- _XtBoolean drop_lock,
-#endif
- unsigned long *howlong);
-
-# ifndef XTHREADS
-# define _XtwaitForSomething(timers,inputs,events,block,howlong,appCtx) \
- _XtWaitForSomething(appCtx,events,timers,inputs,0,block,howlong)
-# else
-# define _XtwaitForSomething(timers,inputs,events,block,howlong,appCtx) \
- _XtWaitForSomething(appCtx,events,timers,inputs,0,block,1,howlong)
-# endif
-#else
-int _XtwaitForSomething(
- Boolean ignoreTimers,
- Boolean ignoreInputs,
- Boolean ignoreEvents,
- Boolean block,
- unsigned long *howlong,
- XtAppContext app
- );
-#endif
-
#ifdef DEBUG_WIDGET
static int geom_masks[] = {
@@ -195,49 +159,77 @@
/* check if an event is of the sort we're looking for */
static Bool
-isMine(Display *dpy, XEvent *event, char *arg)
+isMine(XEvent *event, QueryStruct *q)
{
- QueryStruct *q = (QueryStruct *) arg;
- Widget w = q->w;
-
- if ( (dpy != XtDisplay(w)) || (event->xany.window != XtWindow(w)) ) {
- return FALSE;
- }
- if (event->xany.serial >= q->request_num) {
- if (event->type == ClientMessage &&
- event->xclient.message_type == a_EXTW_NOTIFY &&
- event->xclient.data.l[0] == 1 - extw_which_side &&
- event->xclient.data.l[1] == q->type)
- return TRUE;
- }
- return FALSE;
+ Widget w = q->w;
+
+ if ( (event->xany.display != XtDisplay(w)) || (event->xany.window != XtWindow(w))
)
+ {
+ return FALSE;
+ }
+ if (event->xany.serial >= q->request_num)
+ {
+ if (event->type == ClientMessage &&
+ event->xclient.message_type == a_EXTW_NOTIFY &&
+ event->xclient.data.l[0] == 1 - extw_which_side &&
+ event->xclient.data.l[1] == q->type)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void responseTimeOut(XtPointer clientData,XtIntervalId *id)
+{
+ Bool *expired=(Bool *)clientData;
+ *expired=TRUE;
}
/* wait for a ClientMessage of the specified type from the other widget, or
- time-out. isMine() determines whether an event matches. Culled from
- Shell.c. */
+ time-out. isMine() determines whether an event matches.
+ Took out the call to _XtWaitForSomething and replaced it with public
+ Xt api's.
+*/
Bool
extw_wait_for_response(Widget w, XEvent *event, unsigned long request_num,
en_extw_notify type, unsigned long timeout)
{
- XtAppContext app = XtWidgetToApplicationContext(w);
- QueryStruct q;
-
- XFlush(XtDisplay(w));
- q.w = w;
- q.request_num = request_num;
- q.type = type;
-
- for(;;) {
- /*
- * look for match event
- */
- if (XCheckIfEvent( XtDisplay(w), event, isMine, (char*)&q))
- return TRUE;
- if (_XtwaitForSomething(TRUE, TRUE, FALSE, TRUE, &timeout, app)
- != -1) continue;
- if (timeout == 0)
- return FALSE;
- }
+ XtAppContext app = XtWidgetToApplicationContext(w);
+ XtInputMask inputMask;
+ QueryStruct q;
+ Bool expired;
+ XtIntervalId id;
+
+ q.w = w;
+ q.request_num = request_num;
+ q.type = type;
+ expired=FALSE;
+
+ id=XtAppAddTimeOut(app,timeout,responseTimeOut,&expired);
+ while (!expired)
+ {
+ inputMask=XtAppPending(app);
+ if (inputMask & XtIMXEvent)
+ {
+ XtAppNextEvent(app,event);
+ if (isMine(event,&q))
+ {
+ if (!expired) XtRemoveTimeOut(id);
+ return True;
+ }
+ else
+ {
+ /* Do Nothing and go back to waiting */
+ }
+ }
+ if (inputMask & XtIMTimer)
+ {
+ /* Process the expired timer */
+ XtAppProcessEvent(app,XtIMTimer);
+ }
+ }
+ /* Must have expired */
+ return False;
}
--
Isaac Hollander Morgan Stanley Dean Witter
isaac.hollander(a)morganstanley.com 1585 Broadway, 2nd floor
(212) 761 3417 New York, NY