We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 158 - Unclear documentation for SDL_ActiveEvent, or bad behaviour
Summary: Unclear documentation for SDL_ActiveEvent, or bad behaviour
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: website (show other bugs)
Version: 1.2.9
Hardware: x86 Windows (XP)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-08 17:56 UTC by Sebastian Redl
Modified: 2006-05-16 03:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Redl 2006-03-08 17:56:56 UTC
The documentation of SDL_ActiveEvent's state member is:
"SDL_APPMOUSEFOCUS if mouse focus was gained or lost, SDL_APPINPUTFOCUS if input focus was gained or lost, or SDL_APPACTIVE if the application was iconified (gain=0) or restored(gain=1)."

The "or" leads the reader to believe that a == comparison with these constants is appropriate to detect these states, i.e. that one event is generated for each type of state change.

At least in the Windows implementation, this is not the case, though: an APPACTIVE state never comes alone, but is instead bit-or'ed together with APPMOUSEFOCUS. Code that looks like this doesn't work:

if(event.active.state == SDL_APPACTIVE) {
  active = event.active.gain != 0;
}

Either the Windows implementation is in error in that it creates mixed events (in my opinion, that is the case, as I don't think mixing events is a good idea), or the documentation is unclear or even faulty.
Comment 1 Sam Lantinga 2006-03-09 10:23:50 UTC
Where did you see that documentation?
The header has the following comment:
 * This function returns the current state of the application, which is a
 * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
 * SDL_APPACTIVE.  If SDL_APPACTIVE is set, then the user is able to
 * see your application, otherwise it has been iconified or disabled.
Comment 2 Sebastian Redl 2006-03-09 11:15:05 UTC
Here:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fActiveEvent
I'm not sure how authoritative the DocWiki is, but there seems to be no other online resource.
Comment 3 Sam Lantinga 2006-03-11 18:27:32 UTC
The Wiki has been updated, thanks.  BTW, you're welcome to correct the Wiki documentation if you find any errors in it.
Comment 4 Sebastian Redl 2006-03-11 19:00:57 UTC
I would have, but I didn't know whether it was a bug in the docs or the implementation. Will check the header next time.