< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m

Print this page




 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);




 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, "(IIIIIIIIDDI)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                                   [AWTToolkit scrollStateWithEvent: event]);
 397     CHECK_NULL(jEvent);
 398     
 399     static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
 400     static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
 401     jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
 402     if (!(*env)->IsSameObject(env, jlocal, NULL)) {
 403         JNFCallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent);
 404         (*env)->DeleteLocalRef(env, jlocal);
 405     }
 406     (*env)->DeleteLocalRef(env, jEvent);
 407 }
 408 
 409 - (void) resetTrackingArea {
 410     if (rolloverTrackingArea != nil) {
 411         [self removeTrackingArea:rolloverTrackingArea];
 412         [rolloverTrackingArea release];
 413     }
 414     
 415     int options = (NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited |
 416                    NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag);


< prev index next >