[SDL] GTK/SDL Window Repainting

Sam Lantinga slouken at devolution.com
Tue Jan 21 09:24:02 PST 2003

> 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

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

More information about the SDL mailing list