Mercurial > sdl-ios-xcode
annotate src/events/SDL_active.c @ 1312:c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
I batch edited these files, so please let me know if I've accidentally removed anybody's
credit here.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 01 Feb 2006 06:32:25 +0000 |
parents | 28ac87a38c17 |
children | 450721ad5436 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
23 /* Application focus/iconification handling code for SDL */ | |
24 | |
25 #include <stdio.h> | |
26 #include <string.h> | |
27 | |
28 #include "SDL_events.h" | |
29 #include "SDL_events_c.h" | |
30 | |
31 | |
32 /* These are static for our active event handling code */ | |
33 static Uint8 SDL_appstate = 0; | |
34 | |
35 /* Public functions */ | |
36 int SDL_AppActiveInit(void) | |
37 { | |
38 /* Start completely active */ | |
39 SDL_appstate = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); | |
40 | |
41 /* That's it! */ | |
42 return(0); | |
43 } | |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
44 void SDL_AppActiveQuit(void) |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
45 { |
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
46 } |
0 | 47 |
48 Uint8 SDL_GetAppState(void) | |
49 { | |
50 return(SDL_appstate); | |
51 } | |
52 | |
53 /* This is global for SDL_eventloop.c */ | |
54 int SDL_PrivateAppActive(Uint8 gain, Uint8 state) | |
55 { | |
56 int posted; | |
57 Uint8 new_state; | |
58 | |
59 /* Modify the current state with the given mask */ | |
60 if ( gain ) { | |
61 new_state = (SDL_appstate | state); | |
62 } else { | |
63 new_state = (SDL_appstate & ~state); | |
64 } | |
65 | |
66 /* Drop events that don't change state */ | |
67 if ( new_state == SDL_appstate ) { | |
68 return(0); | |
69 } | |
70 | |
71 /* Update internal active state */ | |
72 SDL_appstate = new_state; | |
73 | |
74 /* Post the event, if desired */ | |
75 posted = 0; | |
76 if ( SDL_ProcessEvents[SDL_ACTIVEEVENT] == SDL_ENABLE ) { | |
77 SDL_Event event; | |
78 memset(&event, 0, sizeof(event)); | |
79 event.type = SDL_ACTIVEEVENT; | |
80 event.active.gain = gain; | |
81 event.active.state = state; | |
82 if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { | |
83 posted = 1; | |
84 SDL_PushEvent(&event); | |
85 } | |
86 } | |
87 | |
88 /* If we lost keyboard focus, post key-up events */ | |
89 if ( (state & SDL_APPINPUTFOCUS) && !gain ) { | |
90 SDL_ResetKeyboard(); | |
91 } | |
92 return(posted); | |
93 } |