Re: [gtk-list] Xwindow as GTK Widget



There are probably other solutions to this problem, but here's mine ;)

Any events which are suppose to happen in the astro window are going to
get by the GDK event loop, and translated into GDK events from X events.
It would be nice to have a GDK->X event translater, but we don't.

The solution is to create a drawing widget (GTK), then use some of gdk's
private includes to gain access to the X window ID.  Then open up a new
connection to the X display within your program and create a X window as a
child of the drawing widget's window, and let the astronomical graphics
subroutine library draw on top of that.  You can get the events by
grabbing the file descriptor of your newly formed X display connection and
creating a callback on the file descriptor using gdk_input_add.

Just a personal opinion here, but it would be useful to add some hooks
into GDK to help support plug-in graphics libraries like this.  This could
be done by:

1) if a flag is set for a widget, have an additional callback with the X
event; this would be just a void pointer to GTK so the abstraction level
isn't broken.

2) make gdk aware of the "create child window" events in X, and
automagicly associate those X windows with the widget's window they were
created on top of so X events get propagated to the correct widget.

-----------------------------------------------------------------------
Jay Painter -- jpaint@serv.net -- jpaint@gimp.org -- jpaint@real.com
http://www.serv.net/~jpaint

On Fri, 19 Jun 1998, Jeffrey Larsen wrote:

> 
> I'm trying to use GTK to wrap our project's real-time asteroid
> detection code.  One problem I can't solve though...
> 
> Our incoming pixel data is displayed on an X window using an
> astronomical graphics subroutine library I don't want to mess 
> with.  I would like the X window to be responsive to GTK events 
> (in particular mouse clicks).  I have the Xdisplay and Xwindow
> ID's for the X window but can't see how to turn this into a usable
> GTK widget.  How can one do this?
> 
> I've examined gdkx.h and I'm still in the dark.  Help?
> 
> Regards,
> 
> Jeff
> 
> ---------------------------------------------------------------------------
> Dr. Jeffrey Larsen                              jlarsen@lpl.arizona.edu
> Spacewatch Project                              Telephone: (520) 621-3384
> Lunar and Planetary Laboratory                  FAX:  (520) 621-1940
> University of Arizona                                          
> Tucson, Arizona 85721                    
> 
> "Whether they ever find life there or not, I think Jupiter should be 
> considered an enemy planet."
> 				-- Jack Handey (Saturday Night Live)
> ---------------------------------------------------------------------------
> 
> 
> -- 
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null
> 
> 



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