Re: Wrapper for arbitrary Drawable



On Wed, 2006-09-20 at 12:18 +0400, Kirill Kirichenko wrote:
> Hi Alex,
> 
> > Why do you have to access it through the same display though? The
> > drawable is just an id for the pixmap, and its the same independent on
> > what connection to the x server (==display) you use.
> Simply because it doesn't work, it generates BadDrawable X error.
> Check out the code below:
> <code>
> /* test.c
>   * gcc test.c -o test -g -Wall `pkg-config --cflags --libs gdk-2.0`
>  */
> 
> #include <gdk/gdk.h>
> #include <X11/Xlib.h>
> #include <stdio.h>
> 
> int main(int argc, char** argv)
> {
>     gdk_init(&argc, &argv);
> 
>     Display* display = XOpenDisplay(NULL);
>     if (!display)
>         return -1;
> 
>     Drawable xid = XCreatePixmap(display, DefaultRootWindow(display),
>                                  20, 20, 24);

You need to add:
    XSync(display, FALSE);
here. The xid is only allocated at the client side at this point,
because there has been no roundtrip yet.

>     GdkPixmap* pixmap =
> gdk_pixmap_foreign_new_for_display(gdk_display_get_default(), xid);
> 
>     printf("Foreign pixmap = %p\n", pixmap);
> 
>     return 0;
> }
> </code>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a one-legged soccer-playing farmboy with a secret. She's a tortured 
green-skinned femme fatale with the power to bend men's minds. They fight 
crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]