changeset: 4337:4fbcce3f60970b235f789a1071bea2473c879f03
parent: 4329:8a38eea09ab5a1e5a81fde551283d0418a8fa821
user: Mike Sperber <sperber(a)deinprogramm.de>
date: Wed Dec 19 10:21:38 2007 +0100
files: src/ChangeLog src/extw-Xt.c
description:
Don't use undocumented Xt functions in external widget.
2007-12-18 Kenny Chien <Kenny.Chien(a)morganstanley.com>
* extw-Xt.c (extw_wait_for_response): Don't use undocumented
internal Xt functions, avoiding inconsistent behavior between
different Solaris versions.
diff -r 8a38eea09ab5a1e5a81fde551283d0418a8fa821 -r
4fbcce3f60970b235f789a1071bea2473c879f03 src/ChangeLog
--- a/src/ChangeLog Tue Dec 18 15:05:21 2007 +0100
+++ b/src/ChangeLog Wed Dec 19 10:21:38 2007 +0100
@@ -1,3 +1,9 @@ 2007-12-12 Aidan Kehoe <kehoea@parhasa
+2007-12-18 Kenny Chien <Kenny.Chien(a)morganstanley.com>
+
+ * extw-Xt.c (extw_wait_for_response): Don't use undocumented
+ internal Xt functions, avoiding inconsistent behavior between
+ different Solaris versions.
+
2007-12-12 Aidan Kehoe <kehoea(a)parhasard.net>
* config.h.in:
diff -r 8a38eea09ab5a1e5a81fde551283d0418a8fa821 -r
4fbcce3f60970b235f789a1071bea2473c879f03 src/extw-Xt.c
--- a/src/extw-Xt.c Tue Dec 18 15:05:21 2007 +0100
+++ b/src/extw-Xt.c Wed Dec 19 10:21:38 2007 +0100
@@ -37,38 +37,8 @@ static void fatal (char *msg);
#include <X11/IntrinsicP.h>
#include <stdlib.h>
#include <stdio.h>
+#include "compiler.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)
-EXTERN_C 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 _XT_WAIT_FOR_SOMETHING(timers,inputs,events,block,howlong,appCtx) \
- _XtWaitForSomething (appCtx,events,timers,inputs,0,block,howlong)
-# else
-# define _XT_WAIT_FOR_SOMETHING(timers,inputs,events,block,howlong,appCtx) \
- _XtWaitForSomething (appCtx,events,timers,inputs,0,block,1,howlong)
-# endif
-#else
-EXTERN_C int
-_XtwaitForSomething (Boolean ignoreTimers, Boolean ignoreInputs,
- Boolean ignoreEvents, Boolean block,
- unsigned long *howlong, XtAppContext app);
-# define _XT_WAIT_FOR_SOMETHING(timers,inputs,events,block,howlong,appCtx) \
- _XtwaitForSomething (timers,inputs,events,block,howlong,appCtx)
-#endif
#ifdef DEBUG_WIDGET
@@ -181,60 +151,87 @@ extw_get_geometry_value(Display *display
#endif
}
-typedef struct {
- Widget w;
- unsigned long request_num;
- en_extw_notify type;
+typedef struct
+{
+ Widget w;
+ unsigned long request_num;
+ en_extw_notify type;
} QueryStruct;
/* check if an event is of the sort we're looking for */
static Bool
-isMine(Display *dpy, XEvent *event, char *arg)
-{
- 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 &&
- (en_extw_notify) event->xclient.data.l[1] == q->type)
- return TRUE;
- }
- return FALSE;
+isMine(XEvent *event, QueryStruct *q)
+{
+ 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] == (int) q->type)
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void responseTimeOut(XtPointer clientData, XtIntervalId * UNUSED (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);
+ XtInputMask inputMask;
QueryStruct q;
-
- XFlush(XtDisplay(w));
+ Bool expired;
+ XtIntervalId id;
+
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 (_XT_WAIT_FOR_SOMETHING (TRUE, TRUE, FALSE, TRUE, &timeout, app)
- != -1)
- continue;
- if (timeout == 0)
- return FALSE;
- }
-}
+ 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;
+}
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches