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
72 self = [super initWithFrame: rect];
73 if (self == nil) return self;
74
75 m_cPlatformView = cPlatformView;
76 fInputMethodLOCKABLE = NULL;
77 fKeyEventsNeeded = NO;
78 fProcessingKeystroke = NO;
79
80 fEnablePressAndHold = shouldUsePressAndHold();
81 fInPressAndHold = NO;
82 fPAHNeedsToSelect = NO;
83
282 }
283
284 - (void) keyUp: (NSEvent *)event {
285 [self deliverJavaKeyEventHelper: event];
286 }
287
288 - (void) flagsChanged: (NSEvent *)event {
289 [self deliverJavaKeyEventHelper: event];
290 }
291
292 - (BOOL) performKeyEquivalent: (NSEvent *) event {
293 [self deliverJavaKeyEventHelper: event];
294 return NO;
295 }
296
297 /**
298 * Utility methods and accessors
299 */
300
301 -(void) deliverJavaMouseEvent: (NSEvent *) event {
302 [AWTToolkit eventCountPlusPlus];
303
304 JNIEnv *env = [ThreadUtilities getJNIEnv];
305
306 NSPoint eventLocation = [event locationInWindow];
307 NSPoint localPoint = [self convertPoint: eventLocation fromView: nil];
308 NSPoint absP = [NSEvent mouseLocation];
309 NSEventType type = [event type];
310
311 // Convert global numbers between Cocoa's coordinate system and Java.
312 // TODO: need consitent way for doing that both with global as well as with local coordinates.
313 // The reason to do it here is one more native method for getting screen dimension otherwise.
314
315 NSRect screenRect = [[NSScreen mainScreen] frame];
316 absP.y = screenRect.size.height - absP.y;
317 jint clickCount;
318
319 if (type == NSMouseEntered ||
320 type == NSMouseExited ||
321 type == NSScrollWheel ||
322 type == NSMouseMoved) {
323 clickCount = 0;
324 } else {
325 clickCount = [event clickCount];
326 }
327
328 static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
329 static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V");
|
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 @synthesize mouseIsOver;
65
66 // Note: Must be called on main (AppKit) thread only
67 - (id) initWithRect: (NSRect) rect
68 platformView: (jobject) cPlatformView
69 windowLayer: (CALayer*) windowLayer
70 {
71 AWT_ASSERT_APPKIT_THREAD;
72 // Initialize ourselves
73 self = [super initWithFrame: rect];
74 if (self == nil) return self;
75
76 m_cPlatformView = cPlatformView;
77 fInputMethodLOCKABLE = NULL;
78 fKeyEventsNeeded = NO;
79 fProcessingKeystroke = NO;
80
81 fEnablePressAndHold = shouldUsePressAndHold();
82 fInPressAndHold = NO;
83 fPAHNeedsToSelect = NO;
84
283 }
284
285 - (void) keyUp: (NSEvent *)event {
286 [self deliverJavaKeyEventHelper: event];
287 }
288
289 - (void) flagsChanged: (NSEvent *)event {
290 [self deliverJavaKeyEventHelper: event];
291 }
292
293 - (BOOL) performKeyEquivalent: (NSEvent *) event {
294 [self deliverJavaKeyEventHelper: event];
295 return NO;
296 }
297
298 /**
299 * Utility methods and accessors
300 */
301
302 -(void) deliverJavaMouseEvent: (NSEvent *) event {
303
304 NSEventType type = [event type];
305
306 // check synthesized mouse entered/exited events
307 if((type == NSMouseEntered && mouseIsOver) || (type == NSMouseExited && !mouseIsOver)){
308 return;
309 }else if((type == NSMouseEntered && !mouseIsOver) || (type == NSMouseExited && mouseIsOver)){
310 mouseIsOver = !mouseIsOver;
311 }
312
313 [AWTToolkit eventCountPlusPlus];
314
315 JNIEnv *env = [ThreadUtilities getJNIEnv];
316
317 NSPoint eventLocation = [event locationInWindow];
318 NSPoint localPoint = [self convertPoint: eventLocation fromView: nil];
319 NSPoint absP = [NSEvent mouseLocation];
320
321 // Convert global numbers between Cocoa's coordinate system and Java.
322 // TODO: need consitent way for doing that both with global as well as with local coordinates.
323 // The reason to do it here is one more native method for getting screen dimension otherwise.
324
325 NSRect screenRect = [[NSScreen mainScreen] frame];
326 absP.y = screenRect.size.height - absP.y;
327 jint clickCount;
328
329 if (type == NSMouseEntered ||
330 type == NSMouseExited ||
331 type == NSScrollWheel ||
332 type == NSMouseMoved) {
333 clickCount = 0;
334 } else {
335 clickCount = [event clickCount];
336 }
337
338 static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/event/NSEvent");
339 static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V");
|