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