Re: gdk_window_foreign_new returns NULL



jacktm wrote:

Hello.

I'm working on a big project and I have to use
gdk_window_foreign_new function in it. It doesn't work
and always returns NULL. I've checked if I can use
it in a small application - just to see how does it work,
but unfortunately it doesn't work for me.  I attached
as simple test as I could do (just a tutorial program
+ call to gdk_window_foreign_new). What's wrong?
What should I do to make it work?

Thanks,
   Jack
 

Sorry, I forgot to attach test program...
// Written by Ch. Tronche (http://tronche.lri.fr:8000/)
// Copyright by the author. This is unmaintained, no-warranty free software. 
// Please use freely. It is appreciated (but by no means mandatory) to
// acknowledge the author's contribution. Thank you.
// Started on Thu Jun 26 23:29:03 1997

#include <X11/Xlib.h>
#include <assert.h>
#include <unistd.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>

#define NIL (0)

main(int argc, char **argv)
{
      GdkWindow *gdk_win;

      gdk_init(&argc, &argv);

      // Open the display
      Display *dpy = XOpenDisplay(NIL);
      assert(dpy);

      // Get some colors
      int blackColor = BlackPixel(dpy, DefaultScreen(dpy));
      int whiteColor = WhitePixel(dpy, DefaultScreen(dpy));

      // Create the window
      Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 
                                     200, 100, 0, blackColor, blackColor);
      gdk_win = gdk_window_foreign_new((guint32)w);
      printf("gdk_win = %p\n", gdk_win);

      // We want to get MapNotify events
      XSelectInput(dpy, w, StructureNotifyMask);

      // "Map" the window (that is, make it appear on the screen)
      XMapWindow(dpy, w);

      // Create a "Graphics Context"
      GC gc = XCreateGC(dpy, w, 0, NIL);

      // Tell the GC we draw using the white color
      XSetForeground(dpy, gc, whiteColor);

      // Wait for the MapNotify event
      for(;;) {
            XEvent e;
            XNextEvent(dpy, &e);
            if (e.type == MapNotify)
                  break;
      }

      // Draw the line
      XDrawLine(dpy, w, gc, 10, 60, 180, 20);

      // Send the "DrawLine" request to the server
      XFlush(dpy);

      // Wait for 10 seconds
      sleep(10);
}



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