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

Print this page




  31 #import "ThreadUtilities.h"
  32 #import "AWTView.h"
  33 #import "AWTEvent.h"
  34 #import "AWTWindow.h"
  35 #import "LWCToolkit.h"
  36 #import "JavaComponentAccessibility.h"
  37 #import "JavaTextAccessibility.h"
  38 #import "GeomUtilities.h"
  39 #import "OSVersion.h"
  40 #import "CGLLayer.h"
  41 
  42 @interface AWTView()
  43 @property (retain) CDropTarget *_dropTarget;
  44 @property (retain) CDragSource *_dragSource;
  45 @end
  46 
  47 // Uncomment this line to see fprintfs of each InputMethod API being called on this View
  48 //#define IM_DEBUG TRUE
  49 //#define EXTRA_DEBUG
  50 
  51 
  52 static BOOL shouldUsePressAndHold() {
  53     static int shouldUsePressAndHold = -1;
  54     if (shouldUsePressAndHold != -1) return shouldUsePressAndHold;
  55     shouldUsePressAndHold = !isSnowLeopardOrLower();
  56     return shouldUsePressAndHold;
  57 }
  58 
  59 @implementation AWTView
  60 
  61 @synthesize _dropTarget;
  62 @synthesize _dragSource;
  63 @synthesize cglLayer;
  64 
  65 // Note: Must be called on main (AppKit) thread only
  66 - (id) initWithRect: (NSRect) rect
  67        platformView: (jobject) cPlatformView
  68        windowLayer: (CALayer*) windowLayer
  69 {
  70 AWT_ASSERT_APPKIT_THREAD;
  71     // Initialize ourselves


 351     if (rolloverTrackingRectTag > 0) {
 352         [self removeTrackingRect:rolloverTrackingRectTag];
 353         rolloverTrackingRectTag = 0;
 354     }
 355 }
 356 
 357 - (void) resetTrackingRect {
 358     [self clearTrackingRect];
 359     rolloverTrackingRectTag = [self addTrackingRect:[self visibleRect]
 360                                               owner:self
 361                                            userData:NULL
 362                                        assumeInside:NO];
 363 }
 364 
 365 - (void) resetCursorRects {
 366     [super resetCursorRects];
 367     [self resetTrackingRect];
 368 }
 369 
 370 -(void) deliverJavaKeyEventHelper: (NSEvent *) event {







 371     [AWTToolkit eventCountPlusPlus];
 372     JNIEnv *env = [ThreadUtilities getJNIEnv];
 373 
 374     jstring characters = NULL;
 375     if ([event type] != NSFlagsChanged) {
 376         characters = JNFNSToJavaString(env, [event characters]);    
 377     }
 378 
 379     static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
 380     static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;)V");
 381     jobject jevent = JNFNewObject(env, jctor_NSEvent,
 382                                   [event type],
 383                                   [event modifierFlags],
 384                                   [event keyCode],
 385                                   characters);
 386 
 387     static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
 388     static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
 389                             "deliverKeyEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V");
 390     JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent);




  31 #import "ThreadUtilities.h"
  32 #import "AWTView.h"
  33 #import "AWTEvent.h"
  34 #import "AWTWindow.h"
  35 #import "LWCToolkit.h"
  36 #import "JavaComponentAccessibility.h"
  37 #import "JavaTextAccessibility.h"
  38 #import "GeomUtilities.h"
  39 #import "OSVersion.h"
  40 #import "CGLLayer.h"
  41 
  42 @interface AWTView()
  43 @property (retain) CDropTarget *_dropTarget;
  44 @property (retain) CDragSource *_dragSource;
  45 @end
  46 
  47 // Uncomment this line to see fprintfs of each InputMethod API being called on this View
  48 //#define IM_DEBUG TRUE
  49 //#define EXTRA_DEBUG
  50 

  51 static BOOL shouldUsePressAndHold() {
  52     static int shouldUsePressAndHold = -1;
  53     if (shouldUsePressAndHold != -1) return shouldUsePressAndHold;
  54     shouldUsePressAndHold = !isSnowLeopardOrLower();
  55     return shouldUsePressAndHold;
  56 }
  57 
  58 @implementation AWTView
  59 
  60 @synthesize _dropTarget;
  61 @synthesize _dragSource;
  62 @synthesize cglLayer;
  63 
  64 // Note: Must be called on main (AppKit) thread only
  65 - (id) initWithRect: (NSRect) rect
  66        platformView: (jobject) cPlatformView
  67        windowLayer: (CALayer*) windowLayer
  68 {
  69 AWT_ASSERT_APPKIT_THREAD;
  70     // Initialize ourselves


 350     if (rolloverTrackingRectTag > 0) {
 351         [self removeTrackingRect:rolloverTrackingRectTag];
 352         rolloverTrackingRectTag = 0;
 353     }
 354 }
 355 
 356 - (void) resetTrackingRect {
 357     [self clearTrackingRect];
 358     rolloverTrackingRectTag = [self addTrackingRect:[self visibleRect]
 359                                               owner:self
 360                                            userData:NULL
 361                                        assumeInside:NO];
 362 }
 363 
 364 - (void) resetCursorRects {
 365     [super resetCursorRects];
 366     [self resetTrackingRect];
 367 }
 368 
 369 -(void) deliverJavaKeyEventHelper: (NSEvent *) event {
 370     static id sUnretainedLastKeyEvent = nil;    
 371     if (event == sUnretainedLastKeyEvent) {
 372         // The event is repeatedly delivered by keyDown: after performKeyEquivalent:
 373         return;
 374     }
 375     sUnretainedLastKeyEvent = event;    
 376         
 377     [AWTToolkit eventCountPlusPlus];
 378     JNIEnv *env = [ThreadUtilities getJNIEnv];
 379 
 380     jstring characters = NULL;
 381     if ([event type] != NSFlagsChanged) {
 382         characters = JNFNSToJavaString(env, [event characters]);    
 383     }
 384 
 385     static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
 386     static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;)V");
 387     jobject jevent = JNFNewObject(env, jctor_NSEvent,
 388                                   [event type],
 389                                   [event modifierFlags],
 390                                   [event keyCode],
 391                                   characters);
 392 
 393     static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
 394     static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
 395                             "deliverKeyEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V");
 396     JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent);