Mercurial > sdl-ios-xcode
annotate docs/html/general.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 >General</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 Reference" | |
14 HREF="reference.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL Reference" | |
17 HREF="reference.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_Init" | |
20 HREF="sdlinit.html"><META | |
21 NAME="KEYWORD" | |
22 CONTENT="general"><META | |
23 NAME="KEYWORD" | |
24 CONTENT="function"></HEAD | |
25 ><BODY | |
26 CLASS="CHAPTER" | |
27 BGCOLOR="#FFF8DC" | |
28 TEXT="#000000" | |
29 LINK="#0000ee" | |
30 VLINK="#551a8b" | |
31 ALINK="#ff0000" | |
32 ><DIV | |
33 CLASS="NAVHEADER" | |
34 ><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
35 SUMMARY="Header navigation table" |
0 | 36 WIDTH="100%" |
37 BORDER="0" | |
38 CELLPADDING="0" | |
39 CELLSPACING="0" | |
40 ><TR | |
41 ><TH | |
42 COLSPAN="3" | |
43 ALIGN="center" | |
44 >SDL Library Documentation</TH | |
45 ></TR | |
46 ><TR | |
47 ><TD | |
48 WIDTH="10%" | |
49 ALIGN="left" | |
50 VALIGN="bottom" | |
51 ><A | |
52 HREF="reference.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
53 ACCESSKEY="P" |
0 | 54 >Prev</A |
55 ></TD | |
56 ><TD | |
57 WIDTH="80%" | |
58 ALIGN="center" | |
59 VALIGN="bottom" | |
60 ></TD | |
61 ><TD | |
62 WIDTH="10%" | |
63 ALIGN="right" | |
64 VALIGN="bottom" | |
65 ><A | |
66 HREF="sdlinit.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
67 ACCESSKEY="N" |
0 | 68 >Next</A |
69 ></TD | |
70 ></TR | |
71 ></TABLE | |
72 ><HR | |
73 ALIGN="LEFT" | |
74 WIDTH="100%"></DIV | |
75 ><DIV | |
76 CLASS="CHAPTER" | |
77 ><H1 | |
78 ><A | |
79 NAME="GENERAL" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
80 ></A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
81 >Chapter 5. General</H1 |
0 | 82 ><DIV |
83 CLASS="TOC" | |
84 ><DL | |
85 ><DT | |
86 ><B | |
87 >Table of Contents</B | |
88 ></DT | |
89 ><DT | |
90 ><A | |
91 HREF="sdlinit.html" | |
92 >SDL_Init</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
93 > -- Initializes SDL</DT |
0 | 94 ><DT |
95 ><A | |
96 HREF="sdlinitsubsystem.html" | |
97 >SDL_InitSubSystem</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
98 > -- Initialize subsystems</DT |
0 | 99 ><DT |
100 ><A | |
101 HREF="sdlquitsubsystem.html" | |
102 >SDL_QuitSubSystem</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
103 > -- Shut down a subsystem</DT |
0 | 104 ><DT |
105 ><A | |
106 HREF="sdlquit.html" | |
107 >SDL_Quit</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
108 > -- Shut down SDL</DT |
0 | 109 ><DT |
110 ><A | |
111 HREF="sdlwasinit.html" | |
112 >SDL_WasInit</A | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
113 > -- Check which subsystems are initialized</DT |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
114 ><DT |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
115 ><A |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
116 HREF="sdlgeterror.html" |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
117 >SDL_GetError</A |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
118 > -- Get SDL error string</DT |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
119 ><DT |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
120 ><A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
121 HREF="sdlenvvars.html" |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
122 >SDL_envvars</A |
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
123 > -- SDL environment variables</DT |
0 | 124 ></DL |
125 ></DIV | |
126 ><P | |
127 >Before SDL can be used in a program it must be initialized with <A | |
128 HREF="sdlinit.html" | |
129 ><TT | |
130 CLASS="FUNCTION" | |
131 >SDL_Init</TT | |
132 ></A | |
133 >. <TT | |
134 CLASS="FUNCTION" | |
135 >SDL_Init</TT | |
136 > initializes all the subsystems that the user requests (video, audio, joystick, timers and/or cdrom). Once SDL is initialized with <TT | |
137 CLASS="FUNCTION" | |
138 >SDL_Init</TT | |
139 > subsystems can be shut down and initialized as needed using <A | |
140 HREF="sdlinitsubsystem.html" | |
141 ><TT | |
142 CLASS="FUNCTION" | |
143 >SDL_InitSubSystem</TT | |
144 ></A | |
145 > and <A | |
146 HREF="sdlquitsubsystem.html" | |
147 ><TT | |
148 CLASS="FUNCTION" | |
149 >SDL_QuitSubSystem</TT | |
150 ></A | |
151 >.</P | |
152 ><P | |
153 >SDL must also be shut down before the program exits to make sure it cleans up correctly. Calling <A | |
154 HREF="sdlquit.html" | |
155 ><TT | |
156 CLASS="FUNCTION" | |
157 >SDL_Quit</TT | |
158 ></A | |
159 > shuts down all subsystems and frees any resources allocated to SDL.</P | |
160 ></DIV | |
161 ><DIV | |
162 CLASS="NAVFOOTER" | |
163 ><HR | |
164 ALIGN="LEFT" | |
165 WIDTH="100%"><TABLE | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
166 SUMMARY="Footer navigation table" |
0 | 167 WIDTH="100%" |
168 BORDER="0" | |
169 CELLPADDING="0" | |
170 CELLSPACING="0" | |
171 ><TR | |
172 ><TD | |
173 WIDTH="33%" | |
174 ALIGN="left" | |
175 VALIGN="top" | |
176 ><A | |
177 HREF="reference.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
178 ACCESSKEY="P" |
0 | 179 >Prev</A |
180 ></TD | |
181 ><TD | |
182 WIDTH="34%" | |
183 ALIGN="center" | |
184 VALIGN="top" | |
185 ><A | |
186 HREF="index.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
187 ACCESSKEY="H" |
0 | 188 >Home</A |
189 ></TD | |
190 ><TD | |
191 WIDTH="33%" | |
192 ALIGN="right" | |
193 VALIGN="top" | |
194 ><A | |
195 HREF="sdlinit.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
196 ACCESSKEY="N" |
0 | 197 >Next</A |
198 ></TD | |
199 ></TR | |
200 ><TR | |
201 ><TD | |
202 WIDTH="33%" | |
203 ALIGN="left" | |
204 VALIGN="top" | |
205 >SDL Reference</TD | |
206 ><TD | |
207 WIDTH="34%" | |
208 ALIGN="center" | |
209 VALIGN="top" | |
210 ><A | |
211 HREF="reference.html" | |
803
355632dca928
Updated SDL HTML documentation
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
212 ACCESSKEY="U" |
0 | 213 >Up</A |
214 ></TD | |
215 ><TD | |
216 WIDTH="33%" | |
217 ALIGN="right" | |
218 VALIGN="top" | |
219 >SDL_Init</TD | |
220 ></TR | |
221 ></TABLE | |
222 ></DIV | |
223 ></BODY | |
224 ></HTML | |
225 > |