Retrieving Xlib Widget from GtkWindow



Hi all,

Posting this question here assuming that there will be ppl here knowledgeable
in the X11 bit of the question, too.

right now, I'm trying to add a GTK GUI to an application with an Xw GUI
and, of course trying to reuse as much code as possible.
This app stores the Xlib Widget instance of the toplevel Xlib Window for
further processing. It gets the widget returned by XtVaAppInitialize().

I'm trying to get the same from a GTK GUI doing:

   .....
  gtk_widget_show(window1);
  {
        Display *mydisplay;
        Window root, topwin;
        Widget *toplevel;
        XWindowAttributes xwin_attr;
        topwin = GDK_WINDOW_XWINDOW ( GTK_WIDGET (window1)->window);
        g_print("pointer to topwin: %p - ID: %i\n", &topwin, topwin);
        mydisplay = GDK_DRAWABLE_XDISPLAY( GTK_WIDGET (window1)->window );
        g_print("pointer to display: %p \n", mydisplay);
        XGetWindowAttributes(mydisplay, topwin, &xwin_attr);
g_print("Xwin Attrs: %i x %i + %i + %i . %i\n", xwin_attr.width, xwin_attr.height, xwin_attr.x, xwin_attr.y, xwin_attr.depth);
        *toplevel = XtWindowToWidget(mydisplay, topwin);
    }
    ......


This gives me the following output:

<someuid>@ono-sendai(501)> ./gvidcap
requested gtk2 gui!
pointer to topwin: 0xbffff76c - ID: 35651587
pointer to display: 0x820cb80
Xwin Attrs: 398 x 25 + 0 + 0 . 24
Error: Couldn't find per display information


Now, the pointers to topwin and display seem to indicate that I've found
my Xlib Window and Display alright. Also, the Window dimensions in the
Xwin Attributes are the right ones. Still the XtWindowToWidget() doesn't
seem to work.

Can anybody shed some light on this? I've done some research and found
pointers to the importance of the link order ... following the advices there
didn't improve things, though. Still, I'm attaching how I compile things
below.

TIA,

Karl.

---

e.g. gtk2_control

gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/X11R6/include -DVERSION=\"1.0.16\" -I../getopt -g -O2 -I/export/home/<someuid>/cvstree/xvidcap/ffmpeg/libavcodec -I/export/home/kb87850/cvstree/xvidcap/ffmpeg/libavformat `pkg-config --cflags gtk+-2.0` -c `test -f 'gtk2_control.c' || echo './'`gtk2_control.c

Where pkg-config returns:

-I/usr/local/include/pango-1.0 -I/usr/include/freetype2 -I/usr/X11R6/include -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include

The link bit is in here:

gcc -I/usr/X11R6/include -DVERSION=\"1.0.16\" -I../getopt -g -O2 -I/export/home/<someuid>/cvstree/xvidcap/ffmpeg/libavcodec -I/export/home/<someuid>/cvstree/xvidcap/ffmpeg/libavformat `pkg-config --cflags gtk+-2.0` -L/usr/X11R6/lib -L/export/home/<someuid>/cvstree/xvidcap/ffmpeg/libavcodec -L/export/home/<someuid>/cvstree/xvidcap/ffmpeg/libavformat -L/usr/local/lib -L/usr/lib -o xvidcap main.o control.o options.o colors.o util.o frame.o capture.o xtoxwd.o xtopnm.o mngutil.o xtomng.o xutil.o job.o sound.o video.o getopt1.o getopt.o malloc.o realloc.o xtoffmpeg.o xtojpg.o xtopng.o gtk2_control.o gtk2_options.o gtk2_support.o ../Xw/libXw.a -Wl,-Bstatic -lavformat -Wl,-Bdynamic -Wl,-Bstatic -lavcodec -Wl,-Bdynamic -ljpeg -lpng -lz -lXmu -lXext -lSM -lICE `pkg-config --libs gtk+-2.0`

pkg-config here returns:

-Wl,--export-dynamic -L/usr/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0








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