[SDL] Mouse position bugs on Mac OS X

Christian Walther cwalther at gmx.ch
Fri Nov 18 14:39:02 PST 2005


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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: SDL-quartz-mouse-bugs.patch
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20051118/59151149/attachment-0007.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mousebug.c
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20051118/59151149/attachment-0007.asc>


More information about the SDL mailing list