Updated test system.macos.m
authorMark Sibly <blitzmunter@gmail.com>
Mon, 21 Sep 2015 03:18:39 +0000 (15:18 +1200)
committerMark Sibly <blitzmunter@gmail.com>
Mon, 21 Sep 2015 03:18:39 +0000 (15:18 +1200)
mod/brl.mod/system.mod/_system.macos.m

index af1da7d27659a02f3f121244554f4a9afa5cae8c..be1b104959b4df05fe46c24bf4e01a3e081877a3 100644 (file)
@@ -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];