Integrating guile-gtk with other event loops




I hope this is an appropriate place for questions about guile-gtk; I
know of no more appropriate list.

I am trying to figure out a way to integrate guile-gtk's event loop
with another event loop, specifically that of scwm. I can now get
guile-gtk to load successfully and create windows, but the ways I've
come up with to integrate the event loops all seem hackish; the main
problem seems to be that there is a high tradeoff between ease of
implementation and correctness. Here are the three approaches I've
thought of:

* Add the following:

(lambda () 
  (while (not (= 0 (gtk-events-pending)))
	 (gtk-main-iteration)))

as a timer hook in scwm's event loop to make sure gtk events get
processed periodically (scwm has it's own notion of timer hooks
orthogonal to gtk/gdk's). The problem with this is that it
unnecessarily eats CPU and makes the gtk response sluggish.

* Write a mini-library that provides a function which returns the file
descriptor being used for gdk's X connection. Add an input hook to
scwm's event loop on this file descriptor which does the same as the
above solution.

* Write a dynamically loaded module that provides a hacked version of
gtk-main that uses scm_internal_select in place of select; this would
allow the gtk event loop and the scwm event loop to peacefully coexist
through Guile's cooperative threads.


Which is best? I think if the last solution is considered useful, it
may be worthwhile to provide it in guile-gtk itself so that other apps
that have their own event loops can use guile-gtk transparently.

 - Maciej Stachowiak



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