[SDL] Checking if Window is minimized
Either this, or if you only care about the transitions, this.
All courtesy of http://www.libsdl.org/cgi/docwiki.cgi/
Good Luck!
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]
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]
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:
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.
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.
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
The operation is bitwise
(pasted directly from the tutorial)
(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 ); } }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement