I added a new function XResQueryClientPixmapBytes to the
XResource extension to query the byte total of pixmaps that
the client has allocated.

   I've attached a modified version of the original restest.c
program which uses it.


                        Mark.
/*
     gcc -o restest -Wall restest.c -L/usr/X11R6/lib -lX11 -lXext -lXRes
*/


#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/extensions/XRes.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(void)
{
    Display *TheDisplay;
    int event, error, major, minor, num_clients, i, j, num_types;
    unsigned long bytes;
    XResClient *clients;
    XResType *types;
    char *name;
    Atom pixmap;

    TheDisplay = XOpenDisplay(0);

    if(!XResQueryExtension(TheDisplay, &event, &error)) {
        printf("XResQueryExtension failed\n");
        return 1;
    }

    if(!XResQueryVersion(TheDisplay, &major, &minor)) {
        printf("XResQueryVersion failed\n");
        return 1;
    } else {
        printf("X-Resource extension version %i.%i\n", major, minor);
    }

    pixmap = XInternAtom(TheDisplay, "PIXMAP", 0);

    XGrabServer(TheDisplay);

    XResQueryClients(TheDisplay, &num_clients, &clients);
 
    printf("There are %i clients\n", num_clients);
    for(i = 0; i < num_clients; i++) {
       XResQueryClientResources(TheDisplay, clients[i].resource_base,
                                &num_types, &types);

       printf("Client %i (base = 0x%x, mask = 0x%x): %i resource types\n", i,
                                        clients[i].resource_base,
                                        clients[i].resource_mask, num_types);

       for(j = 0; j < num_types; j++) {
          name = XGetAtomName(TheDisplay, types[j].resource_type);
          printf("   %s: %i", name, types[j].count);
          if(types[j].resource_type == pixmap) {
              XResQueryClientPixmapBytes(TheDisplay, clients[i].resource_base,
                                         &bytes);
              printf("  (%i bytes)\n", bytes); 
          } else printf("\n");
          XFree(name);
       }

       XFree(types);
    }

    XUngrabServer(TheDisplay);

    XFree(clients);
     
    XCloseDisplay(TheDisplay);

    return 0;
}


Reply via email to