[patch] Cocoa fullscreen mouse fix

Hi,

Sending a patch for fullscreen Mac OS X SDL 1.3 (SVN) Cocoa mouse
position handling. In fullscreen mouse coordinates should be relative
to SCREEN not to the window, which doesn’t really occupy fullscreen.
Without this patch mouse position (especially Y) was totally incorrect
(shifted) in fullscreen.

Regards,–
Adam
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL-SVN-cocoa-fullscreen-mouse-position.patch
Type: application/octet-stream
Size: 1868 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20091020/cd0eda35/attachment.obj

Great!

The window already knows whether it is fullscreen, so I was able to
simplify the patch slightly.

Thanks!On Tue, Oct 20, 2009 at 1:58 PM, Adam Strzelecki wrote:

Hi,

Sending a patch for fullscreen Mac OS X SDL 1.3 (SVN) Cocoa mouse position
handling. In fullscreen mouse coordinates should be relative to SCREEN not
to the window, which doesn’t really occupy fullscreen.
Without this patch mouse position (especially Y) was totally incorrect
(shifted) in fullscreen.

Regards,

Adam


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Sam,

The patch below should fix finally the FULLSCREEN mouse movement
coords. However there’s bigger issue here. Mouse button events are not
passed to SDL at all in FULLSCREEN Cocoa (OSX).
Why? I think this is because we lock screens with CGDisplayCapture
which means NO mouse events (actually mouseMove is passed !?!) are
passed to underlaying SDL window (and any other windows) which handles
mouse.
So there’s a serious problem. I have absolutely no idea how to easily
solve this.
I meantime please commit fix below so we at least have mouseMove
events in FULLSCREEN.

The window already knows whether it is fullscreen, so I was able to
simplify the patch slightly.

Yeah. Thanks. But I think something is wrong (look at the fix patch
below):
(1) NSRect rect shouldn’t be initialized with contentRectForFrameRect:
at the top of the function, contentRectForFrameRect is called in non-
fullscreen case anyway (1st @@)
(2) I think you’ve left two lines that should be removed completely
(2nd @@)

Index: src/video/cocoa/SDL_cocoawindow.m===================================================================
— src/video/cocoa/SDL_cocoawindow.m (revision 5170)
+++ src/video/cocoa/SDL_cocoawindow.m (working copy)
@@ -233,7 +233,7 @@
int index;
SDL_Mouse *mouse;
NSPoint point;

  • NSRect rect = [_data->window contentRectForFrameRect:[_data-

window frame]];

  • NSRect rect;

    index = _data->videodata->mouse;
    mouse = SDL_GetMouse(index);
    @@ -248,8 +248,6 @@
    point.x = point.x - rect.origin.x;
    point.y = rect.size.height - (point.y - rect.origin.y);
    }

  • point.x = point.x - rect.origin.x;
  • point.y = rect.size.height - (point.y - rect.origin.y);
    if ( point.x < 0 || point.x >= rect.size.width ||
    point.y < 0 || point.y >= rect.size.height ) {
    if (mouse->focus != 0) {

Best regards,

Adam Strzelecki | nanoant.com

Whoops, good catch, thanks!On Thu, Oct 22, 2009 at 9:55 AM, Adam Strzelecki wrote:

Sam,

The patch below should fix finally the FULLSCREEN mouse movement coords.
However there’s bigger issue here. Mouse button events are not passed to SDL
at all in FULLSCREEN Cocoa (OSX).
Why? I think this is because we lock screens with CGDisplayCapture which
means NO mouse events (actually mouseMove is passed !?!) are passed to
underlaying SDL window (and any other windows) which handles mouse.
So there’s a serious problem. I have absolutely no idea how to easily solve
this.
I meantime please commit fix below so we at least have mouseMove events in
FULLSCREEN.

The window already knows whether it is fullscreen, so I was able to
simplify the patch slightly.

Yeah. Thanks. But I think something is wrong (look at the fix patch below):
(1) NSRect rect shouldn’t be initialized with contentRectForFrameRect: at
the top of the function, contentRectForFrameRect is called in non-fullscreen
case anyway (1st @@)
(2) I think you’ve left two lines that should be removed completely (2nd @@)

Index: src/video/cocoa/SDL_cocoawindow.m

— src/video/cocoa/SDL_cocoawindow.m ? (revision 5170)
+++ src/video/cocoa/SDL_cocoawindow.m ? (working copy)
@@ -233,7 +233,7 @@
? ? int index;
? ? SDL_Mouse *mouse;
? ? NSPoint point;

  • ? ?NSRect rect = [_data->window contentRectForFrameRect:[_data->window
    frame]];
  • ? ?NSRect rect;

? ? index = _data->videodata->mouse;
? ? mouse = SDL_GetMouse(index);
@@ -248,8 +248,6 @@
? ? ? ? point.x = point.x - rect.origin.x;
? ? ? ? point.y = rect.size.height - (point.y - rect.origin.y);
? ? }

  • ? ?point.x = point.x - rect.origin.x;
  • ? ?point.y = rect.size.height - (point.y - rect.origin.y);
    ? ? if ( point.x < 0 || point.x >= rect.size.width ||
    ? ? ? ? ?point.y < 0 || point.y >= rect.size.height ) {
    ? ? ? ? if (mouse->focus != 0) {

Best regards,

Adam Strzelecki | nanoant.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC