Sign in to follow this  
Stompy9999

[SDL] Checking if Window is minimized

Recommended Posts

Thanks.

What I'm trying to do is pause my game whenever the window is minimized. I still can't seem to get it to work. It's probably very wrong, but here is the code I put in:


if(event.active.type == SDL_APPACTIVE)
if(event.active.gain == 0)
paused = true;



What happens with this is that it now pauses when the mouse leaves the window, but not when it is minimized.

Thanks again for any help.

Share this post


Link to post
Share on other sites
Quote:
Source: that link I gave you =)
state:
a bitmask of the following values: SDL_APPMOUSEFOCUS if mouse focus was gained or lost, SDL_APPINPUTFOCUS if input focus was gained or lost, and SDL_APPACTIVE if the application was iconified (gain=0) or restored(gain=1).


so that would make it


if(event.active.type == SDL_APPACTIVE)
if( (event.active.state & SDL_APPINPUTFOCUS) && (event.active.gain == 0) )
paused = true;



If I'm not mistaken

Share this post


Link to post
Share on other sites
The operation is bitwise

(pasted directly from the tutorial)

//If the window focus changed
else if( event.type == SDL_ACTIVEEVENT )
{
//If the window was inconified or restored
if( event.active.state & SDL_APPACTIVE )
{
//If the application is no longer active
if( event.active.gain == 0 )
{
SDL_WM_SetCaption( "Window Event Test: Iconified", NULL );
}
else
{
SDL_WM_SetCaption( "Window Event Test", NULL );
}
}

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