1: #include <X/mit-copyright.h>
   2: 
   3: /* $Header: XUpdateMouse.c,v 10.4 86/02/01 15:41:37 tony Rel $ */
   4: /* Copyright    Massachusetts Institute of Technology    1985	*/
   5: 
   6: #include "XlibInternal.h"
   7: 
   8: extern _QEvent *_qfree;
   9: 
  10: /* Like XQueryMouse, but also reads pending events and flushes any MouseMoved
  11:  * events at the head of the queue.  A good way to track the mouse is to use
  12:  * a MouseMoved event as a "hint", by calling this routine to get up to date
  13:  * coordinates.
  14:  */
  15: 
  16: Status XUpdateMouse (w, x, y, subw)
  17:     Window w;
  18:     Window *subw;
  19:     int *x, *y;
  20: {
  21:     register Display *dpy;
  22:     register XReq *req;
  23:     register _QEvent *qelt;
  24:     XRep rep;
  25: 
  26:     XPending(dpy = _XlibCurrentDisplay);
  27:         /* read all events in socket's kernel buffer */
  28:     GetReq(X_QueryMouse, w);
  29:     if (!_XReply(dpy, &rep))
  30:         return(0);
  31:     while ((qelt = dpy->head) && qelt->event.type == MouseMoved) {
  32:         if ((dpy->head = qelt->next) == NULL)
  33:         dpy->tail = NULL;
  34:         qelt->next = _qfree;
  35:         _qfree = qelt;
  36:         dpy->qlen--;
  37:     }
  38:     *x = rep.param.s[2];
  39:     *y = rep.param.s[3];
  40:     *subw = rep.param.l[0];
  41:     return (1);
  42: }
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 780
Valid CSS Valid XHTML 1.0 Strict