How to distinguish Window and Pixmap ID

Adam Jackson ajax at nwnk.net
Mon Mar 16 07:30:53 PDT 2009


On Mon, 2009-03-16 at 10:57 +0800, Ren, Zhaohan wrote:
> Hi all
> Windows and pixmaps together are known as drawables. Now I get a
> "drawable" ID(Created by XCreateWindow or XCreatePixmap) , I want to
> know how to distinguish them, that is to say how to distinguish if a
> "drawable ID" is a pixmap ID or window ID.
> It seems that I didn't find any Xlib interface to achieve this. Are
> there any good method to use?

There's no good interface for this, or for discovering the type of an
arbitrary XID in general.  If you think you need one you're probably
mistaken.  Why do you think you need to do this?

You _can_ do something like:

static int pixmap = 0;
static int pixmap_check(Display *d, void *v) { pixmap = 1; return 0; }
/* ... */
    XWindowAttributes xwa;
    void *old_handler = XSetErrorHandler(dpy, pixmap_check);
    XGetWindowAttributes(dpy, draw, &xwa);
    XSetErrorHandler(dpy, old_handler);
    if (pixmap) /* whatever */

But really, don't.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.x.org/archives/xorg-devel/attachments/20090316/4c271992/attachment.pgp 


More information about the xorg-devel mailing list