/*
 * -- $Header: /cec/src/nestor/servers/R3/shXlib/XGetGeom.c,v 1.1.1.1 90/04/23 09:58:40 spanachi Exp $
 */
#include "copyright.h"

/* $XConsortium: XGetGeom.c,v 11.15 88/09/06 16:07:49 jim Exp $ */
/* Copyright    Massachusetts Institute of Technology    1986	*/
/* -- MULTIPLEX Extension -- */

#define NEED_REPLIES
#include "Xlibint.h"

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

Status XGetGeometry (calling_dpy, d, root, x, y, width, height,
		     borderWidth, depth)
    register Display *calling_dpy;
    Drawable d;
    Window *root; /* RETURN */
    int *x, *y;  /* RETURN */
    unsigned int *width, *height, *borderWidth, *depth;  /* RETURN */
{
    xGetGeometryReply rep;
    register xResourceReq *req;
    register Display *dpy ;

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

    LockDisplay(dpy);
    /* -- must map drawable -- */
    GetResReq(GetGeometry,
	      XmuXMapID( dpy , d , FromClient ) ,
	      req);
    if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
	UnlockDisplay(dpy);
	SyncHandle();
	return (0);
	}
    *root = rep.root;
    *x = cvtINT16toInt (rep.x);
    *y = cvtINT16toInt (rep.y);
    *width = rep.width;
    *height = rep.height;
    *borderWidth = rep.borderWidth;
    *depth = XmuXMapDepth( calling_dpy , rep.depth , d , DontKnow ) ;
    UnlockDisplay(dpy);
    SyncHandle();
    return (1);
}

