[comp.windows.x] icon control using Xt

schoch@sheba.arc.nasa.gov (Steve Schoch) (02/22/91)

I'm using the X toolkit with the following sequence of calls:

	toplevel = XtAppInitialize(&my_app, ...., fallback_resources, ...);
	
	/* some other stuff */

	XtRealizeWidget(toplevel);
	
	/* more initialization */

	XtAppMainLoop(my_app);

I would like to have the window manager let me play with my own icon
which I would like to be a window (so I can flash it when input from the
user is required) but I could learn to live with just telling the window
manager to use a bitmap for the icon and mask.

One of the supplied programs (xlogo) initializes fallback_resources with
two strings:

String fallback_resources[] = {
    "*iconPixmap:    xlogo32",
    "*iconMask:      xlogo32",
    NULL,
};

The trouble with this is that filenames are expected.  I would like to
have the bitmap encoded directly in my program so it will be portable to
machines that don't have my bitmap in /usr/include/X11/bitmaps.

What I would really like is to create a window and give that to the window
manager.  There is a toolkit provision for this to be done by doing something
like:

String fallback_resources[] = {
        "*iconWindow:   mywin",
        NULL,
};

but something needs to convert the string "mywin" into a Window.  How do I
do this?

	Steve

rthomson@mesa.dsd.es.com (Rich Thomson) (02/22/91)

In article <1991Feb21.174838.7365@news.arc.nasa.gov>
	schoch@trident.arc.nasa.gov (Steve Schoch) writes:
>I would like to have the window manager let me play with my own icon
>which I would like to be a window (so I can flash it when input from the
>user is required) but I could learn to live with just telling the window
>manager to use a bitmap for the icon and mask.
>
>One of the supplied programs (xlogo) initializes fallback_resources with
>two strings:
>
>String fallback_resources[] = {
>    "*iconPixmap:    xlogo32",
>    "*iconMask:      xlogo32",
>    NULL,
>};
>
>The trouble with this is that filenames are expected.  I would like to
>have the bitmap encoded directly in my program so it will be portable to
>machines that don't have my bitmap in /usr/include/X11/bitmaps.

The resource has to be a filename, but the argument to XtSetValues can
be the drawable ID of the pixmap you've created.  The O'Reilly books
(Volume 4, pp. 292ff) discuss this.

Basically, you create the pixmap with the XCreateBitmapFromData call
and then do a set values like:

    XtVaSetValues(topLevel, XtNiconPixmap, icon_pixmap, NULL);

As to how you would "flash" the pixmap for the icon, I don't know.
This seems to rely too much on their being a window manager present,
etc.  If the intent is to signal the user that input is needed to
progress, why not pop-up a modal dialog?

						-- Rich
-- 
  ``Read my MIPS -- no new VAXes!!'' -- George Bush after sniffing freon
	    Disclaimer: I speak for myself, except as noted.
UUCP: ...!uunet!dsd.es.com!rthomson		Rich Thomson
ARPA: rthomson@dsd.es.com			PEXt Programmer