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

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

#define NEED_REPLIES
#include "Xlibint.h"

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

Window XGetSelectionOwner(dpy, selection)
register Display *dpy;
Atom selection;
{
    xGetSelectionOwnerReply rep;
    register 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 selection ! -- */
    GetResReq(GetSelectionOwner, 
	      XmuXMapID( dpy , selection , FromClient ) , req);

    if (_XReply(dpy, (xReply *)&rep, 0, xTrue) == 0) rep.owner = None;
    UnlockDisplay(dpy);
    SyncHandle();
    return(rep.owner);
}
