/*
 * -- $Header: /cec/src/nestor/servers/R3/shXlib/XQuPntr.c,v 1.1.1.1 90/04/23
 * 10:04:15 spanachi Exp $
 */
#include "copyright.h"

/* $XConsortium: XQuPntr.c,v 11.14 88/09/06 16:09:58 jim Exp $ */
/* Copyright    Massachusetts Institute of Technology    1986	 */
/* -- MULTIPLEX Extension -- */

#define NEED_REPLIES
#include "Xlibint.h"

/* -- additional includes -- */
#include "utils.h"
#include "map.h"

Bool
XQueryPointer (dpy, w, root, child, root_x, root_y, win_x, win_y, mask)
  register Display *dpy;
  Window w, *root, *child;
  int *root_x, *root_y, *win_x, *win_y;
  unsigned int *mask;

{
  xQueryPointerReply rep;
  xResourceReq *req;


  /* -- flush default dpy's queue to keep buffers aligned -- */
  XmuXFlushDefault (dpy);
  /* -- switch to the chalk holder display -- */
  dpy = XmuXChalkDisplay (dpy);

  LockDisplay (dpy);
  /* -- must map ID !! -- */
  GetResReq (QueryPointer, XmuXMapID (dpy, w, FromClient), req);
  if (_XReply (dpy, (xReply *) & rep, 0, xTrue) == 0) {
    UnlockDisplay (dpy);
    SyncHandle ();
    return (False);
  }
  /* -- must map ID's -- */

  /*
   * -- NOTE : -- Hope this will cause no trouble; child may be a ID that --
   * can't be mapped, because it doesn't belong to the application -- and it
   * doesn't exist on all servers !!!
   */
  *root = XmuXMapID (dpy, rep.root, FromServer);
  *child = XmuXMapID (dpy, rep.child, FromServer);
  *root_x = cvtINT16toInt (rep.rootX);
  *root_y = cvtINT16toInt (rep.rootY);
  *win_x = cvtINT16toInt (rep.winX);
  *win_y = cvtINT16toInt (rep.winY);
  *mask = rep.mask;
  UnlockDisplay (dpy);
  SyncHandle ();
  return (rep.sameScreen);
}
