Mercurial > sdl-ios-xcode
annotate docs/html/sdldestroysemaphore.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_DestroySemaphore</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_CreateSemaphore" | |
17 HREF="sdlcreatesemaphore.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_SemWait" | |
20 HREF="sdlsemwait.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="sdlcreatesemaphore.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="sdlsemwait.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="SDLDESTROYSEMAPHORE" | |
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_DestroySemaphore</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="AEN7982" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_DestroySemaphore -- Destroys a semaphore that was created by <A | |
84 HREF="sdlcreatesemaphore.html" | |
85 >SDL_CreateSemaphore</A | |
86 >.</DIV | |
87 ><DIV | |
88 CLASS="REFSYNOPSISDIV" | |
89 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
90 NAME="AEN7986" |
0 | 91 ></A |
92 ><H2 | |
93 >Synopsis</H2 | |
94 ><DIV | |
95 CLASS="FUNCSYNOPSIS" | |
96 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
97 NAME="AEN7987" |
0 | 98 ></A |
99 ><P | |
100 ></P | |
101 ><PRE | |
102 CLASS="FUNCSYNOPSISINFO" | |
103 >#include "SDL.h" | |
104 #include "SDL_thread.h"</PRE | |
105 ><P | |
106 ><CODE | |
107 ><CODE | |
108 CLASS="FUNCDEF" | |
109 >void <B | |
110 CLASS="FSFUNC" | |
111 >SDL_DestroySemaphore</B | |
112 ></CODE | |
113 >(SDL_sem *sem);</CODE | |
114 ></P | |
115 ><P | |
116 ></P | |
117 ></DIV | |
118 ></DIV | |
119 ><DIV | |
120 CLASS="REFSECT1" | |
121 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
122 NAME="AEN7993" |
0 | 123 ></A |
124 ><H2 | |
125 >Description</H2 | |
126 ><P | |
127 ><TT | |
128 CLASS="FUNCTION" | |
129 >SDL_DestroySemaphore</TT | |
130 > destroys the semaphore pointed to | |
131 by <TT | |
132 CLASS="PARAMETER" | |
133 ><I | |
134 >sem</I | |
135 ></TT | |
136 > that was created by | |
137 <A | |
138 HREF="sdlcreatesemaphore.html" | |
139 ><TT | |
140 CLASS="FUNCTION" | |
141 >SDL_CreateSemaphore</TT | |
142 ></A | |
143 >. | |
144 It is not safe to destroy a semaphore if there are threads currently blocked | |
145 waiting on it.</P | |
146 ></DIV | |
147 ><DIV | |
148 CLASS="REFSECT1" | |
149 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
150 NAME="AEN8000" |
0 | 151 ></A |
152 ><H2 | |
153 >Examples</H2 | |
154 ><P | |
155 ><PRE | |
156 CLASS="PROGRAMLISTING" | |
157 >if (my_sem != NULL) { | |
158 SDL_DestroySemaphore(my_sem); | |
159 my_sem = NULL; | |
160 }</PRE | |
161 ></P | |
162 ></DIV | |
163 ><DIV | |
164 CLASS="REFSECT1" | |
165 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
166 NAME="AEN8004" |
0 | 167 ></A |
168 ><H2 | |
169 >See Also</H2 | |
170 ><P | |
171 ><A | |
172 HREF="sdlcreatesemaphore.html" | |
173 ><TT | |
174 CLASS="FUNCTION" | |
175 >SDL_CreateSemaphore</TT | |
176 ></A | |
177 >, | |
178 <A | |
179 HREF="sdlsemwait.html" | |
180 ><TT | |
181 CLASS="FUNCTION" | |
182 >SDL_SemWait</TT | |
183 ></A | |
184 >, | |
185 <A | |
186 HREF="sdlsemtrywait.html" | |
187 ><TT | |
188 CLASS="FUNCTION" | |
189 >SDL_SemTryWait</TT | |
190 ></A | |
191 >, | |
192 <A | |
193 HREF="sdlsemwaittimeout.html" | |
194 ><TT | |
195 CLASS="FUNCTION" | |
196 >SDL_SemWaitTimeout</TT | |
197 ></A | |
198 >, | |
199 <A | |
200 HREF="sdlsempost.html" | |
201 ><TT | |
202 CLASS="FUNCTION" | |
203 >SDL_SemPost</TT | |
204 ></A | |
205 >, | |
206 <A | |
207 HREF="sdlsemvalue.html" | |
208 ><TT | |
209 CLASS="FUNCTION" | |
210 >SDL_SemValue</TT | |
211 ></A | |
212 ></P | |
213 ></DIV | |
214 ><DIV | |
215 CLASS="NAVFOOTER" | |
216 ><HR | |
217 ALIGN="LEFT" | |
218 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
219 SUMMARY="Footer navigation table" |
0 | 220 WIDTH="100%" |
221 BORDER="0" | |
222 CELLPADDING="0" | |
223 CELLSPACING="0" | |
224 ><TR | |
225 ><TD | |
226 WIDTH="33%" | |
227 ALIGN="left" | |
228 VALIGN="top" | |
229 ><A | |
230 HREF="sdlcreatesemaphore.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
231 ACCESSKEY="P" |
0 | 232 >Prev</A |
233 ></TD | |
234 ><TD | |
235 WIDTH="34%" | |
236 ALIGN="center" | |
237 VALIGN="top" | |
238 ><A | |
239 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
240 ACCESSKEY="H" |
0 | 241 >Home</A |
242 ></TD | |
243 ><TD | |
244 WIDTH="33%" | |
245 ALIGN="right" | |
246 VALIGN="top" | |
247 ><A | |
248 HREF="sdlsemwait.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
249 ACCESSKEY="N" |
0 | 250 >Next</A |
251 ></TD | |
252 ></TR | |
253 ><TR | |
254 ><TD | |
255 WIDTH="33%" | |
256 ALIGN="left" | |
257 VALIGN="top" | |
258 >SDL_CreateSemaphore</TD | |
259 ><TD | |
260 WIDTH="34%" | |
261 ALIGN="center" | |
262 VALIGN="top" | |
263 ><A | |
264 HREF="thread.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
265 ACCESSKEY="U" |
0 | 266 >Up</A |
267 ></TD | |
268 ><TD | |
269 WIDTH="33%" | |
270 ALIGN="right" | |
271 VALIGN="top" | |
272 >SDL_SemWait</TD | |
273 ></TR | |
274 ></TABLE | |
275 ></DIV | |
276 ></BODY | |
277 ></HTML | |
278 > |