Mercurial > sdl-ios-xcode
annotate docs/html/sdlupdaterect.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_UpdateRect</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_SetVideoMode" | |
17 HREF="sdlsetvideomode.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_UpdateRects" | |
20 HREF="sdlupdaterects.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="sdlsetvideomode.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="sdlupdaterects.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="SDLUPDATERECT" | |
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_UpdateRect</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="AEN1355" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_UpdateRect -- Makes sure the given area is updated on the given screen.</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="AEN1358" |
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="AEN1359" |
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 >void <B | |
106 CLASS="FSFUNC" | |
107 >SDL_UpdateRect</B | |
108 ></CODE | |
109 >(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);</CODE | |
110 ></P | |
111 ><P | |
112 ></P | |
113 ></DIV | |
114 ></DIV | |
115 ><DIV | |
116 CLASS="REFSECT1" | |
117 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
118 NAME="AEN1365" |
0 | 119 ></A |
120 ><H2 | |
121 >Description</H2 | |
122 ><P | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
123 >Makes sure the given area is updated on the given screen. The rectangle must |
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
124 be confined within the screen boundaries (no clipping is done).</P |
0 | 125 ><P |
126 >If '<TT | |
127 CLASS="PARAMETER" | |
128 ><I | |
129 >x</I | |
130 ></TT | |
131 >', '<TT | |
132 CLASS="PARAMETER" | |
133 ><I | |
134 >y</I | |
135 ></TT | |
136 >', '<TT | |
137 CLASS="PARAMETER" | |
138 ><I | |
139 >w</I | |
140 ></TT | |
141 >' | |
142 and '<TT | |
143 CLASS="PARAMETER" | |
144 ><I | |
145 >h</I | |
146 ></TT | |
147 >' are all 0, | |
148 <TT | |
149 CLASS="FUNCTION" | |
150 >SDL_UpdateRect</TT | |
151 > will update the | |
152 entire screen.</P | |
153 ><P | |
154 >This function should not be called while '<TT | |
155 CLASS="PARAMETER" | |
156 ><I | |
157 >screen</I | |
158 ></TT | |
159 >' is | |
160 <A | |
161 HREF="sdllocksurface.html" | |
162 >locked</A | |
163 >.</P | |
164 ></DIV | |
165 ><DIV | |
166 CLASS="REFSECT1" | |
167 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
168 NAME="AEN1377" |
0 | 169 ></A |
170 ><H2 | |
171 >See Also</H2 | |
172 ><P | |
173 ><A | |
174 HREF="sdlupdaterects.html" | |
175 ><TT | |
176 CLASS="FUNCTION" | |
177 >SDL_UpdateRects</TT | |
178 ></A | |
179 >, | |
180 <A | |
181 HREF="sdlrect.html" | |
182 ><SPAN | |
183 CLASS="STRUCTNAME" | |
184 >SDL_Rect</SPAN | |
185 ></A | |
186 >, | |
187 <A | |
188 HREF="sdlsurface.html" | |
189 ><SPAN | |
190 CLASS="STRUCTNAME" | |
191 >SDL_Surface</SPAN | |
192 ></A | |
193 >, | |
194 <A | |
195 HREF="sdllocksurface.html" | |
196 ><TT | |
197 CLASS="FUNCTION" | |
198 >SDL_LockSurface</TT | |
199 ></A | |
200 ></P | |
201 ></DIV | |
202 ><DIV | |
203 CLASS="NAVFOOTER" | |
204 ><HR | |
205 ALIGN="LEFT" | |
206 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
207 SUMMARY="Footer navigation table" |
0 | 208 WIDTH="100%" |
209 BORDER="0" | |
210 CELLPADDING="0" | |
211 CELLSPACING="0" | |
212 ><TR | |
213 ><TD | |
214 WIDTH="33%" | |
215 ALIGN="left" | |
216 VALIGN="top" | |
217 ><A | |
218 HREF="sdlsetvideomode.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
219 ACCESSKEY="P" |
0 | 220 >Prev</A |
221 ></TD | |
222 ><TD | |
223 WIDTH="34%" | |
224 ALIGN="center" | |
225 VALIGN="top" | |
226 ><A | |
227 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
228 ACCESSKEY="H" |
0 | 229 >Home</A |
230 ></TD | |
231 ><TD | |
232 WIDTH="33%" | |
233 ALIGN="right" | |
234 VALIGN="top" | |
235 ><A | |
236 HREF="sdlupdaterects.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
237 ACCESSKEY="N" |
0 | 238 >Next</A |
239 ></TD | |
240 ></TR | |
241 ><TR | |
242 ><TD | |
243 WIDTH="33%" | |
244 ALIGN="left" | |
245 VALIGN="top" | |
246 >SDL_SetVideoMode</TD | |
247 ><TD | |
248 WIDTH="34%" | |
249 ALIGN="center" | |
250 VALIGN="top" | |
251 ><A | |
252 HREF="video.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
253 ACCESSKEY="U" |
0 | 254 >Up</A |
255 ></TD | |
256 ><TD | |
257 WIDTH="33%" | |
258 ALIGN="right" | |
259 VALIGN="top" | |
260 >SDL_UpdateRects</TD | |
261 ></TR | |
262 ></TABLE | |
263 ></DIV | |
264 ></BODY | |
265 ></HTML | |
266 > |