How to distinguish Window and Pixmap ID

Ren, Zhaohan zhaohan.ren at intel.com
Mon Mar 16 18:29:38 PDT 2009


I'm doing some video post-processing work, if the "Drawable" created by application interface is a window I will use hardware overlay, if it is a pixmap I will use textured video. Now I see, thank you for your help.

-----Original Message-----
From: Adam Jackson [mailto:ajax at nwnk.net] 
Sent: 2009年3月16日 22:31
To: Ren, Zhaohan
Cc: xorg-devel at lists.x.org
Subject: Re: How to distinguish Window and Pixmap ID

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


More information about the xorg-devel mailing list