Mercurial > sdl-ios-xcode
annotate docs/html/sdloverlay.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_Overlay</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="Video" | |
14 HREF="video.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_VideoInfo" | |
17 HREF="sdlvideoinfo.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="Window Management" | |
20 HREF="wm.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="sdlvideoinfo.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="wm.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="SDLOVERLAY" | |
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_Overlay</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="AEN3464" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_Overlay -- YUV video overlay</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="AEN3467" |
0 | 88 ></A |
89 ><H2 | |
90 >Structure Definition</H2 | |
91 ><PRE | |
92 CLASS="PROGRAMLISTING" | |
93 >typedef struct{ | |
94 Uint32 format; | |
95 int w, h; | |
96 int planes; | |
97 Uint16 *pitches; | |
98 Uint8 **pixels; | |
99 Uint32 hw_overlay:1; | |
100 } SDL_Overlay;</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="AEN3470" |
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="AEN3472" |
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 >format</I | |
128 ></TT | |
129 ></TD | |
130 ><TD | |
131 ALIGN="LEFT" | |
132 VALIGN="TOP" | |
133 >Overlay format (see below)</TD | |
134 ></TR | |
135 ><TR | |
136 ><TD | |
137 ALIGN="LEFT" | |
138 VALIGN="TOP" | |
139 ><TT | |
140 CLASS="STRUCTFIELD" | |
141 ><I | |
142 >w, h</I | |
143 ></TT | |
144 ></TD | |
145 ><TD | |
146 ALIGN="LEFT" | |
147 VALIGN="TOP" | |
148 >Width and height of overlay</TD | |
149 ></TR | |
150 ><TR | |
151 ><TD | |
152 ALIGN="LEFT" | |
153 VALIGN="TOP" | |
154 ><TT | |
155 CLASS="STRUCTFIELD" | |
156 ><I | |
157 >planes</I | |
158 ></TT | |
159 ></TD | |
160 ><TD | |
161 ALIGN="LEFT" | |
162 VALIGN="TOP" | |
163 >Number of planes in the overlay. Usually either 1 or 3</TD | |
164 ></TR | |
165 ><TR | |
166 ><TD | |
167 ALIGN="LEFT" | |
168 VALIGN="TOP" | |
169 ><TT | |
170 CLASS="STRUCTFIELD" | |
171 ><I | |
172 >pitches</I | |
173 ></TT | |
174 ></TD | |
175 ><TD | |
176 ALIGN="LEFT" | |
177 VALIGN="TOP" | |
178 >An array of pitches, one for each plane. Pitch is the length of a row in bytes.</TD | |
179 ></TR | |
180 ><TR | |
181 ><TD | |
182 ALIGN="LEFT" | |
183 VALIGN="TOP" | |
184 ><TT | |
185 CLASS="STRUCTFIELD" | |
186 ><I | |
187 >pixels</I | |
188 ></TT | |
189 ></TD | |
190 ><TD | |
191 ALIGN="LEFT" | |
192 VALIGN="TOP" | |
193 >An array of pointers to teh data of each plane. The overlay should be locked before these pointers are used.</TD | |
194 ></TR | |
195 ><TR | |
196 ><TD | |
197 ALIGN="LEFT" | |
198 VALIGN="TOP" | |
199 ><TT | |
200 CLASS="STRUCTFIELD" | |
201 ><I | |
202 >hw_overlay</I | |
203 ></TT | |
204 ></TD | |
205 ><TD | |
206 ALIGN="LEFT" | |
207 VALIGN="TOP" | |
208 >This will be set to 1 if the overlay is hardware accelerated.</TD | |
209 ></TR | |
210 ></TBODY | |
211 ></TABLE | |
212 ><P | |
213 ></P | |
214 ></DIV | |
215 ></DIV | |
216 ><DIV | |
217 CLASS="REFSECT1" | |
218 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
219 NAME="AEN3499" |
0 | 220 ></A |
221 ><H2 | |
222 >Description</H2 | |
223 ><P | |
224 >A <SPAN | |
225 CLASS="STRUCTNAME" | |
226 >SDL_Overlay</SPAN | |
227 > is similar to a <A | |
228 HREF="sdlsurface.html" | |
229 ><SPAN | |
230 CLASS="STRUCTNAME" | |
231 >SDL_Surface</SPAN | |
232 ></A | |
233 > except it stores a YUV overlay. All the fields are read only, except for <TT | |
234 CLASS="STRUCTFIELD" | |
235 ><I | |
236 >pixels</I | |
237 ></TT | |
238 > which should be <A | |
239 HREF="sdllockyuvoverlay.html" | |
240 >locked</A | |
241 > before use. The <TT | |
242 CLASS="STRUCTFIELD" | |
243 ><I | |
244 >format</I | |
245 ></TT | |
246 > field stores the format of the overlay which is one of the following: | |
247 <PRE | |
248 CLASS="PROGRAMLISTING" | |
249 >#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U */ | |
250 #define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V */ | |
251 #define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 */ | |
252 #define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 */ | |
253 #define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 */</PRE | |
254 > | |
255 More information on YUV formats can be found at <A | |
256 HREF="http://www.webartz.com/fourcc/indexyuv.htm" | |
257 TARGET="_top" | |
258 >http://www.webartz.com/fourcc/indexyuv.htm</A | |
259 >.</P | |
260 ></DIV | |
261 ><DIV | |
262 CLASS="REFSECT1" | |
263 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
264 NAME="AEN3510" |
0 | 265 ></A |
266 ><H2 | |
267 >See Also</H2 | |
268 ><P | |
269 ><A | |
270 HREF="sdlcreateyuvoverlay.html" | |
271 ><TT | |
272 CLASS="FUNCTION" | |
273 >SDL_CreateYUVOverlay</TT | |
274 ></A | |
275 >, | |
276 <A | |
277 HREF="sdllockyuvoverlay.html" | |
278 ><TT | |
279 CLASS="FUNCTION" | |
280 >SDL_LockYUVOverlay</TT | |
281 ></A | |
282 >, | |
283 <A | |
284 HREF="sdlunlockyuvoverlay.html" | |
285 ><TT | |
286 CLASS="FUNCTION" | |
287 >SDL_UnlockYUVOverlay</TT | |
288 ></A | |
289 >, | |
290 <A | |
291 HREF="sdlfreeyuvoverlay.html" | |
292 ><TT | |
293 CLASS="FUNCTION" | |
294 >SDL_FreeYUVOverlay</TT | |
295 ></A | |
296 ></P | |
297 ></DIV | |
298 ><DIV | |
299 CLASS="NAVFOOTER" | |
300 ><HR | |
301 ALIGN="LEFT" | |
302 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
303 SUMMARY="Footer navigation table" |
0 | 304 WIDTH="100%" |
305 BORDER="0" | |
306 CELLPADDING="0" | |
307 CELLSPACING="0" | |
308 ><TR | |
309 ><TD | |
310 WIDTH="33%" | |
311 ALIGN="left" | |
312 VALIGN="top" | |
313 ><A | |
314 HREF="sdlvideoinfo.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
315 ACCESSKEY="P" |
0 | 316 >Prev</A |
317 ></TD | |
318 ><TD | |
319 WIDTH="34%" | |
320 ALIGN="center" | |
321 VALIGN="top" | |
322 ><A | |
323 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
324 ACCESSKEY="H" |
0 | 325 >Home</A |
326 ></TD | |
327 ><TD | |
328 WIDTH="33%" | |
329 ALIGN="right" | |
330 VALIGN="top" | |
331 ><A | |
332 HREF="wm.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
333 ACCESSKEY="N" |
0 | 334 >Next</A |
335 ></TD | |
336 ></TR | |
337 ><TR | |
338 ><TD | |
339 WIDTH="33%" | |
340 ALIGN="left" | |
341 VALIGN="top" | |
342 >SDL_VideoInfo</TD | |
343 ><TD | |
344 WIDTH="34%" | |
345 ALIGN="center" | |
346 VALIGN="top" | |
347 ><A | |
348 HREF="video.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
349 ACCESSKEY="U" |
0 | 350 >Up</A |
351 ></TD | |
352 ><TD | |
353 WIDTH="33%" | |
354 ALIGN="right" | |
355 VALIGN="top" | |
356 >Window Management</TD | |
357 ></TR | |
358 ></TABLE | |
359 ></DIV | |
360 ></BODY | |
361 ></HTML | |
362 > |