Mercurial > sdl-ios-xcode
annotate docs/html/sdllistmodes.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_ListModes</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_VideoDriverName" | |
17 HREF="sdlvideodrivername.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_VideoModeOK" | |
20 HREF="sdlvideomodeok.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="sdlvideodrivername.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="sdlvideomodeok.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="SDLLISTMODES" | |
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_ListModes</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="AEN1159" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_ListModes -- Returns a pointer to an array of available screen dimensions for | |
84 the given format and video flags</DIV | |
85 ><DIV | |
86 CLASS="REFSYNOPSISDIV" | |
87 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
88 NAME="AEN1162" |
0 | 89 ></A |
90 ><H2 | |
91 >Synopsis</H2 | |
92 ><DIV | |
93 CLASS="FUNCSYNOPSIS" | |
94 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
95 NAME="AEN1163" |
0 | 96 ></A |
97 ><P | |
98 ></P | |
99 ><PRE | |
100 CLASS="FUNCSYNOPSISINFO" | |
101 >#include "SDL.h"</PRE | |
102 ><P | |
103 ><CODE | |
104 ><CODE | |
105 CLASS="FUNCDEF" | |
106 >SDL_Rect **<B | |
107 CLASS="FSFUNC" | |
108 >SDL_ListModes</B | |
109 ></CODE | |
110 >(SDL_PixelFormat *format, Uint32 flags);</CODE | |
111 ></P | |
112 ><P | |
113 ></P | |
114 ></DIV | |
115 ></DIV | |
116 ><DIV | |
117 CLASS="REFSECT1" | |
118 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
119 NAME="AEN1169" |
0 | 120 ></A |
121 ><H2 | |
122 >Description</H2 | |
123 ><P | |
124 >Return a pointer to an array of available screen dimensions for the given | |
125 format and video flags, sorted largest to smallest. Returns | |
126 <TT | |
127 CLASS="LITERAL" | |
128 >NULL</TT | |
129 > if there are no dimensions available for a particular | |
130 format, or <SPAN | |
131 CLASS="RETURNVALUE" | |
132 >-1</SPAN | |
133 > if any dimension is okay for | |
134 the given format.</P | |
135 ><P | |
136 >If <TT | |
137 CLASS="PARAMETER" | |
138 ><I | |
139 >format</I | |
140 ></TT | |
141 > is <TT | |
142 CLASS="LITERAL" | |
143 >NULL</TT | |
144 >, the mode list | |
145 will be for the format returned by <A | |
146 HREF="sdlgetvideoinfo.html" | |
147 >SDL_GetVideoInfo()</A | |
148 >-><TT | |
149 CLASS="STRUCTFIELD" | |
150 ><I | |
151 >vfmt</I | |
152 ></TT | |
153 >. The <TT | |
154 CLASS="PARAMETER" | |
155 ><I | |
156 >flag</I | |
157 ></TT | |
158 > parameter is an OR'd combination of <A | |
159 HREF="sdlsurface.html" | |
160 >surface</A | |
161 > flags. The flags are the same as those used <A | |
162 HREF="sdlsetvideomode.html" | |
163 ><TT | |
164 CLASS="FUNCTION" | |
165 >SDL_SetVideoMode</TT | |
166 ></A | |
167 > and they play a strong role in deciding what modes are valid. For instance, if you pass <TT | |
168 CLASS="LITERAL" | |
169 >SDL_HWSURFACE</TT | |
170 > as a flag only modes that support hardware video surfaces will be returned.</P | |
171 ></DIV | |
172 ><DIV | |
173 CLASS="REFSECT1" | |
174 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
175 NAME="AEN1184" |
0 | 176 ></A |
177 ><H2 | |
178 >Example</H2 | |
179 ><PRE | |
180 CLASS="PROGRAMLISTING" | |
181 >SDL_Rect **modes; | |
182 int i; | |
183 . | |
184 . | |
185 . | |
186 | |
187 /* Get available fullscreen/hardware modes */ | |
188 modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); | |
189 | |
190 /* Check is there are any modes available */ | |
191 if(modes == (SDL_Rect **)0){ | |
192 printf("No modes available!\n"); | |
193 exit(-1); | |
194 } | |
195 | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
196 /* Check if our resolution is restricted */ |
0 | 197 if(modes == (SDL_Rect **)-1){ |
198 printf("All resolutions available.\n"); | |
199 } | |
200 else{ | |
201 /* Print valid modes */ | |
202 printf("Available Modes\n"); | |
203 for(i=0;modes[i];++i) | |
204 printf(" %d x %d\n", modes[i]->w, modes[i]->h); | |
205 } | |
206 . | |
207 .</PRE | |
208 ></DIV | |
209 ><DIV | |
210 CLASS="REFSECT1" | |
211 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
212 NAME="AEN1187" |
0 | 213 ></A |
214 ><H2 | |
215 >See Also</H2 | |
216 ><P | |
217 ><A | |
218 HREF="sdlsetvideomode.html" | |
219 ><TT | |
220 CLASS="FUNCTION" | |
221 >SDL_SetVideoMode</TT | |
222 ></A | |
223 >, | |
224 <A | |
225 HREF="sdlgetvideoinfo.html" | |
226 ><TT | |
227 CLASS="FUNCTION" | |
228 >SDL_GetVideoInfo</TT | |
229 ></A | |
230 >, | |
231 <A | |
232 HREF="sdlrect.html" | |
233 ><SPAN | |
234 CLASS="STRUCTNAME" | |
235 >SDL_Rect</SPAN | |
236 ></A | |
237 >, | |
238 <A | |
239 HREF="sdlpixelformat.html" | |
240 ><SPAN | |
241 CLASS="STRUCTNAME" | |
242 >SDL_PixelFormat</SPAN | |
243 ></A | |
244 ></P | |
245 ></DIV | |
246 ><DIV | |
247 CLASS="NAVFOOTER" | |
248 ><HR | |
249 ALIGN="LEFT" | |
250 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
251 SUMMARY="Footer navigation table" |
0 | 252 WIDTH="100%" |
253 BORDER="0" | |
254 CELLPADDING="0" | |
255 CELLSPACING="0" | |
256 ><TR | |
257 ><TD | |
258 WIDTH="33%" | |
259 ALIGN="left" | |
260 VALIGN="top" | |
261 ><A | |
262 HREF="sdlvideodrivername.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
263 ACCESSKEY="P" |
0 | 264 >Prev</A |
265 ></TD | |
266 ><TD | |
267 WIDTH="34%" | |
268 ALIGN="center" | |
269 VALIGN="top" | |
270 ><A | |
271 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
272 ACCESSKEY="H" |
0 | 273 >Home</A |
274 ></TD | |
275 ><TD | |
276 WIDTH="33%" | |
277 ALIGN="right" | |
278 VALIGN="top" | |
279 ><A | |
280 HREF="sdlvideomodeok.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
281 ACCESSKEY="N" |
0 | 282 >Next</A |
283 ></TD | |
284 ></TR | |
285 ><TR | |
286 ><TD | |
287 WIDTH="33%" | |
288 ALIGN="left" | |
289 VALIGN="top" | |
290 >SDL_VideoDriverName</TD | |
291 ><TD | |
292 WIDTH="34%" | |
293 ALIGN="center" | |
294 VALIGN="top" | |
295 ><A | |
296 HREF="video.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
297 ACCESSKEY="U" |
0 | 298 >Up</A |
299 ></TD | |
300 ><TD | |
301 WIDTH="33%" | |
302 ALIGN="right" | |
303 VALIGN="top" | |
304 >SDL_VideoModeOK</TD | |
305 ></TR | |
306 ></TABLE | |
307 ></DIV | |
308 ></BODY | |
309 ></HTML | |
310 > |