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

/* $XConsortium: XTrCoords.c,v 11.12 88/09/06 16:11:08 jim Exp $ */
/* Copyright    Massachusetts Institute of Technology    1986	 */
/* -- MULTIPLEX Extension -- */

#define NEED_REPLIES
#include "Xlibint.h"

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

int
XTranslateCoordinates (dpy, src_win, dest_win, src_x, src_y,
		       dst_x, dst_y, child)
  register Display *dpy;
  Window src_win, dest_win;
  int src_x, src_y;
  int *dst_x, *dst_y;
  Window *child;
{
  register xTranslateCoordsReq *req;
  xTranslateCoordsReply rep;


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

  LockDisplay (dpy);
  GetReq (TranslateCoords, req);
  /* must map !! -- */
  req->srcWid = XmuXMapID (dpy, src_win, FromClient);
  req->dstWid = XmuXMapID (dpy, dest_win, FromClient);
  req->srcX = src_x;
  req->srcY = src_y;
  if (_XReply (dpy, (xReply *) & rep, 0, xTrue) == 0) {
    UnlockDisplay (dpy);
    SyncHandle ();
    return (False);
  }
  /* -- must map ! -- */
  *child = XmuXMapID (dpy, rep.child, FromServer);
  *dst_x = cvtINT16toInt (rep.dstX);
  *dst_y = cvtINT16toInt (rep.dstY);
  UnlockDisplay (dpy);
  SyncHandle ();
  return ((int) rep.sameScreen);
}
