Sign in to follow this  
gumpy

[sdl+opengl+windows]handling focus loss from fullscreen

Recommended Posts

gumpy    795
i'm trying to write a simple sdl+opengl framework for use under both windows and linux. i've done some searching and i can't figure out how to properly handle losing focus while in fullscreen using sdl and opengl in windows. if the screensaver kicks in or if i alt+tab, i can't switch back into my app. i'd like to prevent the screensaver from activating and be able to properly minimize the app and toggle fullscreen if possible (without mangling my gl context). does anyone know how to handle these problems or know someplace i can find info on these and other platform-specific issues?

Share this post


Link to post
Share on other sites
rip-off    10979
Quote:
Original post by gumpy macdrunken
i'm trying to write a simple sdl+opengl framework for use under both windows and linux. i've done some searching and i can't figure out how to properly handle losing focus while in fullscreen using sdl and opengl in windows. if the screensaver kicks in or if i alt+tab, i can't switch back into my app. i'd like to prevent the screensaver from activating and be able to properly minimize the app and toggle fullscreen if possible (without mangling my gl context). does anyone know how to handle these problems or know someplace i can find info on these and other platform-specific issues?


it has been suggested in the SDL development list to make the loss of an openGL context and textures a specific event that can be generated, but that won't happen for a while at best. you have 2 options, look at all the occansions in which you can lose an openGL context and re-init your GL settings and textures, or see if theres some hand-hack you can get to work to detect if it happened. either way its going to be ugly though...

good luck!

Share this post


Link to post
Share on other sites
Undeadlnsanity    233
In Windows, when the screensaver starts up, a message (SC_SCREENSAVER) is sent out to WM_SYSCOMMAND. If you catch this message and prevent it from happening, you are stopping the screensaver from activating whilst your application is running. Here's an example of how to do it:
switch (msg) // msg is our window message
{
case WM_SYSCOMMAND: // Interpret system commands
{
switch (wParam) // wParam is our additional message information
{
case SC_SCREENSAVER: // If the screensaver is trying to start...

return 0; // Stop it from starting
}
break; // Exit the switch-case
}
}


Good luck!

Share this post


Link to post
Share on other sites
gumpy    795
i've searched and experimented for hours but i still can't find a way to get back into my fullscreen app after it loses focus. alt+tab, screensaver, or an instant messenger window popping up causes me to completely/permanently lose access to my app. is there a way for sdl to handle this issue?

Share this post


Link to post
Share on other sites
rip-off    10979
Quote:
Original post by gumpy macdrunken
i've searched and experimented for hours but i still can't find a way to get back into my fullscreen app after it loses focus. alt+tab, screensaver, or an instant messenger window popping up causes me to completely/permanently lose access to my app. is there a way for sdl to handle this issue?


try calling SDL_SetVideoMode again. remember to resetup all the openGL parameters, textures etc.

Share this post


Link to post
Share on other sites
gumpy    795
i decided to watch all of the events, including windows events, and after i alt+tab out of the app it never recieves any more events even when clicking on the app on the taskbar. i'm completely lost here...

edit: no normal sdl event is generated when focus is lost in this way

Share this post


Link to post
Share on other sites
rip-off    10979
Quote:
Original post by gumpy macdrunken
i decided to watch all of the events, including windows events, and after i alt+tab out of the app it never recieves any more events even when clicking on the app on the taskbar. i'm completely lost here...

edit: no normal sdl event is generated when focus is lost in this way


if you include a certain header then SDL will forward an unprocessed OS messages in an OS-specific way.

see the functions outlined in SDL_syswm.h ( it is not automatically included, you have to include it yourself )

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this