Mercurial > sdl-ios-xcode
annotate docs/html/sdlresizeevent.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_ResizeEvent</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="SDL Event Structures." | |
14 HREF="eventstructures.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_JoyBallEvent" | |
17 HREF="sdljoyballevent.html"><LINK | |
18 REL="NEXT" | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
19 TITLE="SDL_ExposeEvent" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
20 HREF="sdlexposeevent.html"></HEAD |
0 | 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="sdljoyballevent.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 | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
62 HREF="sdlexposeevent.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="SDLRESIZEEVENT" | |
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_ResizeEvent</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="AEN4453" |
0 | 80 ></A |
81 ><H2 | |
82 >Name</H2 | |
83 >SDL_ResizeEvent -- Window resize event structure</DIV | |
84 ><DIV | |
85 CLASS="REFSECT1" | |
86 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
87 NAME="AEN4456" |
0 | 88 ></A |
89 ><H2 | |
90 >Structure Definition</H2 | |
91 ><PRE | |
92 CLASS="PROGRAMLISTING" | |
93 >typedef struct{ | |
94 Uint8 type; | |
95 int w, h; | |
96 } SDL_ResizeEvent;</PRE | |
97 ></DIV | |
98 ><DIV | |
99 CLASS="REFSECT1" | |
100 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
101 NAME="AEN4459" |
0 | 102 ></A |
103 ><H2 | |
104 >Structure Data</H2 | |
105 ><DIV | |
106 CLASS="INFORMALTABLE" | |
107 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
108 NAME="AEN4461" |
0 | 109 ></A |
110 ><P | |
111 ></P | |
112 ><TABLE | |
113 BORDER="0" | |
114 CLASS="CALSTABLE" | |
115 ><TBODY | |
116 ><TR | |
117 ><TD | |
118 ALIGN="LEFT" | |
119 VALIGN="TOP" | |
120 ><TT | |
121 CLASS="STRUCTFIELD" | |
122 ><I | |
123 >type</I | |
124 ></TT | |
125 ></TD | |
126 ><TD | |
127 ALIGN="LEFT" | |
128 VALIGN="TOP" | |
129 ><TT | |
130 CLASS="LITERAL" | |
131 >SDL_VIDEORESIZE</TT | |
132 ></TD | |
133 ></TR | |
134 ><TR | |
135 ><TD | |
136 ALIGN="LEFT" | |
137 VALIGN="TOP" | |
138 ><TT | |
139 CLASS="STRUCTFIELD" | |
140 ><I | |
141 >w</I | |
142 ></TT | |
143 >, <TT | |
144 CLASS="STRUCTFIELD" | |
145 ><I | |
146 >h</I | |
147 ></TT | |
148 ></TD | |
149 ><TD | |
150 ALIGN="LEFT" | |
151 VALIGN="TOP" | |
152 >New width and height of the window</TD | |
153 ></TR | |
154 ></TBODY | |
155 ></TABLE | |
156 ><P | |
157 ></P | |
158 ></DIV | |
159 ></DIV | |
160 ><DIV | |
161 CLASS="REFSECT1" | |
162 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
163 NAME="AEN4474" |
0 | 164 ></A |
165 ><H2 | |
166 >Description</H2 | |
167 ><P | |
168 ><SPAN | |
169 CLASS="STRUCTNAME" | |
170 >SDL_ResizeEvent</SPAN | |
171 > is a member of the <A | |
172 HREF="sdlevent.html" | |
173 ><SPAN | |
174 CLASS="STRUCTNAME" | |
175 >SDL_Event</SPAN | |
176 ></A | |
177 > union and is used when an event of type <TT | |
178 CLASS="LITERAL" | |
179 >SDL_VIDEORESIZE</TT | |
180 > is reported.</P | |
181 ><P | |
182 >When <TT | |
183 CLASS="LITERAL" | |
184 >SDL_RESIZABLE</TT | |
185 > is passed as a <TT | |
186 CLASS="PARAMETER" | |
187 ><I | |
188 >flag</I | |
189 ></TT | |
190 > to <A | |
191 HREF="sdlsetvideomode.html" | |
192 ><TT | |
193 CLASS="FUNCTION" | |
194 >SDL_SetVideoMode</TT | |
195 ></A | |
196 > the user is allowed to resize the applications window. When the window is resized an <TT | |
197 CLASS="LITERAL" | |
198 >SDL_VIDEORESIZE</TT | |
199 > is report, with the new window width and height values stored in <TT | |
200 CLASS="STRUCTFIELD" | |
201 ><I | |
202 >w</I | |
203 ></TT | |
204 > and <TT | |
205 CLASS="STRUCTFIELD" | |
206 ><I | |
207 >h</I | |
208 ></TT | |
209 >, respectively. When an <TT | |
210 CLASS="LITERAL" | |
211 >SDL_VIDEORESIZE</TT | |
212 > is recieved the window should be resized to the new dimensions using <A | |
213 HREF="sdlsetvideomode.html" | |
214 ><TT | |
215 CLASS="FUNCTION" | |
216 >SDL_SetVideoMode</TT | |
217 ></A | |
218 >.</P | |
219 ></DIV | |
220 ><DIV | |
221 CLASS="REFSECT1" | |
222 ><A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
223 NAME="AEN4492" |
0 | 224 ></A |
225 ><H2 | |
226 >See Also</H2 | |
227 ><P | |
228 ><A | |
229 HREF="sdlevent.html" | |
230 ><SPAN | |
231 CLASS="STRUCTNAME" | |
232 >SDL_Event</SPAN | |
233 ></A | |
234 >, | |
235 <A | |
236 HREF="sdlsetvideomode.html" | |
237 ><TT | |
238 CLASS="FUNCTION" | |
239 >SDL_SetVideoMode</TT | |
240 ></A | |
241 ></P | |
242 ></DIV | |
243 ><DIV | |
244 CLASS="NAVFOOTER" | |
245 ><HR | |
246 ALIGN="LEFT" | |
247 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
248 SUMMARY="Footer navigation table" |
0 | 249 WIDTH="100%" |
250 BORDER="0" | |
251 CELLPADDING="0" | |
252 CELLSPACING="0" | |
253 ><TR | |
254 ><TD | |
255 WIDTH="33%" | |
256 ALIGN="left" | |
257 VALIGN="top" | |
258 ><A | |
259 HREF="sdljoyballevent.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
260 ACCESSKEY="P" |
0 | 261 >Prev</A |
262 ></TD | |
263 ><TD | |
264 WIDTH="34%" | |
265 ALIGN="center" | |
266 VALIGN="top" | |
267 ><A | |
268 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
269 ACCESSKEY="H" |
0 | 270 >Home</A |
271 ></TD | |
272 ><TD | |
273 WIDTH="33%" | |
274 ALIGN="right" | |
275 VALIGN="top" | |
276 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
277 HREF="sdlexposeevent.html" |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
278 ACCESSKEY="N" |
0 | 279 >Next</A |
280 ></TD | |
281 ></TR | |
282 ><TR | |
283 ><TD | |
284 WIDTH="33%" | |
285 ALIGN="left" | |
286 VALIGN="top" | |
287 >SDL_JoyBallEvent</TD | |
288 ><TD | |
289 WIDTH="34%" | |
290 ALIGN="center" | |
291 VALIGN="top" | |
292 ><A | |
293 HREF="eventstructures.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
294 ACCESSKEY="U" |
0 | 295 >Up</A |
296 ></TD | |
297 ><TD | |
298 WIDTH="33%" | |
299 ALIGN="right" | |
300 VALIGN="top" | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
301 >SDL_ExposeEvent</TD |
0 | 302 ></TR |
303 ></TABLE | |
304 ></DIV | |
305 ></BODY | |
306 ></HTML | |
307 > |