From 7fda1db11ca710f14a3feae36a5549d716f4a5a7 Mon Sep 17 00:00:00 2001 From: Mark Sibly Date: Mon, 21 Sep 2015 15:18:39 +1200 Subject: [PATCH] Updated test system.macos.m --- mod/brl.mod/system.mod/_system.macos.m | 41 ++++++++++++-------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/mod/brl.mod/system.mod/_system.macos.m b/mod/brl.mod/system.mod/_system.macos.m index af1da7d..be1b104 100644 --- a/mod/brl.mod/system.mod/_system.macos.m +++ b/mod/brl.mod/system.mod/_system.macos.m @@ -154,40 +154,37 @@ static int mouseViewPos( NSView *view,int *x,int *y ){ NSRect rect; NSPoint point; NSWindow *window; - - if( displayCaptured ){ - Point point; + if( !view ){ + + NSPoint point; + NSRect frame; CGLContextObj gl; - GetMouse( &point ); + point=[NSEvent mouseLocation]; + frame=[[NSScreen mainScreen] frame]; - if( gl=CGLGetCurrentContext() ){ + point.y=frame.size.height-point.y-1; + //yurk... + if( gl=CGLGetCurrentContext() ){ + GLint enabled=0; - CGLIsEnabled( gl,kCGLCESurfaceBackingSize,&enabled ); - - if( enabled ){ + if( !CGLIsEnabled( gl,kCGLCESurfaceBackingSize,&enabled ) && enabled ){ - NSRect frame; - GLint size[2]; + GLint size[2]={0,0}; + if( !CGLGetParameter( gl,kCGLCPSurfaceBackingSize,size ) ){ - frame=[[NSScreen mainScreen] frame]; - CGLGetParameter( gl,kCGLCPSurfaceBackingSize,size ); - - *x=point.h * size[0] / frame.size.width; - *y=point.v * size[1] / frame.size.height; - return 1; - } + point.x=point.x*size[0]/frame.size.width; + point.y=point.y*size[1]/frame.size.height; + } + } } - - *x=point.h; - *y=point.v; + *x=point.x; + *y=point.y; return 1; } - if( !view ) return *x=*y=0; - window=[view window]; point=[window mouseLocationOutsideOfEventStream]; rect=[view bounds]; -- 2.30.2