GTK + SDL revisited; no love for shawn

Hello,

I have been working on creating an SDL/GTK widget. My story will probably
sound familiar as I have seen a few similar posts on the SDL and GTK
lists.

The widget mostly works and is nearly a beautiful thing, but things fall
apart around the expose event handler. Based on debugging output and
calls to sleep(), it looks like: The SDL widget catches and handles the
expose event and correctly updates its surface, but then Gtk clears the
exposed area to the background color (grey). The Gtk documentation
mentions that ``GDK automatically clears the exposed area to the
background color before sending the expose event.’’ Its as though SDL is
beating Gtk to the finish line.

Things I have tried:

  • In an earlier post to this list, Sam suggests a solution: ``I ran into
    this with the Qt demo. Basically Gtk fires off a draw event on it’s X
    connection, and then SDL fires off it’s draw event. SDL’s completes
    first because the GTk drawing is defered to the next event loop update.
    What I did was call XSync(display, FALSE) in the Qt app before drawing
    with SDL.’’ I have tried calling XSync from within the expose handler
    as well as from within an expose wrapper.

  • Another common suggestion is to implement the SDL widget as a composite
    widget based on GtkDrawingArea OR just create a GtkDrawingArea and give
    SDL the drawing area X-window ID. Neither solution has worked for me.
    The results are the same: my SDL code does its thing correctly in the
    expose handler and then Gtk apparently clears the exposed area to the
    background color.

I am beginning to feel like I am flogging a dead horse, but I would really
like to use GTK + SDL to build my tools. Based on the confident
list-replies to earlier queries of this nature, it sounds like there are
others who have working GTK/SDL implementations. I would appreciate any
advice, hints, comments, etc.

Thank you!

shawn

I am beginning to feel like I am flogging a dead horse, but I would really
like to use GTK + SDL to build my tools. Based on the confident
list-replies to earlier queries of this nature, it sounds like there are
others who have working GTK/SDL implementations. I would appreciate any
advice, hints, comments, etc.

So does the gtk demo work for you?
http://www.libsdl.org/projects/gtk-demo/

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam,On Mon Dec 08, 2003 at 06:12:05PM -0800, Sam Lantinga wrote:

So does the gtk demo work for you?
http://www.libsdl.org/projects/gtk-demo/

Thank you for your response and the link to gtk-demo. Yes, the demo works
for me. But of course it works. You have registered a function with
gtk_idle_add- the application is updating the SDL screen surface nearly
all the time and failures to correctly expose the SDL window are quickly
hidden. I recognize that 1) this is the intent of the gtk-demo
application and 2) that this is a potential solution to the problem. But
I admit that in the case of an application like a tool- an application
that is likely to be idle most of the time- it kills me to have it just
hanging out at 100% cpu when idle.

Maybe an expose wrapper registered with g_signal_connect_after … I’ll
give that a try now.

Thanks again, and take care.

shawn