[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

1303.0. "Firefox Root window Pixmap" by DLOACT::BROWNL () Fri Aug 18 1989 12:22

    
    This was previously entered on the FIREFOX conference. I was told that
    someone might help me on the Decwindows conference.
    
    Anybody have any clues.......
    
    Thanks in Advance.
    
    --> Len <--
    
    
           <<< NEVADA::SYS$SYSDEVICE:[NOTES$LIBRARY]FIREFOX.NOTE;1 >>>
                                  -< firefox >-
================================================================================
Note 148.0                     Root window Pixmap                      2 replies
DLOACT::BROWNL                                      223 lines  14-AUG-1989 14:34
--------------------------------------------------------------------------------
    I am presently working with a customer who has many different
    platforms that they wish to operate on. They are using C, Fortran,
    Phigs, DecWindows (And independant x calls). They have 8 plane
    color graphics workstation 2000's and they also have a 3540 (Firefox)
    24 Bit plane system. The following program worked on the 8-plane system
    to install a pixmap on the root window.  No error occured on the
    Firefox... Nothing happened at all.
    
    What modifications do I need to do to get it to work on the firefox?
    
    Does the Firefox session manager create more/fewer windows than the 
    8-plane system at startup? 
    
    
/*
  X - Windows Root Window Pixmap Installer
 */

#define TILEFILE  "bit.dat"

#include <stdio.h>

#include <decw$include/Xlib.h>
#include <decw$include/Xatom.h>
#include <decw$include/Xutil.h>

 /*****************************************************************************/

Window WmRootWindow (dpy1, root1)
  Display *dpy1;
  Window  root1;
{
        Window parent;
        Window *child;
        unsigned int nchildren;
        XWindowAttributes rootatt, childatt;

        if (!XGetWindowAttributes(dpy1, root1, &rootatt))
        {                    
            fprintf (stderr, "XGetWindowAttributes on root failed. \n");
            exit(1);
        }

        if (XQueryTree (dpy1, root1, &root1, &parent, &child, &nchildren)){
            int i;
            for (i=0;i < nchildren; i++){
                 if (!XGetWindowAttributes (dpy1, child[i], &childatt)){
                   fprintf (stderr, "XGetWindowAttributes on child failed.\n");
                   exit(1);
                 }

                 if ((rootatt.width == childatt.width) &&
                     (rootatt.height == childatt.height))
                        return child[i];
             }
            return root1;
        } else {
           fprintf(stderr, "XQueryTree failed (Window doesn't exist).\n");
           exit(1);
        }
}


/*****************************************************************************/0

main()
{
    char  tilefilename[255];
    FILE *tilefile;
    int   tilewidth, tileheight, tilerecords;
    char *tiledata;
    int   i, tilefound;

    Display  *dpy;
    Window    win, win2;
    unsigned int depth;
    char     dummy[64];

    Pixmap    bitmap,
              pixmap;
    GC        gc;
    XGCValues gc_init;
    XEvent    pe;


/*
        Get environment variable to define directories and files for resources.
*/
    strcpy(tilefilename, TILEFILE);

/*
        Open application tile definition file.
*/
    tilefile = fopen(tilefilename,"r");
    if (tilefile == NULL) {
        printf("Error - can not open tile file '%s'\n", tilefilename);
        tilefound = 0;

    } else {

        printf(" File '%s' was opened...\n", tilefilename);


/*
            Read application tile size, allocate space for tile.
*/
        fscanf(tilefile, "%s %s %d", dummy, dummy, &tilewidth);
        fscanf(tilefile, "%s %s %d %d", dummy, dummy, &tileheight);
        fscanf(tilefile, "%s %s %s %s %s", dummy, dummy, dummy, dummy, dummy);
        tilerecords = ((tilewidth * tileheight) + (8 * 11)) / (8 * 12);

        tiledata = (char *) calloc( (tilerecords * 12), sizeof(char) );

        if (tiledata == NULL) {
            printf("Error - Unable to allocate space for tile data.\n");
            tilefound = 0;


        } else {
/*
            Read application tile definition.
*/
          for (i=0; i<tilerecords; i++)
            fscanf(tilefile, "%x, %x, %x, %x, %x, %x, %x, %x, %x, %x, %x, %x,",
                    &tiledata[(i*12)],    &tiledata[(i*12)+1],
                    &tiledata[(i*12)+2],  &tiledata[(i*12)+3],
                    &tiledata[(i*12)+4],  &tiledata[(i*12)+5],
                    &tiledata[(i*12)+6],  &tiledata[(i*12)+7],
                    &tiledata[(i*12)+8],  &tiledata[(i*12)+9],
                    &tiledata[(i*12)+10], &tiledata[(i*12)+11]  );

          tilefound = 1;

          printf(" Tile info received, size = %d x %d\n",
                    tilewidth, tileheight);
          printf(" Number of tile records = %d\n", tilerecords);
        }

        fclose(tilefile);
    }


    if (!tilefound) exit(-1);


/*
        Open the display, set up some useful values.
*/
    if (!(dpy = XOpenDisplay(NULL))) {
        printf("Cannot open display\n");
        exit(-1);
    }


    win2 = DefaultRootWindow(dpy);

    win = WmRootWindow (dpy, win2);
    win = WmRootWindow (dpy, win);

/*    win = RootWindow(dpy, DefaultScreen(dpy)); */

    depth = DefaultDepth(dpy, DefaultScreen(dpy));
    printf(" Display opened.\n");


/**********************************************
        Create the bitmap based on the data retrievd from the file.
***********************************************/

    bitmap = XCreateBitmapFromData(dpy, win, tiledata, tilewidth, tileheight);
    printf(" Bitmap created.\n");

/*
        Create a graphics context to be used when copying the bitmap.
*/
    gc_init.foreground = WhitePixel(dpy, DefaultScreen(dpy));
    gc_init.background = BlackPixel(dpy, DefaultScreen(dpy));
    gc = XCreateGC(dpy, win, GCForeground | GCBackground, &gc_init);

/*
        Copy the one-plane bitmap to a multi-plane pixmap.
*/
    pixmap = XCreatePixmap(dpy, win, tilewidth, tileheight, depth);
    XCopyPlane(dpy, bitmap, pixmap, gc,
               0, 0, tilewidth, tileheight, 0, 0, (unsigned long)1);
    printf(" Background pixmap copied from bitmap.\n");

/*
        Set the root window background.
        Clear and map the window.
*/
    XSetWindowBackgroundPixmap(dpy, win, pixmap);
    XClearWindow(dpy, win);
    XMapRaised(dpy, win);
    XFlush(dpy);

    printf(" Background pixmap set.\n");


/*
        Free the used resources.
*/
    XFreePixmap(dpy, bitmap);
    XFreePixmap(dpy, pixmap);
    XFreeGC(dpy, gc);


/*
        Loop while handling interesting events.
*/
    XNextEvent(dpy, &pe);
    while(XPending(dpy))
    {
        XNextEvent(dpy, &pe);
    }

}  
    
    

T.RTitleUserPersonal
Name
DateLines