365 NSPoint localPoint = [self convertPoint: eventLocation fromView: nil]; 366 NSPoint absP = [NSEvent mouseLocation]; 367 368 // Convert global numbers between Cocoa's coordinate system and Java. 369 // TODO: need consitent way for doing that both with global as well as with local coordinates. 370 // The reason to do it here is one more native method for getting screen dimension otherwise. 371 372 NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame]; 373 absP.y = screenRect.size.height - absP.y; 374 jint clickCount; 375 376 if (type == NSMouseEntered || 377 type == NSMouseExited || 378 type == NSScrollWheel || 379 type == NSMouseMoved) { 380 clickCount = 0; 381 } else { 382 clickCount = [event clickCount]; 383 } 384 385 static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); 386 static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V"); 387 jobject jEvent = JNFNewObject(env, jctor_NSEvent, 388 [event type], 389 [event modifierFlags], 390 clickCount, 391 [event buttonNumber], 392 (jint)localPoint.x, (jint)localPoint.y, 393 (jint)absP.x, (jint)absP.y, 394 [event deltaY], 395 [event deltaX]); 396 CHECK_NULL(jEvent); 397 398 static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); 399 static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); 400 jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView); 401 if (!(*env)->IsSameObject(env, jlocal, NULL)) { 402 JNFCallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent); 403 (*env)->DeleteLocalRef(env, jlocal); 404 } 405 (*env)->DeleteLocalRef(env, jEvent); 406 } 407 408 - (void) resetTrackingArea { 409 if (rolloverTrackingArea != nil) { 410 [self removeTrackingArea:rolloverTrackingArea]; 411 [rolloverTrackingArea release]; 412 } 413 414 int options = (NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited | 415 NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag); | 365 NSPoint localPoint = [self convertPoint: eventLocation fromView: nil]; 366 NSPoint absP = [NSEvent mouseLocation]; 367 368 // Convert global numbers between Cocoa's coordinate system and Java. 369 // TODO: need consitent way for doing that both with global as well as with local coordinates. 370 // The reason to do it here is one more native method for getting screen dimension otherwise. 371 372 NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame]; 373 absP.y = screenRect.size.height - absP.y; 374 jint clickCount; 375 376 if (type == NSMouseEntered || 377 type == NSMouseExited || 378 type == NSScrollWheel || 379 type == NSMouseMoved) { 380 clickCount = 0; 381 } else { 382 clickCount = [event clickCount]; 383 } 384 385 jint scrollPhase = 0; 386 if (type == NSScrollWheel) { 387 scrollPhase = [AWTToolkit scrollStateWithPhase: [event phase] 388 withMomentumPhase: [event momentumPhase]]; 389 } 390 391 static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent"); 392 static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V"); 393 jobject jEvent = JNFNewObject(env, jctor_NSEvent, 394 [event type], 395 [event modifierFlags], 396 clickCount, 397 [event buttonNumber], 398 (jint)localPoint.x, (jint)localPoint.y, 399 (jint)absP.x, (jint)absP.y, 400 [event deltaY], 401 [event deltaX], 402 scrollPhase); 403 CHECK_NULL(jEvent); 404 405 static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView"); 406 static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V"); 407 jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView); 408 if (!(*env)->IsSameObject(env, jlocal, NULL)) { 409 JNFCallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent); 410 (*env)->DeleteLocalRef(env, jlocal); 411 } 412 (*env)->DeleteLocalRef(env, jEvent); 413 } 414 415 - (void) resetTrackingArea { 416 if (rolloverTrackingArea != nil) { 417 [self removeTrackingArea:rolloverTrackingArea]; 418 [rolloverTrackingArea release]; 419 } 420 421 int options = (NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited | 422 NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag); |