import sometimes incorrectly handles X11 window hierarchy, output garbled

Andreas Luik <[email protected]>
Newsgroups gmane.comp.video.image-magick.bugs
Message-ID <[email protected]>
Hello,

  ImageMagick bug report
  Platform: Linux, X11
  Version: 6.0.7.1

We found that sometimes the "import" utility does not correctly handle
a hierarchy of subwindows under X11.  First we have seen this with
windows using the OpenMotif NotePage widget.  But it is easy to
reproduce with just a small window hierarchy.  A small test program to
show the problem is attached.  Please compile and run with

% cc -o wintree wintree.c -lX11
% ./wintree
Main Window = 0xc400001

A white window appears, and the main window's id is printed.  Now run
the import utility as follows:

% import -frame -window <window-id> /tmp/wrong.png

With "display", you will see that import did include some garbage in
the generated PNG file.

% display /tmp/wrong.png

The reason for this is that the XGetWindowImage() function in
magick/xwindow.c does not correctly compute the bounds or crop
rectangles when descending the window hierarchy.

A patch would be appreciated.
Kind regards,
-- 
Andreas Luik

Barco Orthogon GmbH
Vaihinger Str. 169, D-70567 Stuttgart
Managing Directors / Geschaeftsfuehrer: Frank Timmermans, Klaus Kaltwasser
Place of Registration / Sitz: Bremen HRB 23374
Tel. +49-711-78 19 60-744 Fax +49-711-78 19 60-711
http://www.barco-orthogon.com
[email protected]
-----------------------------
This e-mail and any further files transmitted with it are
confidential.  If you are not the intended recipient, please
notify [email protected] and delete the files.
Full disclaimer: http://www.barco-orthogon.com/html/e-mail_disclaimer.htm

_______________________________________________
Magick-bugs mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-bugs
wintree.c (text/plain, 1.2 KB)
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>

static struct {
    int x;
    int y;
    unsigned int width;
    unsigned int height;
    unsigned int bw;
} winlist[] = {
    {  100,  100, 550, 528, 0 },
    {    0,   28, 550, 500, 0 },
    {   10,   10, 540, 340, 0 },
    { -540, -340, 540, 340, 0 },
    {    0,  190, 538, 114, 0 },
};

int main()
{
    int i;
    Display *dpy;
    Window parent;
    Window mainw;
    Window w;

    if ((dpy = XOpenDisplay(0)) == NULL) {
	fprintf(stderr, "failed to open display\n");
	exit(1);
    }

    parent = DefaultRootWindow(dpy);
    for (i = 0; i < sizeof(winlist) / sizeof(winlist[0]); i++) {
	w = XCreateSimpleWindow(dpy, parent,
				winlist[i].x, winlist[i].y,
				winlist[i].width, winlist[i].height,
				winlist[i].bw,
				BlackPixel(dpy, DefaultScreen(dpy)),
				WhitePixel(dpy, DefaultScreen(dpy)));
	parent = w;
	if (i == 0) {
	    mainw = w;
	    XSelectInput(dpy, mainw, ButtonPressMask);
	}
	XMapWindow(dpy, w);
    }

    printf("Main Window = %#lx\n", mainw);

    while (1) {
	XEvent event;
	
	XNextEvent(dpy, &event);
	
	switch (event.type) {
	  case ButtonPress:
	    exit(0);
	    break;
	}
    }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.