I'm currently writing a program to emulate the Enlightenment window manager's iconbox behavior, but I've reached a stumbling block. I try to copy a scaled-down screenshot of the iconified window to the icon I made with the following function:
Code:
void scaleAndCopy(Window win, Window icon) { 
        extern Display *display;
        extern Window root;
        extern int screen; 

        Pixmap mask;
        Imlib_Image img;

        int x, y, width, height, iconWidth, iconHeight;

        getWindowData(icon, &x, &y, &iconWidth, &iconHeight);
        getWindowData(win, &x, &y, &width, &height);

        mask = XCreatePixmap(display, win, width, height, DefaultDepth(display, screen));
        imlib_context_set_drawable(win);
        img = imlib_create_scaled_image_from_drawable(mask, 0, 0, width, height, iconWidth, iconHeight, false, true);
        imlib_context_set_image(img);                                                                                                                                 imlib_context_set_drawable(icon);
        imlib_render_image_on_drawable(0, 0);
        imlib_free_image();
        XFreePixmap(display, mask);
}
But when I run the program and iconify something, this problem pops up:
Code:
rob@TheRing:~/projects/iconbox/iconbox/trunk$ ./iconbox 
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  62 (X_CopyArea)
  Serial number of failed request:  66347
  Current serial number in output stream:  66600
rob@TheRing:~/projects/iconbox/iconbox/trunk$
If you could, please tell what I'm doing wrong! It's driving me nuts!

Thanks!