GTK/SDL Window Repainting

Hi,

I’ve been developing a SDL app that works within a GTK window. The
application consists of a single GTK window with a menu. I use SDL to draw
in the window. I can successfully use the SDL/GTK window id environment
variable to get SDL to draw in the window.

The window is relatively large so I choose to draw the whole window
initially and then only update a subsection of it for performance reasons. I
capture the window expose event to redraw the whole screen as required.
However when I access the window menu and then leave the menu it leaves a
gray box where the menu was. Similarly when the window is partially covered
by another and I bring the GTK/SDL window back to the foreground I can see
it being redrawn by SDL then GTK over the top.(It leaves a gray area)

I can see the GTK event being raised which I then redraw the screen then the
gray box appears afterwards. After doing some investigation I think this is
because GTK fires off the event then does its own redrawing after the signal
handler has completed. Looking at the GTK documentation they recommend using
a GTK Drawing Area Widget which GTK will do no drawing. (More info:
http://www.gtk.org/tutorial/sec-thedrawingareawidget.html)

I modified my application to use a GTK Drawing Area Widget over the main
window but then none of the SDL drawing shows through (maybe GTK is drawing
it then drawing the GtkDrawingArea over the top of it?)

I have tried changing the exported window id to that of the Drawable area
but that has caused the program to exit when attempting to call
SDL_SetVideoMode() with a BadWindow error.

Any ideas on the how to do this would be greatly appreciated.

Thanks,

John._________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail

I’ve been developing a SDL app that works within a GTK window. The
application consists of a single GTK window with a menu. I use SDL to draw
in the window. I can successfully use the SDL/GTK window id environment
variable to get SDL to draw in the window.

The window is relatively large so I choose to draw the whole window
initially and then only update a subsection of it for performance reasons. I
capture the window expose event to redraw the whole screen as required.
However when I access the window menu and then leave the menu it leaves a
gray box where the menu was. Similarly when the window is partially covered
by another and I bring the GTK/SDL window back to the foreground I can see
it being redrawn by SDL then GTK over the top.(It leaves a gray area)

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.

Ideally you could share the X11 display connection with SDL, but SDL does
lots of event processing internally that would conflict with the toolkit.

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