[SDL] Suggestion for controlling display of windowed SDL during startup

Doug biteme at bitbasher.net
Tue Sep 12 01:13:31 PDT 2006

I'm developing two interrelated SDL apps.  One is the "main" app, the other 
acts as a sort of client (it's a video frame viewer, but that's not 
important).  I'm working in Win32 (for other reasons), but I'll try to make a 
suggestion that is portable to all platforms.

When my main app wants to start the viewer client, it's just a simple 
one-liner, like this:

   ShellExecute( NULL, NULL, szMyViewerAppName, NULL, NULL, SW_SHOWNA );

Now, I am trying to start the client app NO-ACTIVATE (SW_SHOWNA).  The client 
app starts, and WinMain's argument, nCmdShow, is set accordingly.

Unfortunately, there currently no way to communicate this to SDL, so it 
happily creates the SDL window in SHOW_NORMAL mode.  This has the nasty 
effect of stealing the focus from my main app (which I don't want), and 
nowadays in WinXP, trying to steal the focus back is not pretty.

What I'd like to suggest is a new SDL environment variable, say 
SDL_VIDEO_WINDOW_MODE, and it might have settings like:
   - NOACTIVATE   <-- I want, I want!

Then, all I have to do before calling SDL_INIT would be a simple,

   SDL_putenv( "SDL_VIDEO_WINDOW_MODE=noactivate" );

It would be up to the SDL code to decide if my passed setting is meaning full 
or not, so this could be quite portable.  Either the platform supports the 
window mode or it doesn't (and gracefully ignores it).

Of course, I could re-compile SDL and support this myself, but I'm trying to 
keep my app from requiring any special roll-your-own versions of SDL.

If there's a better way to possibly do this, well I'm open to any 
 - Doug

More information about the SDL mailing list