Mercurial > sdl-ios-xcode
annotate docs/html/sdlinit.html @ 1212:7663bb0f52c7
To: sdl@libsdl.org
From: Christian Walther <cwalther@gmx.ch>
Date: Thu, 15 Dec 2005 21:19:53 +0100
Subject: [SDL] More mouse enhancements for Mac OS X
The attached patch brings two more enhancements to mouse handling on Mac
OS X (Quartz):
1. Currently, after launching an SDL application, SDL's notion of the
mouse position is stuck in the top left corner (0,0) until the first
time the mouse is moved. That's because the UpdateMouse() function isn't
implemented in the Quartz driver. This patch adds it.
2. When grabbing input while the mouse cursor is hidden, the function
CGAssociateMouseAndMouseCursorPosition(0) is called, which prevents the
system's notion of the mouse location from moving (and therefore leaving
the SDL window) even when the mouse is moved. However, apparently the
Wacom tablet driver (and maybe other special pointing device drivers)
doesn't care about that setting and still allows the mouse location to
go outside of the window. Interestingly, the system cursor, which is
made visible by the existing code in SDL in that case, does not follow
the mouse location, but appears in the middle of the SDL window. The
mouse location being outside of the window however means that mouse
button events go to background applications (or the dock or whatever is
there), which is very confusing to the user who sees no cursor outside
of the SDL window.
I have not found any way of intercepting these events (and that's
probably by design, as "normal" applications shouldn't prevent the user
from bringing other applications' windows to the front by clicking on
them). An idea would be placing a fully transparent, screen-filling
window in front of everything, but I fear that this might affect
rendering performance (by doing unnecessary compositing, using up
memory, or whatever).
The deluxe solution to the problem would be talking to the tablet
driver using AppleEvents to tell it to constrain its mapped area to the
window (see Wacom's "TabletEventDemo" sample app,
http://www.wacomeng.com/devsupport/mac/downloads.html), but I think that
the bloat that solution would add to SDL would outweigh its usefulness.
What I did instead in my patch is reassociating mouse and cursor when
the mouse leaves the window while an invisible grab is in effect, and
restoring the grab when the window is entered. That way, the grab can
still be effectively broken by a tablet, but at least it's obvious to
the user that it is broken. That change is minimal - it doesn't affect
operation with a mouse (or a trackpad), and the code that it adds is not
executed on every PumpEvents() call, only when entering and leaving the
window.
Unless there are any concerns about the patch, please apply. Feel free
to shorten the lengthy comment in SDL_QuartzEvents.m if you think it's
too verbose.
Thanks
-Christian
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 02 Jan 2006 00:31:00 +0000 |
parents | 355632dca928 |
children |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_Init</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
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="General" | |
14 HREF="general.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="General" | |
17 HREF="general.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_InitSubSystem" | |
20 HREF="sdlinitsubsystem.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:
55
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="general.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
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="sdlinitsubsystem.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
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="SDLINIT" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
74 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
75 >SDL_Init</H1 |
0 | 76 ><DIV |
77 CLASS="REFNAMEDIV" | |
78 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
79 NAME="AEN440" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_Init -- Initializes SDL</DIV | |
84 ><DIV | |
85 CLASS="REFSYNOPSISDIV" | |
86 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
87 NAME="AEN443" |
0 | 88 ></A |
89 ><H2 | |
90 >Synopsis</H2 | |
91 ><DIV | |
92 CLASS="FUNCSYNOPSIS" | |
93 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
94 NAME="AEN444" |
0 | 95 ></A |
96 ><P | |
97 ></P | |
98 ><PRE | |
99 CLASS="FUNCSYNOPSISINFO" | |
100 >#include "SDL.h"</PRE | |
101 ><P | |
102 ><CODE | |
103 ><CODE | |
104 CLASS="FUNCDEF" | |
105 >int <B | |
106 CLASS="FSFUNC" | |
107 >SDL_Init</B | |
108 ></CODE | |
109 >(Uint32 flags);</CODE | |
110 ></P | |
111 ><P | |
112 ></P | |
113 ></DIV | |
114 ></DIV | |
115 ><DIV | |
116 CLASS="REFSECT1" | |
117 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
118 NAME="AEN450" |
0 | 119 ></A |
120 ><H2 | |
121 >Description</H2 | |
122 ><P | |
123 >Initializes SDL. This should be called before all other SDL functions. The <TT | |
124 CLASS="PARAMETER" | |
125 ><I | |
126 >flags</I | |
127 ></TT | |
128 > parameter specifies what part(s) of SDL to initialize.</P | |
129 ><DIV | |
130 CLASS="INFORMALTABLE" | |
131 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
132 NAME="AEN454" |
0 | 133 ></A |
134 ><P | |
135 ></P | |
136 ><TABLE | |
137 BORDER="1" | |
138 CLASS="CALSTABLE" | |
139 ><TBODY | |
140 ><TR | |
141 ><TD | |
142 ALIGN="LEFT" | |
143 VALIGN="TOP" | |
144 ><TT | |
145 CLASS="LITERAL" | |
146 >SDL_INIT_TIMER</TT | |
147 ></TD | |
148 ><TD | |
149 ALIGN="LEFT" | |
150 VALIGN="TOP" | |
151 >Initializes the <A | |
152 HREF="time.html" | |
153 >timer</A | |
154 > subsystem.</TD | |
155 ></TR | |
156 ><TR | |
157 ><TD | |
158 ALIGN="LEFT" | |
159 VALIGN="TOP" | |
160 ><TT | |
161 CLASS="LITERAL" | |
162 >SDL_INIT_AUDIO</TT | |
163 ></TD | |
164 ><TD | |
165 ALIGN="LEFT" | |
166 VALIGN="TOP" | |
167 >Initializes the <A | |
168 HREF="audio.html" | |
169 >audio</A | |
170 > subsystem.</TD | |
171 ></TR | |
172 ><TR | |
173 ><TD | |
174 ALIGN="LEFT" | |
175 VALIGN="TOP" | |
176 ><TT | |
177 CLASS="LITERAL" | |
178 >SDL_INIT_VIDEO</TT | |
179 ></TD | |
180 ><TD | |
181 ALIGN="LEFT" | |
182 VALIGN="TOP" | |
183 >Initializes the <A | |
184 HREF="video.html" | |
185 >video</A | |
186 > subsystem.</TD | |
187 ></TR | |
188 ><TR | |
189 ><TD | |
190 ALIGN="LEFT" | |
191 VALIGN="TOP" | |
192 ><TT | |
193 CLASS="LITERAL" | |
194 >SDL_INIT_CDROM</TT | |
195 ></TD | |
196 ><TD | |
197 ALIGN="LEFT" | |
198 VALIGN="TOP" | |
199 >Initializes the <A | |
200 HREF="cdrom.html" | |
201 >cdrom</A | |
202 > subsystem.</TD | |
203 ></TR | |
204 ><TR | |
205 ><TD | |
206 ALIGN="LEFT" | |
207 VALIGN="TOP" | |
208 ><TT | |
209 CLASS="LITERAL" | |
210 >SDL_INIT_JOYSTICK</TT | |
211 ></TD | |
212 ><TD | |
213 ALIGN="LEFT" | |
214 VALIGN="TOP" | |
215 >Initializes the <A | |
216 HREF="joystick.html" | |
217 >joystick</A | |
218 > subsystem.</TD | |
219 ></TR | |
220 ><TR | |
221 ><TD | |
222 ALIGN="LEFT" | |
223 VALIGN="TOP" | |
224 ><TT | |
225 CLASS="LITERAL" | |
226 >SDL_INIT_EVERYTHING</TT | |
227 ></TD | |
228 ><TD | |
229 ALIGN="LEFT" | |
230 VALIGN="TOP" | |
231 >Initialize all of the above.</TD | |
232 ></TR | |
233 ><TR | |
234 ><TD | |
235 ALIGN="LEFT" | |
236 VALIGN="TOP" | |
237 ><TT | |
238 CLASS="LITERAL" | |
239 >SDL_INIT_NOPARACHUTE</TT | |
240 ></TD | |
241 ><TD | |
242 ALIGN="LEFT" | |
243 VALIGN="TOP" | |
244 >Prevents SDL from catching fatal signals.</TD | |
245 ></TR | |
246 ><TR | |
247 ><TD | |
248 ALIGN="LEFT" | |
249 VALIGN="TOP" | |
250 ><TT | |
251 CLASS="LITERAL" | |
252 >SDL_INIT_EVENTTHREAD</TT | |
253 ></TD | |
254 ><TD | |
255 ALIGN="LEFT" | |
256 VALIGN="TOP" | |
257 > </TD | |
258 ></TR | |
259 ></TBODY | |
260 ></TABLE | |
261 ><P | |
262 ></P | |
263 ></DIV | |
264 ></DIV | |
265 ><DIV | |
266 CLASS="REFSECT1" | |
267 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
268 NAME="AEN494" |
0 | 269 ></A |
270 ><H2 | |
271 >Return Value</H2 | |
272 ><P | |
273 >Returns <SPAN | |
274 CLASS="RETURNVALUE" | |
275 >-1</SPAN | |
276 > on an error or <SPAN | |
277 CLASS="RETURNVALUE" | |
278 >0</SPAN | |
279 > on success.</P | |
280 ></DIV | |
281 ><DIV | |
282 CLASS="REFSECT1" | |
283 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
284 NAME="AEN499" |
0 | 285 ></A |
286 ><H2 | |
287 >See Also</H2 | |
288 ><P | |
289 ><A | |
290 HREF="sdlquit.html" | |
291 ><TT | |
292 CLASS="FUNCTION" | |
293 >SDL_Quit</TT | |
294 ></A | |
295 >, | |
296 <A | |
297 HREF="sdlinitsubsystem.html" | |
298 ><TT | |
299 CLASS="FUNCTION" | |
300 >SDL_InitSubSystem</TT | |
301 ></A | |
302 ></P | |
303 ></DIV | |
304 ><DIV | |
305 CLASS="NAVFOOTER" | |
306 ><HR | |
307 ALIGN="LEFT" | |
308 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
309 SUMMARY="Footer navigation table" |
0 | 310 WIDTH="100%" |
311 BORDER="0" | |
312 CELLPADDING="0" | |
313 CELLSPACING="0" | |
314 ><TR | |
315 ><TD | |
316 WIDTH="33%" | |
317 ALIGN="left" | |
318 VALIGN="top" | |
319 ><A | |
320 HREF="general.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
321 ACCESSKEY="P" |
0 | 322 >Prev</A |
323 ></TD | |
324 ><TD | |
325 WIDTH="34%" | |
326 ALIGN="center" | |
327 VALIGN="top" | |
328 ><A | |
329 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
330 ACCESSKEY="H" |
0 | 331 >Home</A |
332 ></TD | |
333 ><TD | |
334 WIDTH="33%" | |
335 ALIGN="right" | |
336 VALIGN="top" | |
337 ><A | |
338 HREF="sdlinitsubsystem.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
339 ACCESSKEY="N" |
0 | 340 >Next</A |
341 ></TD | |
342 ></TR | |
343 ><TR | |
344 ><TD | |
345 WIDTH="33%" | |
346 ALIGN="left" | |
347 VALIGN="top" | |
348 >General</TD | |
349 ><TD | |
350 WIDTH="34%" | |
351 ALIGN="center" | |
352 VALIGN="top" | |
353 ><A | |
354 HREF="general.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
355 ACCESSKEY="U" |
0 | 356 >Up</A |
357 ></TD | |
358 ><TD | |
359 WIDTH="33%" | |
360 ALIGN="right" | |
361 VALIGN="top" | |
362 >SDL_InitSubSystem</TD | |
363 ></TR | |
364 ></TABLE | |
365 ></DIV | |
366 ></BODY | |
367 ></HTML | |
368 > |