• Advertisement
Sign in to follow this  

[SDL] Checking if Window is minimized

This topic is 4366 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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
I tried it, but it didn't work. I'll look over that link again and see if I can work it out.

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
Sign in to follow this  

  • Advertisement