Mercurial > hg > xemacs-beta
comparison src/extw-Xt.c @ 2108:8de911beca70
[xemacs-hg @ 2004-06-02 09:16:14 by didierv]
C++ related fixes
author | didierv |
---|---|
date | Wed, 02 Jun 2004 09:16:21 +0000 |
parents | 4f4c898836ab |
children | f18c80177dfe |
comparison
equal
deleted
inserted
replaced
2107:91e93aba4aae | 2108:8de911beca70 |
---|---|
26 | 26 |
27 #ifndef EXTERNAL_WIDGET | 27 #ifndef EXTERNAL_WIDGET |
28 ERROR! This ought not be getting compiled if EXTERNAL_WIDGET is undefined | 28 ERROR! This ought not be getting compiled if EXTERNAL_WIDGET is undefined |
29 #endif | 29 #endif |
30 | 30 |
31 EXTERN_C | |
32 { | |
31 void fatal (const char *fmt, ...); | 33 void fatal (const char *fmt, ...); |
34 } | |
32 #else /* not emacs */ | 35 #else /* not emacs */ |
33 static void fatal (char *msg); | 36 static void fatal (char *msg); |
34 #endif | 37 #endif |
35 | 38 |
36 #include <X11/Intrinsic.h> | 39 #include <X11/Intrinsic.h> |
43 | 46 |
44 Why the hell didn't the Xt people just export this function | 47 Why the hell didn't the Xt people just export this function |
45 for real? */ | 48 for real? */ |
46 | 49 |
47 #if (XT_REVISION > 5) | 50 #if (XT_REVISION > 5) |
48 int _XtWaitForSomething( | 51 EXTERN_C |
49 XtAppContext app, | 52 { |
50 _XtBoolean ignoreEvents, | 53 int _XtWaitForSomething (XtAppContext app, _XtBoolean ignoreEvents, |
51 _XtBoolean ignoreTimers, | 54 _XtBoolean ignoreTimers, _XtBoolean ignoreInputs, |
52 _XtBoolean ignoreInputs, | 55 _XtBoolean ignoreSignals, _XtBoolean block, |
53 _XtBoolean ignoreSignals, | |
54 _XtBoolean block, | |
55 #ifdef XTHREADS | 56 #ifdef XTHREADS |
56 _XtBoolean drop_lock, | 57 _XtBoolean drop_lock, |
57 #endif | 58 #endif |
58 unsigned long *howlong); | 59 unsigned long *howlong); |
60 } | |
59 | 61 |
60 # ifndef XTHREADS | 62 # ifndef XTHREADS |
61 # define _XtwaitForSomething(timers,inputs,events,block,howlong,appCtx) \ | 63 # define _XT_WAIT_FOR_SOMETHING(timers,inputs,events,block,howlong,appCtx) \ |
62 _XtWaitForSomething(appCtx,events,timers,inputs,0,block,howlong) | 64 _XtWaitForSomething (appCtx,events,timers,inputs,0,block,howlong) |
63 # else | 65 # else |
64 # define _XtwaitForSomething(timers,inputs,events,block,howlong,appCtx) \ | 66 # define _XT_WAIT_FOR_SOMETHING(timers,inputs,events,block,howlong,appCtx) \ |
65 _XtWaitForSomething(appCtx,events,timers,inputs,0,block,1,howlong) | 67 _XtWaitForSomething (appCtx,events,timers,inputs,0,block,1,howlong) |
66 # endif | 68 # endif |
67 #else | 69 #else |
68 int _XtwaitForSomething( | 70 EXTERN_C |
69 Boolean ignoreTimers, | 71 { |
70 Boolean ignoreInputs, | 72 int _XtwaitForSomething (Boolean ignoreTimers, Boolean ignoreInputs, |
71 Boolean ignoreEvents, | 73 Boolean ignoreEvents, Boolean block, |
72 Boolean block, | 74 unsigned long *howlong, XtAppContext app); |
73 unsigned long *howlong, | 75 } |
74 XtAppContext app | |
75 ); | |
76 #endif | 76 #endif |
77 | 77 |
78 #ifdef DEBUG_WIDGET | 78 #ifdef DEBUG_WIDGET |
79 | 79 |
80 static int geom_masks[] = { | 80 static int geom_masks[] = { |
91 static void | 91 static void |
92 print_geometry_structure(XtWidgetGeometry *xwg) | 92 print_geometry_structure(XtWidgetGeometry *xwg) |
93 { | 93 { |
94 int num = sizeof(geom_masks)/sizeof(int); | 94 int num = sizeof(geom_masks)/sizeof(int); |
95 int i; | 95 int i; |
96 | 96 |
97 printf (" masks:"); | 97 printf (" masks:"); |
98 for (i=0; i<num; i++) | 98 for (i=0; i<num; i++) |
99 if (xwg->request_mode & geom_masks[i]) | 99 if (xwg->request_mode & geom_masks[i]) |
100 printf (" %s", geom_mask_strings[i]); | 100 printf (" %s", geom_mask_strings[i]); |
101 printf ("\n"); | 101 printf ("\n"); |
161 { | 161 { |
162 Atom dummy; | 162 Atom dummy; |
163 int format; | 163 int format; |
164 unsigned long nitems, bytes_after; | 164 unsigned long nitems, bytes_after; |
165 unsigned char *prop; | 165 unsigned char *prop; |
166 | 166 |
167 if (XGetWindowProperty(display, win, property, 0, | 167 if (XGetWindowProperty(display, win, property, 0, |
168 sizeof(*xwg)/4, False, a_EXTW_WIDGET_GEOMETRY, | 168 sizeof(*xwg)/4, False, a_EXTW_WIDGET_GEOMETRY, |
169 &dummy, &format, &nitems, &bytes_after, | 169 &dummy, &format, &nitems, &bytes_after, |
170 &prop) != Success) | 170 &prop) != Success) |
171 goto error; | 171 goto error; |
197 static Bool | 197 static Bool |
198 isMine(Display *dpy, XEvent *event, char *arg) | 198 isMine(Display *dpy, XEvent *event, char *arg) |
199 { | 199 { |
200 QueryStruct *q = (QueryStruct *) arg; | 200 QueryStruct *q = (QueryStruct *) arg; |
201 Widget w = q->w; | 201 Widget w = q->w; |
202 | 202 |
203 if ( (dpy != XtDisplay(w)) || (event->xany.window != XtWindow(w)) ) { | 203 if ( (dpy != XtDisplay(w)) || (event->xany.window != XtWindow(w)) ) { |
204 return FALSE; | 204 return FALSE; |
205 } | 205 } |
206 if (event->xany.serial >= q->request_num) { | 206 if (event->xany.serial >= q->request_num) { |
207 if (event->type == ClientMessage && | 207 if (event->type == ClientMessage && |
216 /* wait for a ClientMessage of the specified type from the other widget, or | 216 /* wait for a ClientMessage of the specified type from the other widget, or |
217 time-out. isMine() determines whether an event matches. Culled from | 217 time-out. isMine() determines whether an event matches. Culled from |
218 Shell.c. */ | 218 Shell.c. */ |
219 | 219 |
220 Bool | 220 Bool |
221 extw_wait_for_response(Widget w, XEvent *event, unsigned long request_num, | 221 extw_wait_for_response (Widget w, XEvent *event, unsigned long request_num, |
222 en_extw_notify type, unsigned long timeout) | 222 en_extw_notify type, unsigned long timeout) |
223 { | 223 { |
224 XtAppContext app = XtWidgetToApplicationContext(w); | 224 XtAppContext app = XtWidgetToApplicationContext(w); |
225 QueryStruct q; | 225 QueryStruct q; |
226 | 226 |
227 XFlush(XtDisplay(w)); | 227 XFlush(XtDisplay(w)); |
228 q.w = w; | 228 q.w = w; |
229 q.request_num = request_num; | 229 q.request_num = request_num; |
230 q.type = type; | 230 q.type = type; |
231 | 231 |
232 for(;;) { | 232 for(;;) |
233 /* | 233 { |
234 * look for match event | 234 /* |
235 */ | 235 * look for match event |
236 if (XCheckIfEvent( XtDisplay(w), event, isMine, (char*)&q)) | 236 */ |
237 return TRUE; | 237 if (XCheckIfEvent (XtDisplay(w), event, isMine, (char*)&q)) |
238 if (_XtwaitForSomething(TRUE, TRUE, FALSE, TRUE, &timeout, app) | 238 return TRUE; |
239 != -1) continue; | 239 if (_XT_WAIT_FOR_SOMETHING (TRUE, TRUE, FALSE, TRUE, &timeout, app) |
240 if (timeout == 0) | 240 != -1) |
241 return FALSE; | 241 continue; |
242 } | 242 if (timeout == 0) |
243 } | 243 return FALSE; |
244 } | |
245 } |