Skip to main content
GameDev.net gamedev.net
🔒 Locked

[SDL] Checking if Window is minimized

Started by Stompy9999 Mar 13, 2006 at 4:27 PM 6 replies 9.3k views
rip-off
rip-off
Either this, or if you only care about the transitions, this.

All courtesy of http://www.libsdl.org/cgi/docwiki.cgi/

Good Luck!
Lazy Foo
Lazy Foo
Use SDL_GetAppState() or SDL_ActiveEvent.

I have an example of using SDL_ActiveEvent here
Lazy Foo's SDL tutorials

[Edited by - Lazy Foo on August 9, 2007 11:51:12 PM]
Learn to make games with my SDL 2 Tutorials
Stompy9999
Stompy9999
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.
rip-off
rip-off
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
Lazy Foo
Lazy Foo
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 );            }        }
Learn to make games with my SDL 2 Tutorials

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.