Mercurial > sdl-ios-xcode
annotate docs/html/sdlcd.html @ 4139:568c9b3c0167 SDL-1.2
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
* Use XResetScreenSaver() instead of disabling screensaver entirely.
Full discussion summary from Erik on the SDL mailing list:
Current behaviour
=================
SDL changes the user's display power management settings without
permission from the user and without telling the user.
The interface that it uses to do so is DPMSDisable/DPMSEnable, which
should only ever be used by configuration utilities like KControl, never
by normal application programs, let alone by the libraries that they
use. Using an interface that is not at all intended for what SDL tries
to achieve means that it will not work as it should. Firstly, the power
management is completely disabled during the whole lifetime of the SDL
program, not only when it should be. Secondly, it makes SDL
non-reentrant, meaning that things will break when multiple SDL programs
are clients of the same X server simultaneously. Thirdly, no cleanup
mechanism ensures that the setting is restored if the client does not do
that (for example if it crashes).
In addition to that, this interface is broken on xorg,
[http://bugs.freedesktop.org/show_bug.cgi?id=13962], so what SDL tries
to do does not work at all on that implementation of the X Window
System. (The reason that the DPMSEnable works in KControl is that it
calls DPMSSetTimeout immediately after,
[http://websvn.kde.org/tags/KDE/3.5.9/kdebase/kcontrol/energy/energy.cpp?annotate=774532#l343]).
The problems that the current behaviour causes
==============================================
1. Information leak. When the user is away, someone might see what the
user has on the display when the user counts on the screensaver
preventing this. This does not even require physical access to the
workstation, it is enough to see it from a distance.
2. Draining battery. An SDL program that runs on a laptop will quickly
drain the battery while the user is away. The system will soon shut down
and require recharging before being usable again, while it should in
fact have consumed very little energy if the user's settings would have
been obeyed.
3. Wasting energy. Even if battery issues are not considered, energy as
such is wasted.
4. Display wear. The display may be worn out.
The problems that the current behaviour tries to solve
======================================================
1. Preventing screensaver while playing movies.
Many SDL applications are media players. They have reasons to prevent
screensavers from being activated while a movie is being played. When a
user clicks on the play button it can be interpreted as saying "play
this movie, but do not turn off the display while playing it, because I
will watch it even though I do not interact with the system".
2. Preventing screensaver when some input bypasses X.
Sometimes SDL uses input from another source than the X server, so
that the X server is bypassed. This obviously breaks the screensaver
handling. SDL tries to work around that.
3. Preventing screensaver when all input bypasses X.
There is something called Direct Graphics Access mode, where a
program takes control of both the display and the input devices from the
X server. This obviously means that the X server can not handle the
screensaver alone, since screensaver handling depends on input handling.
SDL does not do what it should to help the X server to handle the
screensaver. Nor does SDL take care of screeensaver handling itself. SDL
simply disables the screensaver completely.
How the problems should be solved
=================================
The correct way for an application program to prevent the screensaver
under X is to call XResetScreenSaver. This was recently discovered and
implemented by the mplayer developers,
[http://svn.mplayerhq.hu/mplayer?view=rev&revision=25637]. SDL needs to
wrap this in an API call (SDL_ResetScreenSaver) and implement it for the
other video targets (if they do not have a corresponding call, SDL
should do what it takes on that particular target, for example sending
fake key events).
1. When a movie is played, the player should reset the screensaver when
the animation is advanced to a new frame. The same applies to anything
similar, like slideshows.
2. When the X server is handling input, it must handle all input
(keyboards, mice, gamepads, ...). This is necessary, not only to be able
to handle the screensaver, but also so that it can send the events to
the correct (the currently active) client. If there is an input device
that the X server can not handle for some reason (such as lack of Plug
and Play capability), the program that handles the device as a
workaround must simulate what would happen if the X server would have
handled the device, by calling XResetScreenSaver when input is received
from the device.
3. When the X server is not handling the input, it depends on the
program that does to call XResetScreenSaver whenever an input event
occurs. Alternatively the program must handle the screensaver countdown
internally and call XActivateScreenSaver.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 29 Feb 2008 13:55:44 +0000 |
parents | 355632dca928 |
children |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_CD</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="CD-ROM" | |
14 HREF="cdrom.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_CDClose" | |
17 HREF="sdlcdclose.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_CDtrack" | |
20 HREF="sdlcdtrack.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
31 SUMMARY="Header navigation table" |
0 | 32 WIDTH="100%" |
33 BORDER="0" | |
34 CELLPADDING="0" | |
35 CELLSPACING="0" | |
36 ><TR | |
37 ><TH | |
38 COLSPAN="3" | |
39 ALIGN="center" | |
40 >SDL Library Documentation</TH | |
41 ></TR | |
42 ><TR | |
43 ><TD | |
44 WIDTH="10%" | |
45 ALIGN="left" | |
46 VALIGN="bottom" | |
47 ><A | |
48 HREF="sdlcdclose.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
49 ACCESSKEY="P" |
0 | 50 >Prev</A |
51 ></TD | |
52 ><TD | |
53 WIDTH="80%" | |
54 ALIGN="center" | |
55 VALIGN="bottom" | |
56 ></TD | |
57 ><TD | |
58 WIDTH="10%" | |
59 ALIGN="right" | |
60 VALIGN="bottom" | |
61 ><A | |
62 HREF="sdlcdtrack.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
63 ACCESSKEY="N" |
0 | 64 >Next</A |
65 ></TD | |
66 ></TR | |
67 ></TABLE | |
68 ><HR | |
69 ALIGN="LEFT" | |
70 WIDTH="100%"></DIV | |
71 ><H1 | |
72 ><A | |
73 NAME="SDLCD" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
74 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
75 >SDL_CD</H1 |
0 | 76 ><DIV |
77 CLASS="REFNAMEDIV" | |
78 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
79 NAME="AEN7566" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_CD -- CDROM Drive Information</DIV | |
84 ><DIV | |
85 CLASS="REFSECT1" | |
86 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
87 NAME="AEN7569" |
0 | 88 ></A |
89 ><H2 | |
90 >Structure Definition</H2 | |
91 ><PRE | |
92 CLASS="PROGRAMLISTING" | |
93 >typedef struct{ | |
94 int id; | |
95 CDstatus status; | |
96 int numtracks; | |
97 int cur_track; | |
98 int cur_frame; | |
99 SDL_CDtrack track[SDL_MAX_TRACKS+1]; | |
100 } SDL_CD;</PRE | |
101 ></DIV | |
102 ><DIV | |
103 CLASS="REFSECT1" | |
104 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
105 NAME="AEN7572" |
0 | 106 ></A |
107 ><H2 | |
108 >Structure Data</H2 | |
109 ><DIV | |
110 CLASS="INFORMALTABLE" | |
111 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
112 NAME="AEN7574" |
0 | 113 ></A |
114 ><P | |
115 ></P | |
116 ><TABLE | |
117 BORDER="0" | |
118 CLASS="CALSTABLE" | |
119 ><TBODY | |
120 ><TR | |
121 ><TD | |
122 ALIGN="LEFT" | |
123 VALIGN="TOP" | |
124 ><TT | |
125 CLASS="STRUCTFIELD" | |
126 ><I | |
127 >id</I | |
128 ></TT | |
129 ></TD | |
130 ><TD | |
131 ALIGN="LEFT" | |
132 VALIGN="TOP" | |
133 >Private drive identifier</TD | |
134 ></TR | |
135 ><TR | |
136 ><TD | |
137 ALIGN="LEFT" | |
138 VALIGN="TOP" | |
139 ><TT | |
140 CLASS="STRUCTFIELD" | |
141 ><I | |
142 >status</I | |
143 ></TT | |
144 ></TD | |
145 ><TD | |
146 ALIGN="LEFT" | |
147 VALIGN="TOP" | |
148 >Drive <A | |
149 HREF="sdlcdstatus.html" | |
150 >status</A | |
151 ></TD | |
152 ></TR | |
153 ><TR | |
154 ><TD | |
155 ALIGN="LEFT" | |
156 VALIGN="TOP" | |
157 ><TT | |
158 CLASS="STRUCTFIELD" | |
159 ><I | |
160 >numtracks</I | |
161 ></TT | |
162 ></TD | |
163 ><TD | |
164 ALIGN="LEFT" | |
165 VALIGN="TOP" | |
166 >Number of tracks on the CD</TD | |
167 ></TR | |
168 ><TR | |
169 ><TD | |
170 ALIGN="LEFT" | |
171 VALIGN="TOP" | |
172 ><TT | |
173 CLASS="STRUCTFIELD" | |
174 ><I | |
175 >cur_track</I | |
176 ></TT | |
177 ></TD | |
178 ><TD | |
179 ALIGN="LEFT" | |
180 VALIGN="TOP" | |
181 >Current track</TD | |
182 ></TR | |
183 ><TR | |
184 ><TD | |
185 ALIGN="LEFT" | |
186 VALIGN="TOP" | |
187 ><TT | |
188 CLASS="STRUCTFIELD" | |
189 ><I | |
190 >cur_frame</I | |
191 ></TT | |
192 ></TD | |
193 ><TD | |
194 ALIGN="LEFT" | |
195 VALIGN="TOP" | |
196 >Current frame offset within the track</TD | |
197 ></TR | |
198 ><TR | |
199 ><TD | |
200 ALIGN="LEFT" | |
201 VALIGN="TOP" | |
202 ><TT | |
203 CLASS="STRUCTFIELD" | |
204 ><I | |
205 >track</I | |
206 ></TT | |
207 >[SDL_MAX_TRACKS+1]</TD | |
208 ><TD | |
209 ALIGN="LEFT" | |
210 VALIGN="TOP" | |
211 >Array of track descriptions. (see <A | |
212 HREF="sdlcdtrack.html" | |
213 ><SPAN | |
214 CLASS="STRUCTNAME" | |
215 >SDL_CDtrack</SPAN | |
216 ></A | |
217 >)</TD | |
218 ></TR | |
219 ></TBODY | |
220 ></TABLE | |
221 ><P | |
222 ></P | |
223 ></DIV | |
224 ></DIV | |
225 ><DIV | |
226 CLASS="REFSECT1" | |
227 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
228 NAME="AEN7604" |
0 | 229 ></A |
230 ><H2 | |
231 >Description</H2 | |
232 ><P | |
233 >An <SPAN | |
234 CLASS="STRUCTNAME" | |
235 >SDL_CD</SPAN | |
236 > structure is returned by <A | |
237 HREF="sdlcdopen.html" | |
238 ><TT | |
239 CLASS="FUNCTION" | |
240 >SDL_CDOpen</TT | |
241 ></A | |
242 >. It represents an opened CDROM device and stores information on the layout of the tracks on the disc.</P | |
243 ><P | |
244 >A frame is the base data unit of a CD. <TT | |
245 CLASS="LITERAL" | |
246 >CD_FPS</TT | |
247 > frames is equal to 1 second of music. SDL provides two macros for converting between time and frames: <TT | |
248 CLASS="LITERAL" | |
249 >FRAMES_TO_MSF(f, M,S,F)</TT | |
250 > and <TT | |
251 CLASS="LITERAL" | |
252 >MSF_TO_FRAMES</TT | |
253 >.</P | |
254 ></DIV | |
255 ><DIV | |
256 CLASS="REFSECT1" | |
257 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
258 NAME="AEN7614" |
0 | 259 ></A |
260 ><H2 | |
261 >Examples</H2 | |
262 ><PRE | |
263 CLASS="PROGRAMLISTING" | |
264 >int min, sec, frame; | |
265 int frame_offset; | |
266 | |
267 FRAMES_TO_MSF(cdrom->cur_frame, &min, &sec, &frame); | |
268 printf("Current Position: %d minutes, %d seconds, %d frames\n", min, sec, frame); | |
269 | |
270 frame_offset=MSF_TO_FRAMES(min, sec, frame);</PRE | |
271 ></DIV | |
272 ><DIV | |
273 CLASS="REFSECT1" | |
274 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
275 NAME="AEN7617" |
0 | 276 ></A |
277 ><H2 | |
278 >See Also</H2 | |
279 ><P | |
280 ><A | |
281 HREF="sdlcdopen.html" | |
282 ><TT | |
283 CLASS="FUNCTION" | |
284 >SDL_CDOpen</TT | |
285 ></A | |
286 >, | |
287 <A | |
288 HREF="sdlcdtrack.html" | |
289 ><SPAN | |
290 CLASS="STRUCTNAME" | |
291 >SDL_CDtrack</SPAN | |
292 ></A | |
293 ></P | |
294 ></DIV | |
295 ><DIV | |
296 CLASS="NAVFOOTER" | |
297 ><HR | |
298 ALIGN="LEFT" | |
299 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
300 SUMMARY="Footer navigation table" |
0 | 301 WIDTH="100%" |
302 BORDER="0" | |
303 CELLPADDING="0" | |
304 CELLSPACING="0" | |
305 ><TR | |
306 ><TD | |
307 WIDTH="33%" | |
308 ALIGN="left" | |
309 VALIGN="top" | |
310 ><A | |
311 HREF="sdlcdclose.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
312 ACCESSKEY="P" |
0 | 313 >Prev</A |
314 ></TD | |
315 ><TD | |
316 WIDTH="34%" | |
317 ALIGN="center" | |
318 VALIGN="top" | |
319 ><A | |
320 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
321 ACCESSKEY="H" |
0 | 322 >Home</A |
323 ></TD | |
324 ><TD | |
325 WIDTH="33%" | |
326 ALIGN="right" | |
327 VALIGN="top" | |
328 ><A | |
329 HREF="sdlcdtrack.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
330 ACCESSKEY="N" |
0 | 331 >Next</A |
332 ></TD | |
333 ></TR | |
334 ><TR | |
335 ><TD | |
336 WIDTH="33%" | |
337 ALIGN="left" | |
338 VALIGN="top" | |
339 >SDL_CDClose</TD | |
340 ><TD | |
341 WIDTH="34%" | |
342 ALIGN="center" | |
343 VALIGN="top" | |
344 ><A | |
345 HREF="cdrom.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
346 ACCESSKEY="U" |
0 | 347 >Up</A |
348 ></TD | |
349 ><TD | |
350 WIDTH="33%" | |
351 ALIGN="right" | |
352 VALIGN="top" | |
353 >SDL_CDtrack</TD | |
354 ></TR | |
355 ></TABLE | |
356 ></DIV | |
357 ></BODY | |
358 ></HTML | |
359 > |