Mercurial > sdl-ios-xcode
annotate docs/html/sdlsemtrywait.html @ 1192:54aa9aa32327
To: sdl@libsdl.org
From: Christian Walther <cwalther@gmx.ch>
Date: Fri, 18 Nov 2005 23:39:02 +0100
Subject: [SDL] Mouse position bugs on Mac OS X
The attached patch fixes a few bugs in SDL related to the mouse position
in windowed mode on Mac OS X, reproduced using the attached minimal test
program - at least here on 10.3.9, with SDL CVS from today. Could anyone
test whether the bugs exist and are fixed by the patch on 10.2 and 10.4?
1. When using OpenGL, the vertical mouse positions obtained through
events or SDL_GetMouseState() are off by one.
2. When using OpenGL, SDL_WarpMouse() inverts the y coordinate.
3. Clicks on the topmost pixel row of the window are not recognized.
1 and 2 do not occur in non-OpenGL mode, while 3 does. All three only
occur in windowed mode, not in fullscreen.
The cause for 1 and 3 is that in Cocoa, "the location of the mouse"
seems to be defined as "the location of the top left corner of the mouse
pointer's hot pixel" (this is not documented, it's just what I found out
here), which together with the fact that Cocoa's usual y coordinates
start at the bottom and increase upwards means that the y coordinate of
the mouse runs from 1 to h, not from 0 to h-1, in a window of height h.
If it does work on 10.2 and 10.4 (I'll try to test it as soon as I can,
but at the moment all I have at hand is 10.3.9), can this be applied to
the CVS?
-Christian
To: sdl@libsdl.org
From: Christian Walther <cwalther@gmx.ch>
Date: Mon, 28 Nov 2005 10:41:51 +0100
Subject: [SDL] Re: Mouse position bugs on Mac OS X
I wrote:
> I'll try to test it as soon as I can, but at the moment all I have at hand is 10.3.9
So, here are the results of my tests (with patched and unpatched
frameworks compiled with Xcode 1.5 (gcc 3.3) on 10.3.9):
On 10.1.5, my test program doesn't run because of "Undefined symbols:
SDL undefined reference to _CGMainDisplayID expected to be defined in
Carbon". I guess not supporting 10.1 was a deliberate decision then and
that's OK with me.
On 10.2.8, 10.3.9, and 10.4.0, the bugs exist as described in my
original post and are fixed by my patch. That is, there is no difference
between pre/post 10.3 and the patched version works correctly in all
combinations of GL/non-GL and windowed/fullscreen.
I therefore recommend the patch for inclusion.
-Christian
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 28 Nov 2005 13:58:26 +0000 |
parents | 355632dca928 |
children |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_SemTryWait</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="Multi-threaded Programming" | |
14 HREF="thread.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_SemWait" | |
17 HREF="sdlsemwait.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_SemWaitTimeout" | |
20 HREF="sdlsemwaittimeout.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="sdlsemwait.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="sdlsemwaittimeout.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="SDLSEMTRYWAIT" | |
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_SemTryWait</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="AEN8069" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_SemTryWait -- Attempt to lock a semaphore but don't suspend the thread.</DIV | |
84 ><DIV | |
85 CLASS="REFSYNOPSISDIV" | |
86 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
87 NAME="AEN8072" |
0 | 88 ></A |
89 ><H2 | |
90 >Synopsis</H2 | |
91 ><DIV | |
92 CLASS="FUNCSYNOPSIS" | |
93 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
94 NAME="AEN8073" |
0 | 95 ></A |
96 ><P | |
97 ></P | |
98 ><PRE | |
99 CLASS="FUNCSYNOPSISINFO" | |
100 >#include "SDL.h" | |
101 #include "SDL_thread.h"</PRE | |
102 ><P | |
103 ><CODE | |
104 ><CODE | |
105 CLASS="FUNCDEF" | |
106 >int <B | |
107 CLASS="FSFUNC" | |
108 >SDL_SemTryWait</B | |
109 ></CODE | |
110 >(SDL_sem *sem);</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="AEN8079" |
0 | 120 ></A |
121 ><H2 | |
122 >Description</H2 | |
123 ><P | |
124 ><TT | |
125 CLASS="FUNCTION" | |
126 >SDL_SemTryWait</TT | |
127 > is a non-blocking varient of | |
128 <A | |
129 HREF="sdlsemwait.html" | |
130 ><TT | |
131 CLASS="FUNCTION" | |
132 >SDL_SemWait</TT | |
133 ></A | |
134 >. If the value of the semaphore | |
135 pointed to by <TT | |
136 CLASS="PARAMETER" | |
137 ><I | |
138 >sem</I | |
139 ></TT | |
140 > is positive it will atomically | |
141 decrement the semaphore value and return 0, otherwise it will return | |
142 <SPAN | |
143 CLASS="RETURNVALUE" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
144 >SDL_MUTEX_TIMEDOUT</SPAN |
0 | 145 > instead of suspending the thread.</P |
146 ><P | |
147 >After <TT | |
148 CLASS="FUNCTION" | |
149 >SDL_SemTryWait</TT | |
150 > is successful, the semaphore | |
151 can be released and its count atomically incremented by a successful call to | |
152 <A | |
153 HREF="sdlsempost.html" | |
154 >SDL_SemPost</A | |
155 >.</P | |
156 ></DIV | |
157 ><DIV | |
158 CLASS="REFSECT1" | |
159 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
160 NAME="AEN8090" |
0 | 161 ></A |
162 ><H2 | |
163 >Return Value</H2 | |
164 ><P | |
165 >Returns <SPAN | |
166 CLASS="RETURNVALUE" | |
167 >0</SPAN | |
168 > if the semaphore was successfully locked or | |
169 either <SPAN | |
170 CLASS="RETURNVALUE" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
171 >SDL_MUTEX_TIMEDOUT</SPAN |
0 | 172 > or <SPAN |
173 CLASS="RETURNVALUE" | |
174 >-1</SPAN | |
175 > | |
176 if the thread would have suspended or there was an error, respectivly.</P | |
177 ><P | |
178 >If the semaphore was not successfully locked, the semaphore will be unchanged.</P | |
179 ></DIV | |
180 ><DIV | |
181 CLASS="REFSECT1" | |
182 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
183 NAME="AEN8097" |
0 | 184 ></A |
185 ><H2 | |
186 >Examples</H2 | |
187 ><P | |
188 ><PRE | |
189 CLASS="PROGRAMLISTING" | |
190 >res = SDL_SemTryWait(my_sem); | |
191 | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
192 if (res == SDL_MUTEX_TIMEDOUT) { |
0 | 193 return TRY_AGAIN; |
194 } | |
195 if (res == -1) { | |
196 return WAIT_ERROR; | |
197 } | |
198 | |
199 ... | |
200 | |
201 SDL_SemPost(my_sem);</PRE | |
202 ></P | |
203 ></DIV | |
204 ><DIV | |
205 CLASS="REFSECT1" | |
206 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
207 NAME="AEN8101" |
0 | 208 ></A |
209 ><H2 | |
210 >See Also</H2 | |
211 ><P | |
212 ><A | |
213 HREF="sdlcreatesemaphore.html" | |
214 ><TT | |
215 CLASS="FUNCTION" | |
216 >SDL_CreateSemaphore</TT | |
217 ></A | |
218 >, | |
219 <A | |
220 HREF="sdldestroysemaphore.html" | |
221 ><TT | |
222 CLASS="FUNCTION" | |
223 >SDL_DestroySemaphore</TT | |
224 ></A | |
225 >, | |
226 <A | |
227 HREF="sdlsemwait.html" | |
228 ><TT | |
229 CLASS="FUNCTION" | |
230 >SDL_SemWait</TT | |
231 ></A | |
232 >, | |
233 <A | |
234 HREF="sdlsemwaittimeout.html" | |
235 ><TT | |
236 CLASS="FUNCTION" | |
237 >SDL_SemWaitTimeout</TT | |
238 ></A | |
239 >, | |
240 <A | |
241 HREF="sdlsempost.html" | |
242 ><TT | |
243 CLASS="FUNCTION" | |
244 >SDL_SemPost</TT | |
245 ></A | |
246 >, | |
247 <A | |
248 HREF="sdlsemvalue.html" | |
249 ><TT | |
250 CLASS="FUNCTION" | |
251 >SDL_SemValue</TT | |
252 ></A | |
253 ></P | |
254 ></DIV | |
255 ><DIV | |
256 CLASS="NAVFOOTER" | |
257 ><HR | |
258 ALIGN="LEFT" | |
259 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
260 SUMMARY="Footer navigation table" |
0 | 261 WIDTH="100%" |
262 BORDER="0" | |
263 CELLPADDING="0" | |
264 CELLSPACING="0" | |
265 ><TR | |
266 ><TD | |
267 WIDTH="33%" | |
268 ALIGN="left" | |
269 VALIGN="top" | |
270 ><A | |
271 HREF="sdlsemwait.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
272 ACCESSKEY="P" |
0 | 273 >Prev</A |
274 ></TD | |
275 ><TD | |
276 WIDTH="34%" | |
277 ALIGN="center" | |
278 VALIGN="top" | |
279 ><A | |
280 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
281 ACCESSKEY="H" |
0 | 282 >Home</A |
283 ></TD | |
284 ><TD | |
285 WIDTH="33%" | |
286 ALIGN="right" | |
287 VALIGN="top" | |
288 ><A | |
289 HREF="sdlsemwaittimeout.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
290 ACCESSKEY="N" |
0 | 291 >Next</A |
292 ></TD | |
293 ></TR | |
294 ><TR | |
295 ><TD | |
296 WIDTH="33%" | |
297 ALIGN="left" | |
298 VALIGN="top" | |
299 >SDL_SemWait</TD | |
300 ><TD | |
301 WIDTH="34%" | |
302 ALIGN="center" | |
303 VALIGN="top" | |
304 ><A | |
305 HREF="thread.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
306 ACCESSKEY="U" |
0 | 307 >Up</A |
308 ></TD | |
309 ><TD | |
310 WIDTH="33%" | |
311 ALIGN="right" | |
312 VALIGN="top" | |
313 >SDL_SemWaitTimeout</TD | |
314 ></TR | |
315 ></TABLE | |
316 ></DIV | |
317 ></BODY | |
318 ></HTML | |
319 > |