XTest.c revision ea133fd7
1a253d6aeSmrg/* $Xorg: XTest.c,v 1.5 2001/02/09 02:04:00 xorgcvs Exp $ */ 2a253d6aeSmrg/* 3a253d6aeSmrgCopyright 1990, 1991 by UniSoft Group Limited 4a253d6aeSmrg*/ 5a253d6aeSmrg 6a253d6aeSmrg/* 7a253d6aeSmrg 8a253d6aeSmrgCopyright 1992, 1993, 1998 The Open Group 9a253d6aeSmrg 10a253d6aeSmrgPermission to use, copy, modify, distribute, and sell this software and its 11a253d6aeSmrgdocumentation for any purpose is hereby granted without fee, provided that 12a253d6aeSmrgthe above copyright notice appear in all copies and that both that 13a253d6aeSmrgcopyright notice and this permission notice appear in supporting 14a253d6aeSmrgdocumentation. 15a253d6aeSmrg 16a253d6aeSmrgThe above copyright notice and this permission notice shall be included 17a253d6aeSmrgin all copies or substantial portions of the Software. 18a253d6aeSmrg 19a253d6aeSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20a253d6aeSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21a253d6aeSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22a253d6aeSmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 23a253d6aeSmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24a253d6aeSmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25a253d6aeSmrgOTHER DEALINGS IN THE SOFTWARE. 26a253d6aeSmrg 27a253d6aeSmrgExcept as contained in this notice, the name of The Open Group shall 28a253d6aeSmrgnot be used in advertising or otherwise to promote the sale, use or 29a253d6aeSmrgother dealings in this Software without prior written authorization 30a253d6aeSmrgfrom The Open Group. 31a253d6aeSmrg 32a253d6aeSmrg*/ 33a253d6aeSmrg/* $XFree86: xc/lib/Xtst/XTest.c,v 1.5 2001/12/14 19:56:40 dawes Exp $ */ 34a253d6aeSmrg 35a253d6aeSmrg#define NEED_REPLIES 36a253d6aeSmrg#include <X11/Xlibint.h> 37a253d6aeSmrg#include <X11/extensions/XTest.h> 38ea133fd7Smrg#include <X11/extensions/xtestproto.h> 39a253d6aeSmrg#include <X11/extensions/Xext.h> 40a253d6aeSmrg#include <X11/extensions/extutil.h> 41a253d6aeSmrg#include <X11/extensions/XInput.h> 42a253d6aeSmrg#include <X11/extensions/XIproto.h> 43a253d6aeSmrg 44a253d6aeSmrgstatic XExtensionInfo _xtest_info_data; 45a253d6aeSmrgstatic XExtensionInfo *xtest_info = &_xtest_info_data; 46a253d6aeSmrgstatic /* const */ char *xtest_extension_name = XTestExtensionName; 47a253d6aeSmrg 48a253d6aeSmrg#define XTestCheckExtension(dpy,i,val) \ 49a253d6aeSmrg XextCheckExtension (dpy, i, xtest_extension_name, val) 50a253d6aeSmrg 51a253d6aeSmrg#define XTestICheckExtension(dpy,i,val) \ 52a253d6aeSmrg XextCheckExtension (dpy, i, xtest_extension_name, val); \ 53a253d6aeSmrg if (!i->data) return val 54a253d6aeSmrg 55a253d6aeSmrg/***************************************************************************** 56a253d6aeSmrg * * 57a253d6aeSmrg * private utility routines * 58a253d6aeSmrg * * 59a253d6aeSmrg *****************************************************************************/ 60a253d6aeSmrg 61a253d6aeSmrgstatic int close_display(Display *dpy, XExtCodes *codes); 62a253d6aeSmrgstatic /* const */ XExtensionHooks xtest_extension_hooks = { 63a253d6aeSmrg NULL, /* create_gc */ 64a253d6aeSmrg NULL, /* copy_gc */ 65a253d6aeSmrg NULL, /* flush_gc */ 66a253d6aeSmrg NULL, /* free_gc */ 67a253d6aeSmrg NULL, /* create_font */ 68a253d6aeSmrg NULL, /* free_font */ 69a253d6aeSmrg close_display, /* close_display */ 70a253d6aeSmrg NULL, /* wire_to_event */ 71a253d6aeSmrg NULL, /* event_to_wire */ 72a253d6aeSmrg NULL, /* error */ 73a253d6aeSmrg NULL /* error_string */ 74a253d6aeSmrg}; 75a253d6aeSmrg 76a253d6aeSmrgstatic XPointer 77a253d6aeSmrgget_xinput_base(Display *dpy) 78a253d6aeSmrg{ 79a253d6aeSmrg int major_opcode, first_event, first_error; 80a253d6aeSmrg first_event = 0; 81a253d6aeSmrg 82a253d6aeSmrg XQueryExtension(dpy, INAME, &major_opcode, &first_event, &first_error); 83a253d6aeSmrg return (XPointer)(long)first_event; 84a253d6aeSmrg} 85a253d6aeSmrg 86a253d6aeSmrgstatic XEXT_GENERATE_FIND_DISPLAY (find_display, xtest_info, 87a253d6aeSmrg xtest_extension_name, 88a253d6aeSmrg &xtest_extension_hooks, XTestNumberEvents, 89a253d6aeSmrg get_xinput_base(dpy)) 90a253d6aeSmrg 91a253d6aeSmrgstatic XEXT_GENERATE_CLOSE_DISPLAY (close_display, xtest_info) 92a253d6aeSmrg 93a253d6aeSmrg/***************************************************************************** 94a253d6aeSmrg * * 95a253d6aeSmrg * public routines * 96a253d6aeSmrg * * 97a253d6aeSmrg *****************************************************************************/ 98a253d6aeSmrg 99a253d6aeSmrgBool 100ea133fd7SmrgXTestQueryExtension (Display *dpy, 101ea133fd7Smrg int *event_base_return, int *error_base_return, 102ea133fd7Smrg int *major_return, int *minor_return) 103a253d6aeSmrg{ 104a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 105a253d6aeSmrg register xXTestGetVersionReq *req; 106a253d6aeSmrg xXTestGetVersionReply rep; 107a253d6aeSmrg 108a253d6aeSmrg if (XextHasExtension(info)) { 109a253d6aeSmrg LockDisplay(dpy); 110a253d6aeSmrg GetReq(XTestGetVersion, req); 111a253d6aeSmrg req->reqType = info->codes->major_opcode; 112a253d6aeSmrg req->xtReqType = X_XTestGetVersion; 113a253d6aeSmrg req->majorVersion = XTestMajorVersion; 114a253d6aeSmrg req->minorVersion = XTestMinorVersion; 115a253d6aeSmrg if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 116a253d6aeSmrg UnlockDisplay(dpy); 117a253d6aeSmrg SyncHandle(); 118a253d6aeSmrg return False; 119a253d6aeSmrg } 120a253d6aeSmrg UnlockDisplay(dpy); 121a253d6aeSmrg SyncHandle(); 122ea133fd7Smrg *event_base_return = info->codes->first_event; 123ea133fd7Smrg *error_base_return = info->codes->first_error; 124ea133fd7Smrg *major_return = rep.majorVersion; 125ea133fd7Smrg *minor_return = rep.minorVersion; 126a253d6aeSmrg return True; 127a253d6aeSmrg } else { 128a253d6aeSmrg return False; 129a253d6aeSmrg } 130a253d6aeSmrg} 131a253d6aeSmrg 132a253d6aeSmrgBool 133ea133fd7SmrgXTestCompareCursorWithWindow(Display *dpy, Window window, Cursor cursor) 134a253d6aeSmrg{ 135a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 136a253d6aeSmrg register xXTestCompareCursorReq *req; 137a253d6aeSmrg xXTestCompareCursorReply rep; 138a253d6aeSmrg 139a253d6aeSmrg XTestCheckExtension (dpy, info, 0); 140a253d6aeSmrg 141a253d6aeSmrg LockDisplay(dpy); 142a253d6aeSmrg GetReq(XTestCompareCursor, req); 143a253d6aeSmrg req->reqType = info->codes->major_opcode; 144a253d6aeSmrg req->xtReqType = X_XTestCompareCursor; 145a253d6aeSmrg req->window = window; 146a253d6aeSmrg req->cursor = cursor; 147a253d6aeSmrg if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { 148a253d6aeSmrg UnlockDisplay(dpy); 149a253d6aeSmrg SyncHandle(); 150a253d6aeSmrg return False; 151a253d6aeSmrg } 152a253d6aeSmrg UnlockDisplay(dpy); 153a253d6aeSmrg SyncHandle(); 154a253d6aeSmrg return rep.same; 155a253d6aeSmrg} 156a253d6aeSmrg 157a253d6aeSmrgBool 158ea133fd7SmrgXTestCompareCurrentCursorWithWindow(Display *dpy, Window window) 159a253d6aeSmrg{ 160a253d6aeSmrg return XTestCompareCursorWithWindow(dpy, window, XTestCurrentCursor); 161a253d6aeSmrg} 162a253d6aeSmrg 163a253d6aeSmrgint 164ea133fd7SmrgXTestFakeKeyEvent(Display *dpy, unsigned int keycode, 165ea133fd7Smrg Bool is_press, unsigned long delay) 166a253d6aeSmrg{ 167a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 168a253d6aeSmrg register xXTestFakeInputReq *req; 169a253d6aeSmrg 170a253d6aeSmrg XTestCheckExtension (dpy, info, 0); 171a253d6aeSmrg 172a253d6aeSmrg LockDisplay(dpy); 173a253d6aeSmrg GetReq(XTestFakeInput, req); 174a253d6aeSmrg req->reqType = info->codes->major_opcode; 175a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 176a253d6aeSmrg req->type = is_press ? KeyPress : KeyRelease; 177a253d6aeSmrg req->detail = keycode; 178a253d6aeSmrg req->time = delay; 179a253d6aeSmrg UnlockDisplay(dpy); 180a253d6aeSmrg SyncHandle(); 181a253d6aeSmrg return 1; 182a253d6aeSmrg} 183a253d6aeSmrg 184a253d6aeSmrgint 185ea133fd7SmrgXTestFakeButtonEvent(Display *dpy, unsigned int button, 186ea133fd7Smrg Bool is_press, unsigned long delay) 187a253d6aeSmrg{ 188a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 189a253d6aeSmrg register xXTestFakeInputReq *req; 190a253d6aeSmrg 191a253d6aeSmrg XTestCheckExtension (dpy, info, 0); 192a253d6aeSmrg 193a253d6aeSmrg LockDisplay(dpy); 194a253d6aeSmrg GetReq(XTestFakeInput, req); 195a253d6aeSmrg req->reqType = info->codes->major_opcode; 196a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 197a253d6aeSmrg req->type = is_press ? ButtonPress : ButtonRelease; 198a253d6aeSmrg req->detail = button; 199a253d6aeSmrg req->time = delay; 200a253d6aeSmrg UnlockDisplay(dpy); 201a253d6aeSmrg SyncHandle(); 202a253d6aeSmrg return 1; 203a253d6aeSmrg} 204a253d6aeSmrg 205a253d6aeSmrgint 206ea133fd7SmrgXTestFakeMotionEvent(Display *dpy, int screen, int x, int y, unsigned long delay) 207a253d6aeSmrg{ 208a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 209a253d6aeSmrg register xXTestFakeInputReq *req; 210a253d6aeSmrg 211a253d6aeSmrg XTestCheckExtension (dpy, info, 0); 212a253d6aeSmrg 213a253d6aeSmrg LockDisplay(dpy); 214a253d6aeSmrg GetReq(XTestFakeInput, req); 215a253d6aeSmrg req->reqType = info->codes->major_opcode; 216a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 217a253d6aeSmrg req->type = MotionNotify; 218a253d6aeSmrg req->detail = False; 219a253d6aeSmrg if (screen == -1) 220a253d6aeSmrg req->root = None; 221a253d6aeSmrg else 222a253d6aeSmrg req->root = RootWindow(dpy, screen); 223a253d6aeSmrg req->rootX = x; 224a253d6aeSmrg req->rootY = y; 225a253d6aeSmrg req->time = delay; 226a253d6aeSmrg UnlockDisplay(dpy); 227a253d6aeSmrg SyncHandle(); 228a253d6aeSmrg return 1; 229a253d6aeSmrg} 230a253d6aeSmrg 231a253d6aeSmrgint 232ea133fd7SmrgXTestFakeRelativeMotionEvent(Display *dpy, int dx, int dy, unsigned long delay) 233a253d6aeSmrg{ 234a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 235a253d6aeSmrg register xXTestFakeInputReq *req; 236a253d6aeSmrg 237a253d6aeSmrg XTestCheckExtension (dpy, info, 0); 238a253d6aeSmrg 239a253d6aeSmrg LockDisplay(dpy); 240a253d6aeSmrg GetReq(XTestFakeInput, req); 241a253d6aeSmrg req->reqType = info->codes->major_opcode; 242a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 243a253d6aeSmrg req->type = MotionNotify; 244a253d6aeSmrg req->detail = True; 245a253d6aeSmrg req->root = None; 246a253d6aeSmrg req->rootX = dx; 247a253d6aeSmrg req->rootY = dy; 248a253d6aeSmrg req->time = delay; 249a253d6aeSmrg UnlockDisplay(dpy); 250a253d6aeSmrg SyncHandle(); 251a253d6aeSmrg return 1; 252a253d6aeSmrg} 253a253d6aeSmrg 254a253d6aeSmrgstatic void 255a253d6aeSmrgsend_axes( 256a253d6aeSmrg Display *dpy, 257a253d6aeSmrg XExtDisplayInfo *info, 258a253d6aeSmrg xXTestFakeInputReq *req, 259a253d6aeSmrg XDevice *dev, 260a253d6aeSmrg int first_axis, 261a253d6aeSmrg int *axes, 262a253d6aeSmrg int n_axes) 263a253d6aeSmrg{ 264a253d6aeSmrg deviceValuator ev; 265a253d6aeSmrg int n; 266a253d6aeSmrg 267a253d6aeSmrg req->deviceid |= MORE_EVENTS; 268a253d6aeSmrg req->length += ((n_axes + 5) / 6) * (SIZEOF(xEvent) >> 2); 269a253d6aeSmrg ev.type = XI_DeviceValuator + (long)info->data; 270a253d6aeSmrg ev.deviceid = dev->device_id; 271a253d6aeSmrg ev.num_valuators = n_axes; 272a253d6aeSmrg ev.first_valuator = first_axis; 273a253d6aeSmrg while (n_axes > 0) { 274a253d6aeSmrg n = n_axes; 275a253d6aeSmrg if (n > 6) 276a253d6aeSmrg n = 6; 277a253d6aeSmrg switch (n) { 278a253d6aeSmrg case 6: 279a253d6aeSmrg ev.valuator5 = *(axes+5); 280a253d6aeSmrg case 5: 281a253d6aeSmrg ev.valuator4 = *(axes+4); 282a253d6aeSmrg case 4: 283a253d6aeSmrg ev.valuator3 = *(axes+3); 284a253d6aeSmrg case 3: 285a253d6aeSmrg ev.valuator2 = *(axes+2); 286a253d6aeSmrg case 2: 287a253d6aeSmrg ev.valuator1 = *(axes+1); 288a253d6aeSmrg case 1: 289a253d6aeSmrg ev.valuator0 = *axes; 290a253d6aeSmrg } 291a253d6aeSmrg Data(dpy, (char *)&ev, SIZEOF(xEvent)); 292a253d6aeSmrg axes += n; 293a253d6aeSmrg n_axes -= n; 294a253d6aeSmrg ev.first_valuator += n; 295a253d6aeSmrg } 296a253d6aeSmrg} 297a253d6aeSmrg 298a253d6aeSmrgint 299ea133fd7SmrgXTestFakeDeviceKeyEvent(Display *dpy, XDevice *dev, 300ea133fd7Smrg unsigned int keycode, Bool is_press, 301ea133fd7Smrg int *axes, int n_axes, unsigned long delay) 302a253d6aeSmrg{ 303a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 304a253d6aeSmrg register xXTestFakeInputReq *req; 305a253d6aeSmrg 306a253d6aeSmrg XTestICheckExtension (dpy, info, 0); 307a253d6aeSmrg 308a253d6aeSmrg LockDisplay(dpy); 309a253d6aeSmrg GetReq(XTestFakeInput, req); 310a253d6aeSmrg req->reqType = info->codes->major_opcode; 311a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 312a253d6aeSmrg req->type = is_press ? XI_DeviceKeyPress : XI_DeviceKeyRelease; 313a253d6aeSmrg req->type += (int)(long)info->data; 314a253d6aeSmrg req->detail = keycode; 315a253d6aeSmrg req->time = delay; 316a253d6aeSmrg req->deviceid = dev->device_id; 317a253d6aeSmrg if (n_axes) 318a253d6aeSmrg send_axes(dpy, info, req, dev, 0, axes, n_axes); 319a253d6aeSmrg UnlockDisplay(dpy); 320a253d6aeSmrg SyncHandle(); 321a253d6aeSmrg return 1; 322a253d6aeSmrg} 323a253d6aeSmrg 324a253d6aeSmrgint 325ea133fd7SmrgXTestFakeDeviceButtonEvent(Display *dpy, XDevice *dev, 326ea133fd7Smrg unsigned int button, Bool is_press, 327ea133fd7Smrg int *axes, int n_axes, unsigned long delay) 328a253d6aeSmrg{ 329a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 330a253d6aeSmrg register xXTestFakeInputReq *req; 331a253d6aeSmrg 332a253d6aeSmrg XTestICheckExtension (dpy, info, 0); 333a253d6aeSmrg 334a253d6aeSmrg LockDisplay(dpy); 335a253d6aeSmrg GetReq(XTestFakeInput, req); 336a253d6aeSmrg req->reqType = info->codes->major_opcode; 337a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 338a253d6aeSmrg req->type = is_press ? XI_DeviceButtonPress : XI_DeviceButtonRelease; 339a253d6aeSmrg req->type += (int)(long)info->data; 340a253d6aeSmrg req->detail = button; 341a253d6aeSmrg req->time = delay; 342a253d6aeSmrg req->deviceid = dev->device_id; 343a253d6aeSmrg if (n_axes) 344a253d6aeSmrg send_axes(dpy, info, req, dev, 0, axes, n_axes); 345a253d6aeSmrg UnlockDisplay(dpy); 346a253d6aeSmrg SyncHandle(); 347a253d6aeSmrg return 1; 348a253d6aeSmrg} 349a253d6aeSmrg 350a253d6aeSmrgint 351ea133fd7SmrgXTestFakeProximityEvent(Display *dpy, XDevice *dev, Bool in_prox, 352ea133fd7Smrg int *axes, int n_axes, unsigned long delay) 353a253d6aeSmrg{ 354a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 355a253d6aeSmrg register xXTestFakeInputReq *req; 356a253d6aeSmrg 357a253d6aeSmrg XTestICheckExtension (dpy, info, 0); 358a253d6aeSmrg 359a253d6aeSmrg LockDisplay(dpy); 360a253d6aeSmrg GetReq(XTestFakeInput, req); 361a253d6aeSmrg req->reqType = info->codes->major_opcode; 362a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 363a253d6aeSmrg req->type = in_prox ? XI_ProximityIn : XI_ProximityOut; 364a253d6aeSmrg req->type += (int)(long)info->data; 365a253d6aeSmrg req->time = delay; 366a253d6aeSmrg req->deviceid = dev->device_id; 367a253d6aeSmrg if (n_axes) 368a253d6aeSmrg send_axes(dpy, info, req, dev, 0, axes, n_axes); 369a253d6aeSmrg UnlockDisplay(dpy); 370a253d6aeSmrg SyncHandle(); 371a253d6aeSmrg return 1; 372a253d6aeSmrg} 373a253d6aeSmrg 374a253d6aeSmrgint 375ea133fd7SmrgXTestFakeDeviceMotionEvent(Display *dpy, XDevice *dev, 376ea133fd7Smrg Bool is_relative, int first_axis, 377ea133fd7Smrg int *axes, int n_axes, unsigned long delay) 378a253d6aeSmrg{ 379a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 380a253d6aeSmrg register xXTestFakeInputReq *req; 381a253d6aeSmrg 382a253d6aeSmrg XTestICheckExtension (dpy, info, 0); 383a253d6aeSmrg 384a253d6aeSmrg LockDisplay(dpy); 385a253d6aeSmrg GetReq(XTestFakeInput, req); 386a253d6aeSmrg req->reqType = info->codes->major_opcode; 387a253d6aeSmrg req->xtReqType = X_XTestFakeInput; 388a253d6aeSmrg req->type = XI_DeviceMotionNotify + (int)(long)info->data; 389a253d6aeSmrg req->detail = is_relative; 390a253d6aeSmrg req->time = delay; 391a253d6aeSmrg req->deviceid = dev->device_id; 392a253d6aeSmrg send_axes(dpy, info, req, dev, first_axis, axes, n_axes); 393a253d6aeSmrg UnlockDisplay(dpy); 394a253d6aeSmrg SyncHandle(); 395a253d6aeSmrg return 1; 396a253d6aeSmrg} 397a253d6aeSmrg 398a253d6aeSmrgint 399ea133fd7SmrgXTestGrabControl(Display *dpy, Bool impervious) 400a253d6aeSmrg{ 401a253d6aeSmrg XExtDisplayInfo *info = find_display (dpy); 402a253d6aeSmrg register xXTestGrabControlReq *req; 403a253d6aeSmrg 404a253d6aeSmrg XTestCheckExtension (dpy, info, 0); 405a253d6aeSmrg 406a253d6aeSmrg LockDisplay(dpy); 407a253d6aeSmrg GetReq(XTestGrabControl, req); 408a253d6aeSmrg req->reqType = info->codes->major_opcode; 409a253d6aeSmrg req->xtReqType = X_XTestGrabControl; 410a253d6aeSmrg req->impervious = impervious; 411a253d6aeSmrg UnlockDisplay(dpy); 412a253d6aeSmrg SyncHandle(); 413a253d6aeSmrg return 1; 414a253d6aeSmrg} 415a253d6aeSmrg 416a253d6aeSmrgvoid 417ea133fd7SmrgXTestSetGContextOfGC(GC gc, GContext gid) 418a253d6aeSmrg{ 419a253d6aeSmrg gc->gid = gid; 420a253d6aeSmrg} 421a253d6aeSmrg 422a253d6aeSmrgvoid 423ea133fd7SmrgXTestSetVisualIDOfVisual(Visual *visual, VisualID visualid) 424a253d6aeSmrg{ 425a253d6aeSmrg visual->visualid = visualid; 426a253d6aeSmrg} 427a253d6aeSmrg 428a253d6aeSmrgstatic xReq _dummy_request = { 429a253d6aeSmrg 0, 0, 0 430a253d6aeSmrg}; 431a253d6aeSmrg 432a253d6aeSmrgStatus 433ea133fd7SmrgXTestDiscard(Display *dpy) 434a253d6aeSmrg{ 435a253d6aeSmrg Bool something; 436a253d6aeSmrg register char *ptr; 437a253d6aeSmrg 438a253d6aeSmrg LockDisplay(dpy); 439a253d6aeSmrg if ((something = (dpy->bufptr != dpy->buffer))) { 440a253d6aeSmrg for (ptr = dpy->buffer; 441a253d6aeSmrg ptr < dpy->bufptr; 442a253d6aeSmrg ptr += (((xReq *)ptr)->length << 2)) 443a253d6aeSmrg dpy->request--; 444a253d6aeSmrg dpy->bufptr = dpy->buffer; 445a253d6aeSmrg dpy->last_req = (char *)&_dummy_request; 446a253d6aeSmrg } 447a253d6aeSmrg UnlockDisplay(dpy); 448a253d6aeSmrg SyncHandle(); 449a253d6aeSmrg return something; 450a253d6aeSmrg} 451