src/macosx/native/sun/awt/AWTWindow.m

Print this page

        

@@ -318,10 +318,11 @@
     return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
 }
 
 // return id for the topmost window under mouse
 + (NSInteger) getTopmostWindowUnderMouseID {
+    NSInteger result = -1;
 
     NSRect screenRect = [[NSScreen mainScreen] frame];
     NSPoint nsMouseLocation = [NSEvent mouseLocation];
     CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
 

@@ -332,15 +333,17 @@
         NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
         if (layer == 0) {
             CGRect rect;
             CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
             if (CGRectContainsPoint(rect, cgMouseLocation)) {
-                return [[window objectForKey:(id)kCGWindowNumber] integerValue];
+                result = [[window objectForKey:(id)kCGWindowNumber] integerValue];
+                break;
             }
         }
     }
-    return -1;
+    [windows release];
+    return result;
 }
 
 // checks that this window is under the mouse cursor and this point is not overlapped by other windows
 - (BOOL) isTopmostWindowUnderMouse {
     return [self.nsWindow windowNumber] == [AWTWindow getTopmostWindowUnderMouseID];