#ifndef lint
static char *rcsid = "$Header: xmisc.c,v 1.2 90/10/25 13:50:16 klee Exp Locker: klee $";
#endif lint
/*
 *			  COPYRIGHT 1990
 *		   DIGITAL EQUIPMENT CORPORATION
 *		       MAYNARD, MASSACHUSETTS
 *			ALL RIGHTS RESERVED.
 *
 * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
 * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
 * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR
 * ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
 *
 * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT RIGHTS,
 * APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN ADDITION TO THAT
 * SET FORTH ABOVE.
 *
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted, provided
 * that the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting documenta-
 * tion, and that the name of Digital Equipment Corporation not be used in
 * advertising or publicity pertaining to distribution of the software without
 * specific, written prior permission.
 */

#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/Shell.h>

static Widget cursorWidget;

void
busyCursor(widget)
    Widget widget;
{
    static Cursor busyCursor;

    cursorWidget = widget;

    /* define an appropriate busy cursor */
    if (busyCursor == NULL)
	busyCursor = XCreateFontCursor(XtDisplay(widget), XC_watch);
    XDefineCursor(XtDisplay(widget), XtWindow(widget), busyCursor);
    XFlush(XtDisplay(widget));
}

void
unbusyCursor()
{
    XUndefineCursor(XtDisplay(cursorWidget), XtWindow(cursorWidget));
    XFlush(XtDisplay(cursorWidget));
}


#include "xglobe.icon"
void
createIcon(shell, iconName)
    Widget shell;
    char *iconName;
{
    char *bits;
    int width, height;
    Pixmap iconPixmap = (Pixmap)0;
    Arg wargs[10];
    Cardinal n;
    
    /* defined in icon include file */
    width = xglobe_width;
    height = xglobe_height;
    bits = xglobe_bits;

    /* user sets iconPixmap resource, converter does the right thing */
    n = 0;
    XtSetArg(wargs[n], XtNiconPixmap, &iconPixmap); n++;
    XtGetValues(shell, wargs, n);

    if (iconPixmap == (Pixmap) 0) {
	Display *d = XtDisplay(shell);
	Screen *s = XtScreen(shell);
	Window w = s->root;	/* any window to indicate screen */
	iconPixmap = XCreateBitmapFromData(d, w, bits, width, height);
	n = 0;
	XtSetArg(wargs[n], XtNiconPixmap, iconPixmap); n++;
	XtSetValues(shell, wargs, n);
    }
}
