[comp.windows.x] Changing icons-X11 on Dec 3100

csbrad@knuth.MTSU.EDU (mr. Brad Maxwell) (02/03/90)

Hi there,

  Does anyone know if there's a trick to getting the Decstation and
Vaxstation 3100's (X11 under Ultrix) to use a different icon in the window?
The window manager doesn't seem to care for the idea, but the big guys like
GKS and postscript previewer do it.  Also, none of the net programs (xrn, etc.)
that include new icons will change it.

  Any help would be appreciated.
  E-mail me at csbrad@knuth.mtsu.edu

  Thanks,
    Brad Maxwell
    Middle Tn. State U.
-- 
-----------------------------------------------------------------------------
--Brad Maxwell              
--Middle Tn. State University
--csbrad@mtsu.edu

roman@ektools.UUCP (Bill Romanowich) (02/09/90)

In article <61@knuth.MTSU.EDU> csbrad@knuth.MTSU.EDU (mr. Brad Maxwell) writes:
>
>  Does anyone know if there's a trick to getting the Decstation and
>Vaxstation 3100's (X11 under Ultrix) to use a different icon in the window?
>The window manager doesn't seem to care for the idea, but the big guys like
>GKS and postscript previewer do it.  Also, none of the net programs (xrn, etc.)
>that include new icons will change it.
>
>  Thanks,
>    Brad Maxwell
>    Middle Tn. State U.

First of all, I assume you are using the DECwindows window manager.  There is a 
slight trick to using different icons, if you are using small icons that is.  
Before we start, you should note that the big icons are 32x32 pixels and the
small icons are 16x16 pixels for the DECwindows window manager.

If you are using a toolkit, it's actually pretty easy once you know how.
You need to set the XtNiconifyPixmap resource on the toplevel shell widget
to your pixmap (`XtNiconifyPixmap' is defined in /usr/include/X11/Vendor.h):

	XtSetArg( arglist[i], XtNiconifyPixmap, <pixmap> ); i++;
	XtSetValues( <toplevel-shell>, arglist, i );

This sets both the icon pixmap and the iconify button in the window banner.
Actually, you can probably set XtNiconifyPixmap on any shell widget that the
window manager sees (eg. doesn't have override redirect set).  By the way,
the XtNiconPixmap resource can be used to set big icons (`XtNiconPixmap is
defined in /usr/include/X11/Shell.h).

If you are using straight Xlib, the example below (sorry, I'm not sure where I
got it from anymore) shows how to set both big and small icons.

Bill

-------------------------------- Cut Here --------------------------------

/*
 * This is an example of setting a big icon and a small icon using Xlib.  With
 * XChangeProperty the small icon is set in both the title bar and the icon box
 */

#ifdef VMS
#include <decw$include/Xlib.h>
#include <decw$include/Xutil.h>
#include <decw$include/Xatom.h>
#include <decw$include/DECWmHints.h>
#else VMS
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/DECWmHints.h>
#endif VMS

#include <stdio.h>

/* small icon pixmap bits */

#define checker16_width 16
#define checker16_height 16
static char checker16_bits[] = {
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0};

/* big icon pixmap bits */

#define checker32_width 32
#define checker32_height 32
static char checker32_bits[] = {
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
   0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
   0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0};

int main()
{
   Display *dpy;
   Screen *screen;
   Window root, win;
   unsigned long fg, bg;
   unsigned int depth, screen_number;
   XEvent event;
   XWMHints wmhints;
   DECWmHintsRec dwmhints;
   Atom wmatom;

   dpy = XOpenDisplay(NULL);
   if (dpy == NULL) printf("Dpy is NULL!\n");
   screen_number = XDefaultScreen(dpy);
   screen = XDefaultScreenOfDisplay(dpy);
   root = XDefaultRootWindow(dpy);
   fg = XBlackPixelOfScreen(screen);
   bg = XWhitePixelOfScreen(screen);
   depth = XDefaultDepth(dpy,screen_number);
   win = XCreateSimpleWindow(dpy, root, 200, 200, 400, 400, 1, fg, bg);

/* Set the "icon pixmap" into the large icon */

   wmhints.icon_pixmap = XCreatePixmapFromBitmapData(dpy, root, checker32_bits, 
			checker32_width, checker32_height, fg, bg, depth);
   wmhints.flags = IconPixmapHint;
   XSetWMHints(dpy, win, &wmhints);  

/* Set the title bar name and the icon name */

   XStoreName(dpy, win, "Checkers");
   XSetIconName(dpy, win, "Checkers");

/* Set the "iconify pixmap" into title bar and small icon */

   wmatom = XInternAtom(dpy, "DEC_WM_HINTS", 0);
   if (wmatom != None) {
      dwmhints.value_mask = DECWmIconifyPixmapMask;
      dwmhints.iconify_pixmap = XCreatePixmapFromBitmapData(dpy, 
			root, checker16_bits, checker16_width, 
			checker16_height, fg, bg, depth);
      XChangeProperty(dpy, win, wmatom, wmatom, 32, PropModeReplace,
         (unsigned char *) &dwmhints,  sizeof(dwmhints));
   }
   XMapWindow(dpy, win);
   for (;;) 
      XNextEvent(dpy, &event);
}

------------------------------------------------------------------------

Bill Romanowich 		(ektools!roman@kodakr.kodak.com)  
UUCP   : {allegra,rutgers}!rochester!kodak!ektools!roman
USMail : System Solutions Group, Eastman Kodak Co., Rochester, NY 14653-5819
Phone  : (716) 726 - 0217	SSG User Interface Software
-- 
Bill Romanowich 		(ektools!roman@kodakr.kodak.com)  
UUCP   : {allegra,rutgers}!rochester!kodak!ektools!roman
USMail : System Solutions Group, Eastman Kodak Co., Rochester, NY 14653-5819
Phone  : (716) 726 - 0217	SSG User Interface Software