[SDL] Checking if Window is minimized

Started by
6 comments, last by Stompy9999 18 years, 1 month ago
How can you check if the program window is minimized in SDL? Thanks in advance.
-----------------------------Play Stompy's Revenge! Now!
Advertisement
Either this, or if you only care about the transitions, this.

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

Good Luck!
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

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

Ah, it works now[smile]

Thank you both very much.
-----------------------------Play Stompy's Revenge! Now!

This topic is closed to new replies.

Advertisement