Re: Getting the WindowID of a GtkWidget




Matt Kimball <mkimball@xmission.com> writes:

> On Sun, May 03, 1998 at 02:11:15PM -0300, Claudemir Todo Bom wrote:
> > I'm beggining with Gtk+ (and with C too), and I'm trying to interface a
> > Gtk+ application with xanim, to make a video appear inside an
> > application, to do this, I need the window id of a widget, so I can pass
> > it as a parameter to xanim.
> 
> I've used the following method to retrieve the X window id before.
> But be aware that this is considered a no-no and may break in future
> versions of GTK+.  (Because I am using GdkWindowPrivate).
> 
> #include <gtk/gtk.h>
> #include <gdk/gdkprivate.h>
> 
> void DoSomething(GtkWindow *window) {
>   GdkWindowPrivate *private;
>   private = (GdkWindowPrivate *)window->window;
> 
>   DoSomethingWithXWindowHandle(private->xwindow);
> }

That _is_ a no-no. However,

#include <gtk/gtk.h>
#include <gdk/gdkx.h>

void DoSomething(GtkWindow *window) 
{
  /* Make sure window->window exists */
  gtk_widget_realize (window);
  /* Or gtk_widget_show (window), but only for toplevel widgets */

  DoSomethingWithXWindowID(GDK_WINDOW_XWINDOW (window->window));
}

Is only mildly discouraged. (That is, if you can do it through
GTK/GDK you should do it that way, but otherwise it is fine)

Regards,
                                        Owen



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