mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-23 00:35:13 +00:00
8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code
Reviewed-by: psadhukhan, kizune
This commit is contained in:
parent
580af4906d
commit
fa50877c2e
@ -32,6 +32,7 @@
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "GeomUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#import <Carbon/Carbon.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
@ -393,9 +394,9 @@ static BOOL shouldUsePressAndHold() {
|
||||
deltaY = [event scrollingDeltaY] * 0.1;
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
|
||||
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
|
||||
DECLARE_CLASS(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
DECLARE_METHOD(jctor_NSEvent, jc_NSEvent, "<init>", "(IIIIIIIIDDI)V");
|
||||
jobject jEvent = (*env)->NewObject(env, jc_NSEvent, jctor_NSEvent,
|
||||
[event type],
|
||||
[event modifierFlags],
|
||||
clickCount,
|
||||
@ -407,11 +408,12 @@ static BOOL shouldUsePressAndHold() {
|
||||
[AWTToolkit scrollStateWithEvent: event]);
|
||||
CHECK_NULL(jEvent);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
|
||||
DECLARE_CLASS(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
DECLARE_METHOD(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
|
||||
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
|
||||
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
|
||||
JNFCallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent);
|
||||
(*env)->CallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jlocal);
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, jEvent);
|
||||
@ -463,9 +465,9 @@ static BOOL shouldUsePressAndHold() {
|
||||
charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]);
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;Ljava/lang/String;)V");
|
||||
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
|
||||
DECLARE_CLASS(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
DECLARE_METHOD(jctor_NSEvent, jc_NSEvent, "<init>", "(IISLjava/lang/String;Ljava/lang/String;)V");
|
||||
jobject jEvent = (*env)->NewObject(env, jc_NSEvent, jctor_NSEvent,
|
||||
[event type],
|
||||
[event modifierFlags],
|
||||
[event keyCode],
|
||||
@ -473,12 +475,13 @@ static BOOL shouldUsePressAndHold() {
|
||||
charactersIgnoringModifiers);
|
||||
CHECK_NULL(jEvent);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
|
||||
DECLARE_CLASS(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
DECLARE_METHOD(jm_deliverKeyEvent, jc_PlatformView,
|
||||
"deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
|
||||
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
|
||||
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
|
||||
JNFCallVoidMethod(env, jlocal, jm_deliverKeyEvent, jEvent);
|
||||
(*env)->CallVoidMethod(env, jlocal, jm_deliverKeyEvent, jEvent);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jlocal);
|
||||
}
|
||||
if (characters != NULL) {
|
||||
@ -493,12 +496,13 @@ static BOOL shouldUsePressAndHold() {
|
||||
jint w = (jint) rect.size.width;
|
||||
jint h = (jint) rect.size.height;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
static JNF_MEMBER_CACHE(jm_deliverResize, jc_PlatformView, "deliverResize", "(IIII)V");
|
||||
DECLARE_CLASS(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
DECLARE_METHOD(jm_deliverResize, jc_PlatformView, "deliverResize", "(IIII)V");
|
||||
|
||||
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
|
||||
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
|
||||
JNFCallVoidMethod(env, jlocal, jm_deliverResize, x,y,w,h);
|
||||
(*env)->CallVoidMethod(env, jlocal, jm_deliverResize, x,y,w,h);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jlocal);
|
||||
}
|
||||
}
|
||||
@ -527,11 +531,12 @@ static BOOL shouldUsePressAndHold() {
|
||||
}
|
||||
} else {
|
||||
*/
|
||||
static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
static JNF_MEMBER_CACHE(jm_deliverWindowDidExposeEvent, jc_CPlatformView, "deliverWindowDidExposeEvent", "()V");
|
||||
DECLARE_CLASS(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
DECLARE_METHOD(jm_deliverWindowDidExposeEvent, jc_CPlatformView, "deliverWindowDidExposeEvent", "()V");
|
||||
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
|
||||
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
|
||||
JNFCallVoidMethod(env, jlocal, jm_deliverWindowDidExposeEvent);
|
||||
(*env)->CallVoidMethod(env, jlocal, jm_deliverWindowDidExposeEvent);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jlocal);
|
||||
}
|
||||
/*
|
||||
@ -566,8 +571,8 @@ static BOOL shouldUsePressAndHold() {
|
||||
// NSAccessibility support
|
||||
- (jobject)awtComponent:(JNIEnv*)env
|
||||
{
|
||||
static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
|
||||
static JNF_MEMBER_CACHE(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;");
|
||||
DECLARE_CLASS_RETURN(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView", NULL);
|
||||
DECLARE_FIELD_RETURN(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;", NULL);
|
||||
if ((env == NULL) || (m_cPlatformView == NULL)) {
|
||||
NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters.");
|
||||
if (env != NULL)
|
||||
@ -580,26 +585,28 @@ static BOOL shouldUsePressAndHold() {
|
||||
jobject peer = NULL;
|
||||
jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
|
||||
if (!(*env)->IsSameObject(env, jlocal, NULL)) {
|
||||
peer = JNFGetObjectField(env, jlocal, jf_Peer);
|
||||
peer = (*env)->GetObjectField(env, jlocal, jf_Peer);
|
||||
(*env)->DeleteLocalRef(env, jlocal);
|
||||
}
|
||||
static JNF_CLASS_CACHE(jc_LWWindowPeer, "sun/lwawt/LWWindowPeer");
|
||||
static JNF_MEMBER_CACHE(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;");
|
||||
DECLARE_CLASS_RETURN(jc_LWWindowPeer, "sun/lwawt/LWWindowPeer", NULL);
|
||||
DECLARE_FIELD_RETURN(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;", NULL);
|
||||
if (peer == NULL) {
|
||||
NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView");
|
||||
JNFDumpJavaStack(env);
|
||||
return NULL;
|
||||
}
|
||||
jobject comp = JNFGetObjectField(env, peer, jf_Target);
|
||||
jobject comp = (*env)->GetObjectField(env, peer, jf_Target);
|
||||
(*env)->DeleteLocalRef(env, peer);
|
||||
return comp;
|
||||
}
|
||||
|
||||
+ (AWTView *) awtView:(JNIEnv*)env ofAccessible:(jobject)jaccessible
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAWTView, sjc_CAccessibility, "getAWTView", "(Ljavax/accessibility/Accessible;)J");
|
||||
DECLARE_CLASS_RETURN(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility", NULL);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getAWTView, sjc_CAccessibility, "getAWTView", "(Ljavax/accessibility/Accessible;)J", NULL);
|
||||
|
||||
jlong jptr = JNFCallStaticLongMethod(env, jm_getAWTView, jaccessible);
|
||||
jlong jptr = (*env)->CallStaticLongMethod(env, sjc_CAccessibility, jm_getAWTView, jaccessible);
|
||||
CHECK_EXCEPTION();
|
||||
if (jptr == 0) return nil;
|
||||
|
||||
return (AWTView *)jlong_to_ptr(jptr);
|
||||
@ -925,7 +932,13 @@ static BOOL shouldUsePressAndHold() {
|
||||
/******************************** BEGIN NSTextInputClient Protocol ********************************/
|
||||
|
||||
|
||||
JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
static jclass jc_CInputMethod = NULL;
|
||||
|
||||
#define GET_CIM_CLASS() \
|
||||
GET_CLASS(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
|
||||
#define GET_CIM_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod", ret);
|
||||
|
||||
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
|
||||
{
|
||||
@ -966,16 +979,19 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
if ([self hasMarkedText] || !fProcessingKeystroke || aStringIsComplex) {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
|
||||
GET_CIM_CLASS();
|
||||
DECLARE_METHOD(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
|
||||
// We need to select the previous glyph so that it is overwritten.
|
||||
if (fPAHNeedsToSelect) {
|
||||
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
|
||||
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
|
||||
CHECK_EXCEPTION();
|
||||
fPAHNeedsToSelect = NO;
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
|
||||
DECLARE_METHOD(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
|
||||
jstring insertedText = JNFNSToJavaString(env, useString);
|
||||
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, insertedText);
|
||||
|
||||
// The input method event will create psuedo-key events for each character in the committed string.
|
||||
@ -1030,16 +1046,18 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
#ifdef IM_DEBUG
|
||||
fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", loc=%lu, length=%lu\n", [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length);
|
||||
#endif // IM_DEBUG
|
||||
static JNF_MEMBER_CACHE(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V");
|
||||
static JNF_MEMBER_CACHE(jm_addAttribute, jc_CInputMethod, "addAttribute", "(ZZII)V");
|
||||
static JNF_MEMBER_CACHE(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIZ)V");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CIM_CLASS();
|
||||
DECLARE_METHOD(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V");
|
||||
DECLARE_METHOD(jm_addAttribute, jc_CInputMethod, "addAttribute", "(ZZII)V");
|
||||
DECLARE_METHOD(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIZ)V");
|
||||
|
||||
// NSInputContext already did the analysis of the TSM event and created attributes indicating
|
||||
// the underlining and color that should be done to the string. We need to look at the underline
|
||||
// style and color to determine what kind of Java hilighting needs to be done.
|
||||
jstring inProcessText = JNFNSToJavaString(env, incomingString);
|
||||
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, inProcessText);
|
||||
|
||||
if (isAttributedString) {
|
||||
@ -1062,20 +1080,24 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
(NSColor *)[attributes objectForKey:NSUnderlineColorAttributeName];
|
||||
isGray = !([underlineColorObj isEqual:[NSColor blackColor]]);
|
||||
|
||||
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline,
|
||||
isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
|
||||
DECLARE_METHOD(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
|
||||
// We need to select the previous glyph so that it is overwritten.
|
||||
if (fPAHNeedsToSelect) {
|
||||
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
|
||||
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
|
||||
CHECK_EXCEPTION();
|
||||
fPAHNeedsToSelect = NO;
|
||||
}
|
||||
|
||||
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
|
||||
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText,
|
||||
selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
// If the marked text is being cleared (zero-length string) don't handle the key event.
|
||||
if ([incomingString length] == 0) {
|
||||
fKeyEventsNeeded = NO;
|
||||
@ -1093,10 +1115,11 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
}
|
||||
|
||||
// unmarkText cancels any input in progress and commits it to the text field.
|
||||
static JNF_MEMBER_CACHE(jm_unmarkText, jc_CInputMethod, "unmarkText", "()V");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
|
||||
GET_CIM_CLASS();
|
||||
DECLARE_METHOD(jm_unmarkText, jc_CInputMethod, "unmarkText", "()V");
|
||||
(*env)->CallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
- (BOOL) hasMarkedText
|
||||
@ -1109,12 +1132,15 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
return NO;
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jf_fCurrentText, jc_CInputMethod, "fCurrentText", "Ljava/text/AttributedString;");
|
||||
static JNF_MEMBER_CACHE(jf_fCurrentTextLength, jc_CInputMethod, "fCurrentTextLength", "I");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject currentText = JNFGetObjectField(env, fInputMethodLOCKABLE, jf_fCurrentText);
|
||||
GET_CIM_CLASS_RETURN(NO);
|
||||
DECLARE_FIELD_RETURN(jf_fCurrentText, jc_CInputMethod, "fCurrentText", "Ljava/text/AttributedString;", NO);
|
||||
DECLARE_FIELD_RETURN(jf_fCurrentTextLength, jc_CInputMethod, "fCurrentTextLength", "I", NO);
|
||||
jobject currentText = (*env)->GetObjectField(env, fInputMethodLOCKABLE, jf_fCurrentText);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
jint currentTextLength = JNFGetIntField(env, fInputMethodLOCKABLE, jf_fCurrentTextLength);
|
||||
jint currentTextLength = (*env)->GetIntField(env, fInputMethodLOCKABLE, jf_fCurrentTextLength);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
BOOL hasMarkedText = (currentText != NULL && currentTextLength > 0);
|
||||
|
||||
@ -1143,9 +1169,10 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
fprintf(stderr, "AWTView InputMethod Selector Called : [attributedSubstringFromRange] location=%lu, length=%lu\n", (unsigned long)theRange.location, (unsigned long)theRange.length);
|
||||
#endif // IM_DEBUG
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject theString = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
DECLARE_METHOD_RETURN(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;", nil);
|
||||
jobject theString = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION_NULL_RETURN(theString, nil);
|
||||
|
||||
id result = [[[NSAttributedString alloc] initWithString:JNFJavaToNSString(env, theString)] autorelease];
|
||||
#ifdef IM_DEBUG
|
||||
@ -1170,14 +1197,16 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
return NSMakeRange(NSNotFound, 0);
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_markedRange, jc_CInputMethod, "markedRange", "()[I");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jarray array;
|
||||
jboolean isCopy;
|
||||
jint *_array;
|
||||
NSRange range = NSMakeRange(NSNotFound, 0);
|
||||
GET_CIM_CLASS_RETURN(range);
|
||||
DECLARE_METHOD_RETURN(jm_markedRange, jc_CInputMethod, "markedRange", "()[I", range);
|
||||
|
||||
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
if (array) {
|
||||
_array = (*env)->GetIntArrayElements(env, array, &isCopy);
|
||||
@ -1205,18 +1234,20 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
return NSMakeRange(NSNotFound, 0);
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_selectedRange, jc_CInputMethod, "selectedRange", "()[I");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jarray array;
|
||||
jboolean isCopy;
|
||||
jint *_array;
|
||||
NSRange range = NSMakeRange(NSNotFound, 0);
|
||||
GET_CIM_CLASS_RETURN(range);
|
||||
DECLARE_METHOD_RETURN(jm_selectedRange, jc_CInputMethod, "selectedRange", "()[I", range);
|
||||
|
||||
#ifdef IM_DEBUG
|
||||
fprintf(stderr, "AWTView InputMethod Selector Called : [selectedRange]\n");
|
||||
#endif // IM_DEBUG
|
||||
|
||||
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
if (array) {
|
||||
_array = (*env)->GetIntArrayElements(env, array, &isCopy);
|
||||
if (_array != NULL) {
|
||||
@ -1238,9 +1269,10 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_firstRectForCharacterRange, jc_CInputMethod,
|
||||
"firstRectForCharacterRange", "(I)[I");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CIM_CLASS_RETURN(NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_firstRectForCharacterRange, jc_CInputMethod,
|
||||
"firstRectForCharacterRange", "(I)[I", NSZeroRect);
|
||||
jarray array;
|
||||
jboolean isCopy;
|
||||
jint *_array;
|
||||
@ -1252,7 +1284,7 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
(unsigned long)theRange.location, (unsigned long)theRange.length);
|
||||
#endif // IM_DEBUG
|
||||
|
||||
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange,
|
||||
array = (*env)->CallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange,
|
||||
theRange.location); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
|
||||
_array = (*env)->GetIntArrayElements(env, array, &isCopy);
|
||||
@ -1281,9 +1313,10 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
return NSNotFound;
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_characterIndexForPoint, jc_CInputMethod,
|
||||
"characterIndexForPoint", "(II)I");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CIM_CLASS_RETURN(NSNotFound);
|
||||
DECLARE_METHOD_RETURN(jm_characterIndexForPoint, jc_CInputMethod,
|
||||
"characterIndexForPoint", "(II)I", NSNotFound);
|
||||
|
||||
NSPoint flippedLocation = ConvertNSScreenPoint(env, thePoint);
|
||||
|
||||
@ -1291,7 +1324,9 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
|
||||
fprintf(stderr, "AWTView InputMethod Selector Called : [characterIndexForPoint:(NSPoint)thePoint] x=%f, y=%f\n", flippedLocation.x, flippedLocation.y);
|
||||
#endif // IM_DEBUG
|
||||
|
||||
jint index = JNFCallIntMethod(env, fInputMethodLOCKABLE, jm_characterIndexForPoint, (jint)flippedLocation.x, (jint)flippedLocation.y); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
jint index = (*env)->CallIntMethod(env, fInputMethodLOCKABLE, jm_characterIndexForPoint,
|
||||
(jint)flippedLocation.x, (jint)flippedLocation.y); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
#ifdef IM_DEBUG
|
||||
fprintf(stderr, "characterIndexForPoint returning %d\n", index);
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#import "AWTView.h"
|
||||
#import "GeomUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#define MASK(KEY) \
|
||||
(sun_lwawt_macosx_CPlatformWindow_ ## KEY)
|
||||
@ -45,7 +46,12 @@
|
||||
#define SET(BITS, KEY, VALUE) \
|
||||
BITS = VALUE ? BITS | MASK(KEY) : BITS & ~MASK(KEY)
|
||||
|
||||
static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
|
||||
static jclass jc_CPlatformWindow = NULL;
|
||||
#define GET_CPLATFORM_WINDOW_CLASS() \
|
||||
GET_CLASS(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
|
||||
|
||||
#define GET_CPLATFORM_WINDOW_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow", ret);
|
||||
|
||||
// Cocoa windowDidBecomeKey/windowDidResignKey notifications
|
||||
// doesn't provide information about "opposite" window, so we
|
||||
@ -113,17 +119,21 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||
jobject platformWindow = [((AWTWindow *)self.delegate).javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
// extract the target AWT Window object out of the CPlatformWindow
|
||||
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
|
||||
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_FIELD(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
|
||||
jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target);
|
||||
if (awtWindow != NULL) {
|
||||
// translate the point into Java coordinates
|
||||
NSPoint loc = [event locationInWindow];
|
||||
loc.y = [self frame].size.height - loc.y;
|
||||
|
||||
// send up to the GestureHandler to recursively dispatch on the AWT event thread
|
||||
static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V");
|
||||
JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b);
|
||||
DECLARE_CLASS(jc_GestureHandler, "com/apple/eawt/event/GestureHandler");
|
||||
DECLARE_METHOD(sjm_handleGestureFromNative, jc_GestureHandler,
|
||||
"handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V");
|
||||
(*env)->CallStaticVoidMethod(env, jc_GestureHandler, sjm_handleGestureFromNative,
|
||||
awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, awtWindow);
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
@ -486,8 +496,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_isBlocked, jc_CPlatformWindow, "isBlocked", "()Z");
|
||||
isBlocked = JNFCallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO;
|
||||
GET_CPLATFORM_WINDOW_CLASS_RETURN(isBlocked);
|
||||
DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isBlocked", "()Z", isBlocked);
|
||||
isBlocked = (*env)->CallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO;
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
|
||||
@ -501,8 +513,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z");
|
||||
isSimpleWindowOwnedByEmbeddedFrame = JNFCallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO;
|
||||
GET_CPLATFORM_WINDOW_CLASS_RETURN(NO);
|
||||
DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z", NO);
|
||||
isSimpleWindowOwnedByEmbeddedFrame = (*env)->CallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO;
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
|
||||
@ -520,8 +534,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [awtWindow.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z");
|
||||
isVisible = JNFCallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO;
|
||||
GET_CPLATFORM_WINDOW_CLASS_RETURN(isVisible);
|
||||
DECLARE_METHOD_RETURN(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z", isVisible)
|
||||
isVisible = (*env)->CallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO;
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
|
||||
}
|
||||
@ -589,9 +605,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow,
|
||||
"checkBlockingAndOrder", "()Z");
|
||||
JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder);
|
||||
GET_CPLATFORM_WINDOW_CLASS_RETURN(NO);
|
||||
DECLARE_METHOD_RETURN(jm_checkBlockingAndOrder, jc_CPlatformWindow, "checkBlockingAndOrder", "()Z", NO);
|
||||
(*env)->CallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
}
|
||||
@ -622,13 +639,15 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V");
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
|
||||
(jint)frame.origin.x,
|
||||
(jint)frame.origin.y,
|
||||
(jint)frame.size.width,
|
||||
(jint)frame.size.height,
|
||||
(jboolean)[self.nsWindow inLiveResize]);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
|
||||
[AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
|
||||
@ -693,8 +712,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_deliverIconify, iconify);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
}
|
||||
@ -707,8 +728,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_windowWillMiniaturize);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V");
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_windowWillMiniaturize);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
// Explicitly make myself a key window to avoid possible
|
||||
@ -737,9 +760,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
(*env)->DeleteLocalRef(env, oppositeWindow);
|
||||
}
|
||||
@ -766,8 +790,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_windowDidBecomeMain);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
}
|
||||
@ -880,24 +906,28 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_deliverWindowClosingEvent);
|
||||
GET_CPLATFORM_WINDOW_CLASS_RETURN(NO);
|
||||
DECLARE_METHOD_RETURN(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V", NO);
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_deliverWindowClosingEvent);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
// The window will be closed (if allowed) as result of sending Java event
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env {
|
||||
static JNF_CLASS_CACHE(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_notifyFullScreenOperation, jc_FullScreenHandler, "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V");
|
||||
static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
|
||||
DECLARE_CLASS(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler");
|
||||
DECLARE_STATIC_METHOD(jm_notifyFullScreenOperation, jc_FullScreenHandler,
|
||||
"handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V");
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_FIELD(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
|
||||
jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target);
|
||||
if (awtWindow != NULL) {
|
||||
JNFCallStaticVoidMethod(env, jm_notifyFullScreenOperation, awtWindow, op);
|
||||
(*env)->CallStaticVoidMethod(env, jc_FullScreenHandler, jm_notifyFullScreenOperation, awtWindow, op);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, awtWindow);
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
@ -906,22 +936,26 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
|
||||
- (void)windowWillEnterFullScreen:(NSNotification *)notification {
|
||||
static JNF_MEMBER_CACHE(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V");
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
JNFCallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen);
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen);
|
||||
CHECK_EXCEPTION();
|
||||
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env];
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowDidEnterFullScreen:(NSNotification *)notification {
|
||||
static JNF_MEMBER_CACHE(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V");
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
JNFCallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen);
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen);
|
||||
CHECK_EXCEPTION();
|
||||
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env];
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
@ -929,22 +963,31 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
}
|
||||
|
||||
- (void)windowWillExitFullScreen:(NSNotification *)notification {
|
||||
static JNF_MEMBER_CACHE(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V");
|
||||
if (jm_windowWillExitFullScreen == NULL) {
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
jm_windowWillExitFullScreen = (*env)->GetMethodID(env, jc_CPlatformWindow, "windowWillExitFullScreen", "()V");
|
||||
}
|
||||
CHECK_NULL(jm_windowWillExitFullScreen);
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
JNFCallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen);
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen);
|
||||
CHECK_EXCEPTION();
|
||||
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env];
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification {
|
||||
static JNF_MEMBER_CACHE(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
JNFCallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V");
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen);
|
||||
CHECK_EXCEPTION();
|
||||
[self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env];
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
@ -960,8 +1003,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
|
||||
JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
|
||||
(*env)->CallVoidMethod(env,platformWindow, jm_orderAboveSiblings);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
}
|
||||
@ -978,8 +1023,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
|
||||
if (platformWindow != NULL) {
|
||||
// Currently, no need to deliver the whole NSEvent.
|
||||
static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
|
||||
JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
|
||||
(*env)->CallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
}
|
||||
@ -1198,9 +1245,9 @@ JNF_COCOA_ENTER(env);
|
||||
jint bottom = (jint)(contentRect.origin.y - frame.origin.y);
|
||||
jint right = (jint)(frame.size.width - (contentRect.size.width + left));
|
||||
|
||||
static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets");
|
||||
static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V");
|
||||
ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right);
|
||||
DECLARE_CLASS_RETURN(jc_Insets, "java/awt/Insets", NULL);
|
||||
DECLARE_METHOD_RETURN(jc_Insets_ctor, jc_Insets, "<init>", "(IIII)V", NULL);
|
||||
ret = (*env)->NewObject(env, jc_Insets, jc_Insets_ctor, top, left, bottom, right);
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
return ret;
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#import "CMenuBar.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "NSApplicationAWT.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#pragma mark App Menu helpers
|
||||
|
||||
@ -243,9 +244,11 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
BOOL prefsEnabled = (prefsAvailable && [self.fPreferencesMenu isEnabled] && ([self.fPreferencesMenu target] != nil));
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(sjc_AppMenuBarHandler, "com/apple/eawt/_AppMenuBarHandler");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_initMenuStates, sjc_AppMenuBarHandler, "initMenuStates", "(ZZZZ)V");
|
||||
JNFCallStaticVoidMethod(env, sjm_initMenuStates, aboutAvailable, aboutEnabled, prefsAvailable, prefsEnabled);
|
||||
DECLARE_CLASS_RETURN(sjc_AppMenuBarHandler, "com/apple/eawt/_AppMenuBarHandler", NULL);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_initMenuStates, sjc_AppMenuBarHandler, "initMenuStates", "(ZZZZ)V", NULL);
|
||||
(*env)->CallStaticVoidMethod(env, sjc_AppMenuBarHandler, sjm_initMenuStates,
|
||||
aboutAvailable, aboutEnabled, prefsAvailable, prefsEnabled);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// register for the finish launching and system power off notifications by default
|
||||
NSNotificationCenter *ctr = [NSNotificationCenter defaultCenter];
|
||||
@ -272,7 +275,12 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
#pragma mark Callbacks from AppKit
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_AppEventHandler, "com/apple/eawt/_AppEventHandler");
|
||||
static jclass sjc_AppEventHandler = NULL;
|
||||
#define GET_APPEVENTHANDLER_CLASS() \
|
||||
GET_CLASS(sjc_AppEventHandler, "com/apple/eawt/_AppEventHandler");
|
||||
|
||||
#define GET_APPEVENTHANDLER_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(sjc_AppEventHandler, "com/apple/eawt/_AppEventHandler", ret);
|
||||
|
||||
- (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
@ -283,8 +291,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
//fprintf(stderr,"jm_handleOpenURL\n");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jstring jURL = JNFNSToJavaString(env, url);
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_handleOpenURI, sjc_AppEventHandler, "handleOpenURI", "(Ljava/lang/String;)V");
|
||||
JNFCallStaticVoidMethod(env, jm_handleOpenURI, jURL); // AWT_THREADING Safe (event)
|
||||
GET_APPEVENTHANDLER_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_handleOpenURI, sjc_AppEventHandler, "handleOpenURI", "(Ljava/lang/String;)V");
|
||||
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenURI, jURL); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jURL);
|
||||
|
||||
[replyEvent insertDescriptor:[NSAppleEventDescriptor nullDescriptor] atIndex:0];
|
||||
@ -293,14 +303,22 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
// Helper for both open file and print file methods
|
||||
// Creates a Java list of files from a native list of files
|
||||
- (jobject)_createFilePathArrayFrom:(NSArray *)filenames withEnv:(JNIEnv *)env {
|
||||
static JNF_CLASS_CACHE(sjc_ArrayList, "java/util/ArrayList");
|
||||
static JNF_CTOR_CACHE(jm_ArrayList_ctor, sjc_ArrayList, "(I)V");
|
||||
static JNF_MEMBER_CACHE(jm_ArrayList_add, sjc_ArrayList, "add", "(Ljava/lang/Object;)Z");
|
||||
static jclass sjc_ArrayList = NULL;
|
||||
if (sjc_ArrayList == NULL) {
|
||||
sjc_ArrayList = (*env)->FindClass(env, "java/util/ArrayList");
|
||||
if (sjc_ArrayList != NULL) sjc_ArrayList = (*env)->NewGlobalRef(env, sjc_ArrayList); \
|
||||
}
|
||||
CHECK_NULL_RETURN(sjc_ArrayList, NULL);
|
||||
DECLARE_METHOD_RETURN(jm_ArrayList_ctor, sjc_ArrayList, "<init>", "(I)V", NULL);
|
||||
DECLARE_METHOD_RETURN(jm_ArrayList_add, sjc_ArrayList, "add", "(Ljava/lang/Object;)Z", NULL);
|
||||
|
||||
jobject jFileNamesArray = (*env)->NewObject(env, sjc_ArrayList, jm_ArrayList_ctor, (jint)[filenames count]); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION_NULL_RETURN(jFileNamesArray, NULL);
|
||||
|
||||
jobject jFileNamesArray = JNFNewObject(env, jm_ArrayList_ctor, (jint)[filenames count]); // AWT_THREADING Safe (known object)
|
||||
for (NSString *filename in filenames) {
|
||||
jstring jFileName = JNFNormalizedJavaStringForPath(env, filename);
|
||||
JNFCallVoidMethod(env, jFileNamesArray, jm_ArrayList_add, jFileName);
|
||||
(*env)->CallVoidMethod(env, jFileNamesArray, jm_ArrayList_add, jFileName);
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
return jFileNamesArray;
|
||||
@ -325,8 +343,11 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
// convert the file names array
|
||||
jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env];
|
||||
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_handleOpenFiles, sjc_AppEventHandler, "handleOpenFiles", "(Ljava/util/List;Ljava/lang/String;)V");
|
||||
JNFCallStaticVoidMethod(env, jm_handleOpenFiles, jFileNamesArray, jSearchString);
|
||||
GET_APPEVENTHANDLER_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_handleOpenFiles, sjc_AppEventHandler,
|
||||
"handleOpenFiles", "(Ljava/util/List;Ljava/lang/String;)V");
|
||||
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenFiles, jFileNamesArray, jSearchString);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jFileNamesArray);
|
||||
(*env)->DeleteLocalRef(env, jSearchString);
|
||||
|
||||
@ -341,8 +362,11 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
//fprintf(stderr,"jm_handlePrintFile\n");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_handlePrintFile, sjc_AppEventHandler, "handlePrintFiles", "(Ljava/util/List;)V");
|
||||
JNFCallStaticVoidMethod(env, jm_handlePrintFile, jFileNamesArray); // AWT_THREADING Safe (event)
|
||||
GET_APPEVENTHANDLER_CLASS_RETURN(NSPrintingCancelled);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_handlePrintFile, sjc_AppEventHandler,
|
||||
"handlePrintFiles", "(Ljava/util/List;)V", NSPrintingCancelled);
|
||||
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handlePrintFile, jFileNamesArray); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jFileNamesArray);
|
||||
|
||||
return NSPrintingSuccess;
|
||||
@ -354,8 +378,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
//fprintf(stderr,"jm_handleOpenApplication\n");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_handleNativeNotification, sjc_AppEventHandler, "handleNativeNotification", "(I)V");
|
||||
JNFCallStaticVoidMethod(env, jm_handleNativeNotification, notificationType); // AWT_THREADING Safe (event)
|
||||
GET_APPEVENTHANDLER_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_handleNativeNotification, sjc_AppEventHandler, "handleNativeNotification", "(I)V");
|
||||
(*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleNativeNotification, notificationType); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
// About menu handler
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
#import "CDataTransferer.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "jni_util.h"
|
||||
#import "JNIUtilities.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
|
||||
@ -88,18 +88,19 @@
|
||||
if (self.changeCount != newChangeCount) {
|
||||
self.changeCount = newChangeCount;
|
||||
|
||||
// Notify that the content might be changed
|
||||
static JNF_CLASS_CACHE(jc_CClipboard, "sun/lwawt/macosx/CClipboard");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_contentChanged, jc_CClipboard, "notifyChanged", "()V");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNFCallStaticVoidMethod(env, jm_contentChanged);
|
||||
// Notify that the content might be changed
|
||||
DECLARE_CLASS(jc_CClipboard, "sun/lwawt/macosx/CClipboard");
|
||||
DECLARE_STATIC_METHOD(jm_contentChanged, jc_CClipboard, "notifyChanged", "()V");
|
||||
(*env)->CallStaticVoidMethod(env, jc_CClipboard, jm_contentChanged);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// If we have a Java pasteboard owner, tell it that it doesn't own the pasteboard anymore.
|
||||
static JNF_MEMBER_CACHE(jm_lostOwnership, jc_CClipboard, "notifyLostOwnership", "()V");
|
||||
DECLARE_METHOD(jm_lostOwnership, jc_CClipboard, "notifyLostOwnership", "()V");
|
||||
@synchronized(self) {
|
||||
if (self.clipboardOwner) {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNFCallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
|
||||
(*env)->CallVoidMethod(env, self.clipboardOwner, jm_lostOwnership); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
JNFDeleteGlobalRef(env, self.clipboardOwner);
|
||||
self.clipboardOwner = NULL;
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
#import "DnDUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "LWCToolkit.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
|
||||
// When sIsJavaDragging is true Java drag gesture has been recognized and a drag is/has been initialized.
|
||||
@ -69,9 +70,17 @@ static BOOL sIsJavaDragging;
|
||||
}
|
||||
@end
|
||||
|
||||
JNF_CLASS_CACHE(DataTransfererClass, "sun/awt/datatransfer/DataTransferer");
|
||||
JNF_CLASS_CACHE(CDragSourceContextPeerClass, "sun/lwawt/macosx/CDragSourceContextPeer");
|
||||
JNF_CLASS_CACHE(CImageClass, "sun/lwawt/macosx/CImage");
|
||||
static jclass DataTransfererClass = NULL;
|
||||
static jclass CDragSourceContextPeerClass = NULL;
|
||||
|
||||
#define GET_DT_CLASS() \
|
||||
GET_CLASS(DataTransfererClass, "sun/awt/datatransfer/DataTransferer");
|
||||
|
||||
#define GET_DT_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(DataTransfererClass, "sun/awt/datatransfer/DataTransferer", ret);
|
||||
|
||||
#define GET_DSCP_CLASS() \
|
||||
GET_CLASS(CDragSourceContextPeerClass, "sun/lwawt/macosx/CDragSourceContextPeer");
|
||||
|
||||
static NSDragOperation sDragOperation;
|
||||
static NSPoint sDraggingLocation;
|
||||
@ -212,8 +221,11 @@ static BOOL sNeedsEnter;
|
||||
//
|
||||
- (jobject)dataTransferer:(JNIEnv*)env
|
||||
{
|
||||
JNF_STATIC_MEMBER_CACHE(getInstanceMethod, DataTransfererClass, "getInstance", "()Lsun/awt/datatransfer/DataTransferer;");
|
||||
return JNFCallStaticObjectMethod(env, getInstanceMethod);
|
||||
GET_DT_CLASS_RETURN(NULL);
|
||||
DECLARE_STATIC_METHOD_RETURN(getInstanceMethod, DataTransfererClass, "getInstance", "()Lsun/awt/datatransfer/DataTransferer;", NULL);
|
||||
jobject o = (*env)->CallStaticObjectMethod(env, DataTransfererClass, getInstanceMethod);
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
// Appropriated from Windows' awt_DataTransferer.cpp:
|
||||
@ -227,9 +239,11 @@ static BOOL sNeedsEnter;
|
||||
jbyteArray data = nil;
|
||||
|
||||
if (transferer != NULL) {
|
||||
JNF_MEMBER_CACHE(convertDataMethod, DataTransfererClass, "convertData", "(Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;JLjava/util/Map;Z)[B");
|
||||
data = JNFCallObjectMethod(env, transferer, convertDataMethod, fComponent, fTransferable, format, fFormatMap, (jboolean) TRUE);
|
||||
GET_DT_CLASS_RETURN(NULL);
|
||||
DECLARE_METHOD_RETURN(convertDataMethod, DataTransfererClass, "convertData", "(Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;JLjava/util/Map;Z)[B", NULL);
|
||||
data = (*env)->CallObjectMethod(env, transferer, convertDataMethod, fComponent, fTransferable, format, fFormatMap, (jboolean) TRUE);
|
||||
}
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -555,11 +569,14 @@ static BOOL sNeedsEnter;
|
||||
}
|
||||
|
||||
// DragSourceContextPeer.dragDropFinished() should be called even if there was an error:
|
||||
JNF_MEMBER_CACHE(dragDropFinishedMethod, CDragSourceContextPeerClass, "dragDropFinished", "(ZIII)V");
|
||||
GET_DSCP_CLASS();
|
||||
DECLARE_METHOD(dragDropFinishedMethod, CDragSourceContextPeerClass, "dragDropFinished", "(ZIII)V");
|
||||
DLog3(@" -> posting dragDropFinished, point %f, %f", point.x, point.y);
|
||||
JNFCallVoidMethod(env, fDragSourceContextPeer, dragDropFinishedMethod, success, dragOp, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
JNF_MEMBER_CACHE(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V");
|
||||
JNFCallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable
|
||||
(*env)->CallVoidMethod(env, fDragSourceContextPeer, dragDropFinishedMethod, success, dragOp, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
DECLARE_METHOD(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V");
|
||||
(*env)->CallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable
|
||||
CHECK_EXCEPTION();
|
||||
} @finally {
|
||||
sNeedsEnter = NO;
|
||||
AWTToolkit.inDoDragDropLoop = NO;
|
||||
@ -594,8 +611,10 @@ static BOOL sNeedsEnter;
|
||||
DLog3(@" -> posting operationChanged, point %f, %f", point.x, point.y);
|
||||
jint modifiedModifiers = fDragKeyModifiers | fDragMouseModifiers | [DnDUtilities javaKeyModifiersForNSDragOperation:dragOp];
|
||||
|
||||
JNF_MEMBER_CACHE(operationChangedMethod, CDragSourceContextPeerClass, "operationChanged", "(IIII)V");
|
||||
JNFCallVoidMethod(env, fDragSourceContextPeer, operationChangedMethod, targetActions, modifiedModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
GET_DSCP_CLASS();
|
||||
DECLARE_METHOD(operationChangedMethod, CDragSourceContextPeerClass, "operationChanged", "(IIII)V");
|
||||
(*env)->CallVoidMethod(env, fDragSourceContextPeer, operationChangedMethod, targetActions, modifiedModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)localDrag {
|
||||
@ -667,12 +686,14 @@ JNF_COCOA_ENTER(env);
|
||||
DLog4(@"[CDragSource draggedImage moved]: (%f, %f) %@\n", screenPoint.x, screenPoint.y, self);
|
||||
|
||||
DLog3(@" -> posting dragMotion, point %f, %f", point.x, point.y);
|
||||
JNF_MEMBER_CACHE(dragMotionMethod, CDragSourceContextPeerClass, "dragMotion", "(IIII)V");
|
||||
JNFCallVoidMethod(env, fDragSourceContextPeer, dragMotionMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
|
||||
GET_DSCP_CLASS();
|
||||
DECLARE_METHOD(dragMotionMethod, CDragSourceContextPeerClass, "dragMotion", "(IIII)V");
|
||||
(*env)->CallVoidMethod(env, fDragSourceContextPeer, dragMotionMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
DLog3(@" -> posting dragMouseMoved, point %f, %f", point.x, point.y);
|
||||
JNF_MEMBER_CACHE(dragMouseMovedMethod, CDragSourceContextPeerClass, "dragMouseMoved", "(IIII)V");
|
||||
JNFCallVoidMethod(env, fDragSourceContextPeer, dragMouseMovedMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
DECLARE_METHOD(dragMouseMovedMethod, CDragSourceContextPeerClass, "dragMouseMoved", "(IIII)V");
|
||||
(*env)->CallVoidMethod(env, fDragSourceContextPeer, dragMouseMovedMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
@ -696,8 +717,10 @@ JNF_COCOA_EXIT(env);
|
||||
|
||||
NSPoint point = [self mapNSScreenPointToJavaWithOffset:sDraggingLocation];
|
||||
DLog3(@" -> posting dragEnter, point %f, %f", point.x, point.y);
|
||||
JNF_MEMBER_CACHE(dragEnterMethod, CDragSourceContextPeerClass, "dragEnter", "(IIII)V");
|
||||
JNFCallVoidMethod(env, fDragSourceContextPeer, dragEnterMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
GET_DSCP_CLASS();
|
||||
DECLARE_METHOD(dragEnterMethod, CDragSourceContextPeerClass, "dragEnter", "(IIII)V");
|
||||
(*env)->CallVoidMethod(env, fDragSourceContextPeer, dragEnterMethod, targetActions, (jint) fModifiers, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
- (void) postDragExit {
|
||||
@ -706,8 +729,11 @@ JNF_COCOA_EXIT(env);
|
||||
|
||||
NSPoint point = [self mapNSScreenPointToJavaWithOffset:sDraggingLocation];
|
||||
DLog3(@" -> posting dragExit, point %f, %f", point.x, point.y);
|
||||
JNF_MEMBER_CACHE(dragExitMethod, CDragSourceContextPeerClass, "dragExit", "(II)V");
|
||||
JNFCallVoidMethod(env, fDragSourceContextPeer, dragExitMethod, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
GET_DSCP_CLASS();
|
||||
DECLARE_METHOD(dragExitMethod, CDragSourceContextPeerClass, "dragExit", "(II)V");
|
||||
(*env)->CallVoidMethod(env, fDragSourceContextPeer, dragExitMethod, (jint) point.x, (jint) point.y); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#import "CDataTransferer.h"
|
||||
#import "DnDUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
|
||||
static NSInteger sDraggingSequenceNumber = -1;
|
||||
@ -57,7 +58,12 @@ static jlongArray sDraggingFormats = nil;
|
||||
|
||||
static CDropTarget* sCurrentDropTarget;
|
||||
|
||||
extern JNFClassInfo jc_CDropTargetContextPeer;
|
||||
extern jclass jc_CDropTargetContextPeer;
|
||||
#define GET_DTCP_CLASS() \
|
||||
GET_CLASS(jc_CDropTargetContextPeer, "sun/lwawt/macosx/CDropTargetContextPeer");
|
||||
|
||||
#define GET_DTCP_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(jc_CDropTargetContextPeer, "sun/lwawt/macosx/CDropTargetContextPeer", ret);
|
||||
|
||||
@implementation CDropTarget
|
||||
|
||||
@ -458,10 +464,13 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
|
||||
}
|
||||
|
||||
// Look up the CDropTargetContextPeer class:
|
||||
JNF_STATIC_MEMBER_CACHE(getDropTargetContextPeerMethod, jc_CDropTargetContextPeer, "getDropTargetContextPeer", "()Lsun/lwawt/macosx/CDropTargetContextPeer;");
|
||||
GET_DTCP_CLASS_RETURN(dragOp);
|
||||
DECLARE_STATIC_METHOD_RETURN(getDropTargetContextPeerMethod, jc_CDropTargetContextPeer,
|
||||
"getDropTargetContextPeer", "()Lsun/lwawt/macosx/CDropTargetContextPeer;", dragOp)
|
||||
if (sDraggingError == FALSE) {
|
||||
// Create a new drop target context peer:
|
||||
jobject dropTargetContextPeer = JNFCallStaticObjectMethod(env, getDropTargetContextPeerMethod);
|
||||
jobject dropTargetContextPeer = (*env)->CallStaticObjectMethod(env, jc_CDropTargetContextPeer, getDropTargetContextPeerMethod);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
if (dropTargetContextPeer != nil) {
|
||||
fDropTargetContextPeer = JNFNewGlobalRef(env, dropTargetContextPeer);
|
||||
@ -493,13 +502,16 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
|
||||
|
||||
jlongArray formats = sDraggingFormats;
|
||||
|
||||
JNF_MEMBER_CACHE(handleEnterMessageMethod, jc_CDropTargetContextPeer, "handleEnterMessage", "(Ljava/awt/Component;IIII[JJ)I");
|
||||
GET_DTCP_CLASS_RETURN(dragOp);
|
||||
DECLARE_METHOD_RETURN(handleEnterMessageMethod, jc_CDropTargetContextPeer,
|
||||
"handleEnterMessage", "(Ljava/awt/Component;IIII[JJ)I", dragOp);
|
||||
if (sDraggingError == FALSE) {
|
||||
// Double-casting self gets rid of 'different size' compiler warning:
|
||||
// AWT_THREADING Safe (CToolkitThreadBlockedHandler)
|
||||
actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod,
|
||||
actions = (*env)->CallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod,
|
||||
fComponent, (jint) javaLocation.x, (jint) javaLocation.y,
|
||||
dropAction, actions, formats, ptr_to_jlong(self));
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
if (sDraggingError == FALSE) {
|
||||
@ -578,10 +590,13 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
|
||||
|
||||
jlongArray formats = sDraggingFormats;
|
||||
|
||||
JNF_MEMBER_CACHE(handleMotionMessageMethod, jc_CDropTargetContextPeer, "handleMotionMessage", "(Ljava/awt/Component;IIII[JJ)I");
|
||||
GET_DTCP_CLASS_RETURN(dragOp);
|
||||
DECLARE_METHOD_RETURN(handleMotionMessageMethod, jc_CDropTargetContextPeer, "handleMotionMessage", "(Ljava/awt/Component;IIII[JJ)I", dragOp);
|
||||
if (sDraggingError == FALSE) {
|
||||
DLog3(@" >> posting handleMotionMessage, point %f, %f", javaLocation.x, javaLocation.y);
|
||||
userAction = JNFCallIntMethod(env, fDropTargetContextPeer, handleMotionMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
|
||||
userAction = (*env)->CallIntMethod(env, fDropTargetContextPeer, handleMotionMessageMethod, fComponent,
|
||||
(jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
if (sDraggingError == FALSE) {
|
||||
@ -608,12 +623,14 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
if (sDraggingExited == FALSE && sDraggingError == FALSE) {
|
||||
JNF_MEMBER_CACHE(handleExitMessageMethod, jc_CDropTargetContextPeer, "handleExitMessage", "(Ljava/awt/Component;J)V");
|
||||
GET_DTCP_CLASS();
|
||||
DECLARE_METHOD(handleExitMessageMethod, jc_CDropTargetContextPeer, "handleExitMessage", "(Ljava/awt/Component;J)V");
|
||||
if (sDraggingError == FALSE) {
|
||||
DLog3(@" - dragExit: loc native %f, %f\n", sDraggingLocation.x, sDraggingLocation.y);
|
||||
// AWT_THREADING Safe (CToolkitThreadBlockedHandler)
|
||||
JNFCallVoidMethod(env, fDropTargetContextPeer,
|
||||
(*env)->CallVoidMethod(env, fDropTargetContextPeer,
|
||||
handleExitMessageMethod, fComponent, ptr_to_jlong(self));
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
// 5-27-03 Note: [Radar 3270455]
|
||||
@ -658,10 +675,13 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
|
||||
|
||||
jlongArray formats = sDraggingFormats;
|
||||
|
||||
JNF_MEMBER_CACHE(handleDropMessageMethod, jc_CDropTargetContextPeer, "handleDropMessage", "(Ljava/awt/Component;IIII[JJ)V");
|
||||
GET_DTCP_CLASS_RETURN(NO);
|
||||
DECLARE_METHOD_RETURN(handleDropMessageMethod, jc_CDropTargetContextPeer, "handleDropMessage", "(Ljava/awt/Component;IIII[JJ)V", NO);
|
||||
|
||||
if (sDraggingError == FALSE) {
|
||||
JNFCallVoidMethod(env, fDropTargetContextPeer, handleDropMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (event)
|
||||
(*env)->CallVoidMethod(env, fDropTargetContextPeer, handleDropMessageMethod, fComponent,
|
||||
(jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
} else {
|
||||
// 8-19-03 Note: [Radar 3368754]
|
||||
|
||||
@ -31,14 +31,22 @@
|
||||
#import "CDropTarget.h"
|
||||
#import "DnDUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
JNF_CLASS_CACHE(jc_CDropTargetContextPeer, "sun/lwawt/macosx/CDropTargetContextPeer");
|
||||
jclass jc_CDropTargetContextPeer = NULL;
|
||||
#define GET_DTCP_CLASS() \
|
||||
GET_CLASS(jc_CDropTargetContextPeer, "sun/lwawt/macosx/CDropTargetContextPeer");
|
||||
|
||||
#define GET_DTCP_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(jc_CDropTargetContextPeer, "sun/lwawt/macosx/CDropTargetContextPeer", ret);
|
||||
|
||||
|
||||
static void TransferFailed(JNIEnv *env, jobject jthis, jlong jdroptarget, jlong jdroptransfer, jlong jformat) {
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
JNF_MEMBER_CACHE(transferFailedMethod, jc_CDropTargetContextPeer, "transferFailed", "(J)V");
|
||||
JNFCallVoidMethod(env, jthis, transferFailedMethod, jformat); // AWT_THREADING Safe (!appKit)
|
||||
GET_DTCP_CLASS();
|
||||
DECLARE_METHOD(transferFailedMethod, jc_CDropTargetContextPeer, "transferFailed", "(J)V");
|
||||
(*env)->CallVoidMethod(env, jthis, transferFailedMethod, jformat); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
static CDropTarget* GetCDropTarget(jlong jdroptarget) {
|
||||
@ -77,7 +85,8 @@ JNF_COCOA_ENTER(env);
|
||||
return result;
|
||||
}
|
||||
|
||||
JNF_MEMBER_CACHE(newDataMethod, jc_CDropTargetContextPeer, "newData", "(J[B)V");
|
||||
GET_DTCP_CLASS_RETURN(result);
|
||||
DECLARE_METHOD_RETURN(newDataMethod, jc_CDropTargetContextPeer, "newData", "(J[B)V", result);
|
||||
if ((*env)->ExceptionOccurred(env) || !newDataMethod) {
|
||||
DLog2(@"[CDropTargetContextPeer startTransfer]: couldn't get newData method for %d.\n", (NSInteger) jdroptarget);
|
||||
TransferFailed(env, jthis, jdroptarget, (jlong) 0L, jformat);
|
||||
@ -94,7 +103,7 @@ JNF_COCOA_ENTER(env);
|
||||
|
||||
// Pass the data to drop target:
|
||||
@try {
|
||||
JNFCallVoidMethod(env, jthis, newDataMethod, jformat, jdropdata); // AWT_THREADING Safe (!appKit)
|
||||
(*env)->CallVoidMethod(env, jthis, newDataMethod, jformat, jdropdata); // AWT_THREADING Safe (!appKit)
|
||||
} @catch (NSException *ex) {
|
||||
DLog2(@"[CDropTargetContextPeer startTransfer]: exception in newData() for %d.\n", (NSInteger) jdroptarget);
|
||||
JNFDeleteGlobalRef(env, jdropdata);
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
|
||||
#import "CFileDialog.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#import "java_awt_FileDialog.h"
|
||||
#import "sun_lwawt_macosx_CFileDialog.h"
|
||||
@ -144,9 +145,10 @@ canChooseDirectories:(BOOL)inChooseDirectories
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jstring jString = JNFNormalizedJavaStringForPath(env, filename);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_CFileDialog, "sun/lwawt/macosx/CFileDialog");
|
||||
static JNF_MEMBER_CACHE(jm_queryFF, jc_CFileDialog, "queryFilenameFilter", "(Ljava/lang/String;)Z");
|
||||
BOOL returnValue = JNFCallBooleanMethod(env, fFileDialog, jm_queryFF, jString); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
DECLARE_CLASS_RETURN(jc_CFileDialog, "sun/lwawt/macosx/CFileDialog", NO);
|
||||
DECLARE_METHOD_RETURN(jm_queryFF, jc_CFileDialog, "queryFilenameFilter", "(Ljava/lang/String;)Z", NO);
|
||||
BOOL returnValue = (*env)->CallBooleanMethod(env, fFileDialog, jm_queryFF, jString); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jString);
|
||||
|
||||
return returnValue;
|
||||
@ -222,8 +224,8 @@ JNF_COCOA_ENTER(env);
|
||||
NSArray *urls = [dialogDelegate URLs];
|
||||
jsize count = [urls count];
|
||||
|
||||
static JNF_CLASS_CACHE(jc_String, "java/lang/String");
|
||||
returnValue = JNFNewObjectArray(env, &jc_String, count);
|
||||
DECLARE_CLASS_RETURN(jc_String, "java/lang/String", NULL);
|
||||
returnValue = (*env)->NewObjectArray(env, count, jc_String, NULL);
|
||||
|
||||
[urls enumerateObjectsUsingBlock:^(id url, NSUInteger index, BOOL *stop) {
|
||||
jstring filename = JNFNormalizedJavaStringForPath(env, [url path]);
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#import "LWCToolkit.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#include "GeomUtilities.h"
|
||||
#include "JNIUtilities.h"
|
||||
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
|
||||
@ -159,9 +160,10 @@ static jobject createJavaDisplayMode(CGDisplayModeRef mode, JNIEnv *env) {
|
||||
w = CGDisplayModeGetWidth(mode);
|
||||
CFRelease(currentBPP);
|
||||
}
|
||||
static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");
|
||||
static JNF_CTOR_CACHE(jc_DisplayMode_ctor, jc_DisplayMode, "(IIII)V");
|
||||
ret = JNFNewObject(env, jc_DisplayMode_ctor, w, h, bpp, refrate);
|
||||
DECLARE_CLASS_RETURN(jc_DisplayMode, "java/awt/DisplayMode", ret);
|
||||
DECLARE_METHOD_RETURN(jc_DisplayMode_ctor, jc_DisplayMode, "<init>", "(IIII)V", ret);
|
||||
ret = (*env)->NewObject(env, jc_DisplayMode, jc_DisplayMode_ctor, w, h, bpp, refrate);
|
||||
CHECK_EXCEPTION();
|
||||
JNF_COCOA_EXIT(env);
|
||||
return ret;
|
||||
}
|
||||
@ -252,9 +254,9 @@ JNF_COCOA_ENTER(env);
|
||||
jint left = visibleFrame.origin.x - frame.origin.x;
|
||||
jint right = frame.size.width - visibleFrame.size.width - left;
|
||||
|
||||
static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets");
|
||||
static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V");
|
||||
ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right);
|
||||
DECLARE_CLASS_RETURN(jc_Insets, "java/awt/Insets", ret);
|
||||
DECLARE_METHOD_RETURN(jc_Insets_ctor, jc_Insets, "<init>", "(IIII)V", ret);
|
||||
ret = (*env)->NewObject(env, jc_Insets, jc_Insets_ctor, top, left, bottom, right);
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
@ -327,9 +329,9 @@ Java_sun_awt_CGraphicsDevice_nativeGetDisplayModes
|
||||
CFArrayRef allModes = getAllValidDisplayModes(displayID);
|
||||
|
||||
CFIndex numModes = allModes ? CFArrayGetCount(allModes): 0;
|
||||
static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");
|
||||
DECLARE_CLASS_RETURN(jc_DisplayMode, "java/awt/DisplayMode", NULL);
|
||||
|
||||
jreturnArray = JNFNewObjectArray(env, &jc_DisplayMode, (jsize) numModes);
|
||||
jreturnArray = (*env)->NewObjectArray(env, (jsize)numModes, jc_DisplayMode, NULL);
|
||||
if (!jreturnArray) {
|
||||
NSLog(@"CGraphicsDevice can't create java array of DisplayMode objects");
|
||||
return nil;
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
#import "AWT_debug.h"
|
||||
|
||||
#import "jni_util.h"
|
||||
#import "JNIUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
@ -74,7 +74,8 @@ JNF_COCOA_ENTER(env);
|
||||
}
|
||||
|
||||
/* Allocate a java array for display identifiers */
|
||||
ret = JNFNewIntArray(env, displayActiveCount);
|
||||
ret = (*env)->NewIntArray(env, displayActiveCount);
|
||||
CHECK_NULL_RETURN(ret, NULL);
|
||||
|
||||
/* Initialize and return the backing int array */
|
||||
assert(sizeof(jint) >= sizeof(CGDirectDisplayID));
|
||||
@ -122,12 +123,13 @@ static void displaycb_handle
|
||||
|
||||
jobject graphicsEnv = [wrapper jObjectWithEnv:env];
|
||||
if (graphicsEnv == NULL) return; // ref already GC'd
|
||||
static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
|
||||
static JNF_MEMBER_CACHE(jm_displayReconfiguration,
|
||||
DECLARE_CLASS(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
|
||||
DECLARE_METHOD(jm_displayReconfiguration,
|
||||
jc_CGraphicsEnvironment, "_displayReconfiguration","(IZ)V");
|
||||
JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
|
||||
(*env)->CallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
|
||||
(jint) display, (jboolean) flags & kCGDisplayRemoveFlag);
|
||||
(*env)->DeleteLocalRef(env, graphicsEnv);
|
||||
CHECK_EXCEPTION();
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@ -405,8 +405,8 @@ JNF_COCOA_ENTER(env);
|
||||
}
|
||||
|
||||
count = [sortedPixelSizes count];
|
||||
static JNF_CLASS_CACHE(jc_Dimension, "java/awt/Dimension");
|
||||
jreturnArray = JNFNewObjectArray(env, &jc_Dimension, count);
|
||||
DECLARE_CLASS_RETURN(jc_Dimension, "java/awt/Dimension", jreturnArray);
|
||||
jreturnArray = (*env)->NewObjectArray(env, count, jc_Dimension, NULL);
|
||||
CHECK_NULL_RETURN(jreturnArray, NULL);
|
||||
|
||||
for(i = 0; i < count; i++){
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#import "sun_lwawt_macosx_CInputMethodDescriptor.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "AWTView.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
|
||||
@ -37,20 +38,13 @@
|
||||
#define JAVA_LIST @"JAVA_LIST"
|
||||
#define CURRENT_KB_DESCRIPTION @"CURRENT_KB_DESCRIPTION"
|
||||
|
||||
static JNF_CLASS_CACHE(jc_localeClass, "java/util/Locale");
|
||||
static JNF_CTOR_CACHE(jm_localeCons, jc_localeClass, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
static JNF_CLASS_CACHE(jc_arrayListClass, "java/util/ArrayList");
|
||||
static JNF_CTOR_CACHE(jm_arrayListCons, jc_arrayListClass, "()V");
|
||||
static JNF_MEMBER_CACHE(jm_listAdd, jc_arrayListClass, "add", "(Ljava/lang/Object;)Z");
|
||||
static JNF_MEMBER_CACHE(jm_listContains, jc_arrayListClass, "contains", "(Ljava/lang/Object;)Z");
|
||||
|
||||
|
||||
|
||||
//
|
||||
// NOTE: This returns a JNI Local Ref. Any code that calls must call DeleteLocalRef with the return value.
|
||||
//
|
||||
static jobject CreateLocaleObjectFromNSString(JNIEnv *env, NSString *name)
|
||||
{
|
||||
DECLARE_CLASS_RETURN(jc_localeClass, "java/util/Locale", NULL);
|
||||
DECLARE_METHOD_RETURN(jm_localeCons, jc_localeClass, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", NULL);
|
||||
// Break apart the string into its components.
|
||||
// First, duplicate the NSString into a C string, since we're going to modify it.
|
||||
char * language = strdup([name UTF8String]);
|
||||
@ -77,8 +71,9 @@ static jobject CreateLocaleObjectFromNSString(JNIEnv *env, NSString *name)
|
||||
if(ctryObj != NULL) {
|
||||
jobject vrntObj = (*env)->NewStringUTF(env, variant);
|
||||
if (vrntObj != NULL) {
|
||||
localeObj = JNFNewObject(env, jm_localeCons,langObj, ctryObj,
|
||||
localeObj = (*env)->NewObject(env, jc_localeClass, jm_localeCons,langObj, ctryObj,
|
||||
vrntObj);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, vrntObj);
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, ctryObj);
|
||||
@ -295,6 +290,11 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CInputMethodDescriptor_nativeInit
|
||||
JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CInputMethodDescriptor_nativeGetAvailableLocales
|
||||
(JNIEnv *env, jclass klass)
|
||||
{
|
||||
DECLARE_CLASS_RETURN(jc_arrayListClass, "java/util/ArrayList", NULL);
|
||||
DECLARE_METHOD_RETURN(jm_arrayListCons, jc_arrayListClass, "<init>", "()V", NULL);
|
||||
DECLARE_METHOD_RETURN(jm_listAdd, jc_arrayListClass, "add", "(Ljava/lang/Object;)Z", NULL);
|
||||
DECLARE_METHOD_RETURN(jm_listContains, jc_arrayListClass, "contains", "(Ljava/lang/Object;)Z", NULL);
|
||||
|
||||
if (!inputMethodController) return NULL;
|
||||
jobject returnValue = 0;
|
||||
|
||||
@ -309,7 +309,8 @@ JNF_COCOA_ENTER(env);
|
||||
if (selectableArray == nil) return NULL;
|
||||
|
||||
// Create an ArrayList to return back to the caller.
|
||||
returnValue = JNFNewObject(env, jm_arrayListCons);
|
||||
returnValue = (*env)->NewObject(env, jc_arrayListClass, jm_arrayListCons);
|
||||
CHECK_EXCEPTION_NULL_RETURN(returnValue, NULL);
|
||||
|
||||
for(NSString *locale in selectableArray) {
|
||||
jobject localeObj = CreateLocaleObjectFromNSString(env, locale);
|
||||
@ -317,9 +318,11 @@ JNF_COCOA_ENTER(env);
|
||||
break;
|
||||
}
|
||||
|
||||
if (JNFCallBooleanMethod(env, returnValue, jm_listContains, localeObj) == JNI_FALSE) {
|
||||
JNFCallBooleanMethod(env, returnValue, jm_listAdd, localeObj);
|
||||
if ((*env)->CallBooleanMethod(env, returnValue, jm_listContains, localeObj) == JNI_FALSE) {
|
||||
if ((*env)->ExceptionOccurred(env)) (*env)->ExceptionClear(env);
|
||||
(*env)->CallBooleanMethod(env, returnValue, jm_listAdd, localeObj);
|
||||
}
|
||||
if ((*env)->ExceptionOccurred(env)) (*env)->ExceptionClear(env);
|
||||
|
||||
(*env)->DeleteLocalRef(env, localeObj);
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#import "AWTEvent.h"
|
||||
#import "AWTWindow.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#import "java_awt_Event.h"
|
||||
#import "java_awt_event_KeyEvent.h"
|
||||
@ -92,23 +93,24 @@
|
||||
}
|
||||
|
||||
if (fIsCheckbox) {
|
||||
static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
|
||||
static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
|
||||
DECLARE_CLASS(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem");
|
||||
DECLARE_METHOD(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V");
|
||||
|
||||
// Send the opposite of what's currently checked -- the action
|
||||
// indicates what state we're going to.
|
||||
NSInteger state = [sender state];
|
||||
jboolean newState = (state == NSOnState ? JNI_FALSE : JNI_TRUE);
|
||||
JNFCallVoidMethod(env, fPeer, jm_ckHandleAction, newState);
|
||||
(*env)->CallVoidMethod(env, fPeer, jm_ckHandleAction, newState);
|
||||
} else {
|
||||
static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
|
||||
static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
|
||||
DECLARE_CLASS(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem");
|
||||
DECLARE_METHOD(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event)
|
||||
|
||||
NSUInteger modifiers = [currEvent modifierFlags];
|
||||
jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO);
|
||||
|
||||
JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
|
||||
(*env)->CallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event)
|
||||
}
|
||||
CHECK_EXCEPTION();
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
|
||||
@ -36,13 +36,29 @@
|
||||
#import "PrintModel.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "GeomUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_Paper, "java/awt/print/Paper");
|
||||
static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
static JNF_CLASS_CACHE(sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob");
|
||||
static JNF_CLASS_CACHE(sjc_CPrinterDialog, "sun/lwawt/macosx/CPrinterDialog");
|
||||
static JNF_MEMBER_CACHE(sjm_getNSPrintInfo, sjc_CPrinterJob, "getNSPrintInfo", "()J");
|
||||
static JNF_MEMBER_CACHE(sjm_printerJob, sjc_CPrinterDialog, "fPrinterJob", "Lsun/lwawt/macosx/CPrinterJob;");
|
||||
static jclass sjc_Paper = NULL;
|
||||
static jclass sjc_PageFormat = NULL;
|
||||
static jclass sjc_CPrinterJob = NULL;
|
||||
static jclass sjc_CPrinterDialog = NULL;
|
||||
static jmethodID sjm_getNSPrintInfo = NULL;
|
||||
static jmethodID sjm_printerJob = NULL;
|
||||
|
||||
#define GET_PAPER_CLASS() GET_CLASS(sjc_Paper, "java/awt/print/Paper");
|
||||
#define GET_PAGEFORMAT_CLASS() GET_CLASS(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
#define GET_CPRINTERDIALOG_CLASS() GET_CLASS(sjc_CPrinterDialog, "sun/lwawt/macosx/CPrinterDialog");
|
||||
#define GET_CPRINTERDIALOG_CLASS_RETURN(ret) GET_CLASS_RETURN(sjc_CPrinterDialog, "sun/lwawt/macosx/CPrinterDialog", ret);
|
||||
#define GET_CPRINTERJOB_CLASS() GET_CLASS(sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob");
|
||||
#define GET_CPRINTERJOB_CLASS_RETURN(ret) GET_CLASS_RETURN(sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob", ret);
|
||||
|
||||
#define GET_NSPRINTINFO_METHOD_RETURN(ret) \
|
||||
GET_CPRINTERJOB_CLASS_RETURN(ret); \
|
||||
GET_METHOD_RETURN(sjm_getNSPrintInfo, sjc_CPrinterJob, "getNSPrintInfo", "()J", ret);
|
||||
|
||||
#define GET_CPRINTERDIALOG_METHOD_RETURN(ret) \
|
||||
GET_CPRINTERDIALOG_CLASS_RETURN(ret); \
|
||||
GET_METHOD_RETURN(sjm_printerJob, sjc_CPrinterDialog, "fPrinterJob", "Lsun/lwawt/macosx/CPrinterJob;", ret);
|
||||
|
||||
static NSPrintInfo* createDefaultNSPrintInfo();
|
||||
|
||||
@ -140,8 +156,10 @@ static void makeBestFit(NSPrintInfo* src)
|
||||
|
||||
static void nsPrintInfoToJavaPaper(JNIEnv* env, NSPrintInfo* src, jobject dst)
|
||||
{
|
||||
static JNF_MEMBER_CACHE(jm_setSize, sjc_Paper, "setSize", "(DD)V");
|
||||
static JNF_MEMBER_CACHE(jm_setImageableArea, sjc_Paper, "setImageableArea", "(DDDD)V");
|
||||
GET_PAGEFORMAT_CLASS();
|
||||
GET_PAPER_CLASS();
|
||||
DECLARE_METHOD(jm_setSize, sjc_Paper, "setSize", "(DD)V");
|
||||
DECLARE_METHOD(jm_setImageableArea, sjc_Paper, "setImageableArea", "(DDDD)V");
|
||||
|
||||
jdouble jPaperW, jPaperH;
|
||||
|
||||
@ -167,7 +185,8 @@ static void nsPrintInfoToJavaPaper(JNIEnv* env, NSPrintInfo* src, jobject dst)
|
||||
break;
|
||||
}
|
||||
|
||||
JNFCallVoidMethod(env, dst, jm_setSize, jPaperW, jPaperH); // AWT_THREADING Safe (known object - always actual Paper)
|
||||
(*env)->CallVoidMethod(env, dst, jm_setSize, jPaperW, jPaperH); // AWT_THREADING Safe (known object - always actual Paper)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// Set the imageable area from the margins
|
||||
CGFloat leftM = [src leftMargin];
|
||||
@ -180,35 +199,44 @@ static void nsPrintInfoToJavaPaper(JNIEnv* env, NSPrintInfo* src, jobject dst)
|
||||
jdouble jImageW = jPaperW - (leftM + rightM);
|
||||
jdouble jImageH = jPaperH - (topM + bottomM);
|
||||
|
||||
JNFCallVoidMethod(env, dst, jm_setImageableArea, jImageX, jImageY, jImageW, jImageH); // AWT_THREADING Safe (known object - always actual Paper)
|
||||
(*env)->CallVoidMethod(env, dst, jm_setImageableArea, jImageX, jImageY, jImageW, jImageH); // AWT_THREADING Safe (known object - always actual Paper)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
static void javaPaperToNSPrintInfo(JNIEnv* env, jobject src, NSPrintInfo* dst)
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_getWidth, sjc_Paper, "getWidth", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_getHeight, sjc_Paper, "getHeight", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_getImageableX, sjc_Paper, "getImageableX", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_getImageableY, sjc_Paper, "getImageableY", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_getImageableW, sjc_Paper, "getImageableWidth", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_getImageableH, sjc_Paper, "getImageableHeight", "()D");
|
||||
GET_PAGEFORMAT_CLASS();
|
||||
GET_PAPER_CLASS();
|
||||
DECLARE_METHOD(jm_getWidth, sjc_Paper, "getWidth", "()D");
|
||||
DECLARE_METHOD(jm_getHeight, sjc_Paper, "getHeight", "()D");
|
||||
DECLARE_METHOD(jm_getImageableX, sjc_Paper, "getImageableX", "()D");
|
||||
DECLARE_METHOD(jm_getImageableY, sjc_Paper, "getImageableY", "()D");
|
||||
DECLARE_METHOD(jm_getImageableW, sjc_Paper, "getImageableWidth", "()D");
|
||||
DECLARE_METHOD(jm_getImageableH, sjc_Paper, "getImageableHeight", "()D");
|
||||
|
||||
// java Paper is always Portrait oriented. Set NSPrintInfo with this
|
||||
// rectangle, and it's orientation may change. If necessary, be sure to call
|
||||
// -[NSPrintInfo setOrientation] after this call, which will then
|
||||
// adjust the -[NSPrintInfo paperSize] as well.
|
||||
|
||||
jdouble jPhysicalWidth = JNFCallDoubleMethod(env, src, jm_getWidth); // AWT_THREADING Safe (!appKit)
|
||||
jdouble jPhysicalHeight = JNFCallDoubleMethod(env, src, jm_getHeight); // AWT_THREADING Safe (!appKit)
|
||||
jdouble jPhysicalWidth = (*env)->CallDoubleMethod(env, src, jm_getWidth); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
jdouble jPhysicalHeight = (*env)->CallDoubleMethod(env, src, jm_getHeight); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
[dst setPaperSize:NSMakeSize(jPhysicalWidth, jPhysicalHeight)];
|
||||
|
||||
// Set the margins from the imageable area
|
||||
jdouble jImageX = JNFCallDoubleMethod(env, src, jm_getImageableX); // AWT_THREADING Safe (!appKit)
|
||||
jdouble jImageY = JNFCallDoubleMethod(env, src, jm_getImageableY); // AWT_THREADING Safe (!appKit)
|
||||
jdouble jImageW = JNFCallDoubleMethod(env, src, jm_getImageableW); // AWT_THREADING Safe (!appKit)
|
||||
jdouble jImageH = JNFCallDoubleMethod(env, src, jm_getImageableH); // AWT_THREADING Safe (!appKit)
|
||||
jdouble jImageX = (*env)->CallDoubleMethod(env, src, jm_getImageableX); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
jdouble jImageY = (*env)->CallDoubleMethod(env, src, jm_getImageableY); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
jdouble jImageW = (*env)->CallDoubleMethod(env, src, jm_getImageableW); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
jdouble jImageH = (*env)->CallDoubleMethod(env, src, jm_getImageableH); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
[dst setLeftMargin:(CGFloat)jImageX];
|
||||
[dst setTopMargin:(CGFloat)jImageY];
|
||||
@ -220,9 +248,12 @@ static void nsPrintInfoToJavaPageFormat(JNIEnv* env, NSPrintInfo* src, jobject d
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_setOrientation, sjc_PageFormat, "setOrientation", "(I)V");
|
||||
static JNF_MEMBER_CACHE(jm_setPaper, sjc_PageFormat, "setPaper", "(Ljava/awt/print/Paper;)V");
|
||||
static JNF_CTOR_CACHE(jm_Paper_ctor, sjc_Paper, "()V");
|
||||
GET_CPRINTERJOB_CLASS();
|
||||
GET_PAGEFORMAT_CLASS();
|
||||
GET_PAPER_CLASS();
|
||||
DECLARE_METHOD(jm_setOrientation, sjc_PageFormat, "setOrientation", "(I)V");
|
||||
DECLARE_METHOD(jm_setPaper, sjc_PageFormat, "setPaper", "(Ljava/awt/print/Paper;)V");
|
||||
DECLARE_METHOD(jm_Paper_ctor, sjc_Paper, "<init>", "()V");
|
||||
|
||||
jint jOrientation;
|
||||
switch ([src orientation]) {
|
||||
@ -246,15 +277,21 @@ static void nsPrintInfoToJavaPageFormat(JNIEnv* env, NSPrintInfo* src, jobject d
|
||||
break;
|
||||
}
|
||||
|
||||
JNFCallVoidMethod(env, dst, jm_setOrientation, jOrientation); // AWT_THREADING Safe (!appKit)
|
||||
(*env)->CallVoidMethod(env, dst, jm_setOrientation, jOrientation); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// Create a new Paper
|
||||
jobject paper = JNFNewObject(env, jm_Paper_ctor); // AWT_THREADING Safe (known object)
|
||||
jobject paper = (*env)->NewObject(env, sjc_Paper, jm_Paper_ctor); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
if (paper == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPrintInfoToJavaPaper(env, src, paper);
|
||||
|
||||
// Set the Paper in the PageFormat
|
||||
JNFCallVoidMethod(env, dst, jm_setPaper, paper); // AWT_THREADING Safe (!appKit)
|
||||
(*env)->CallVoidMethod(env, dst, jm_setPaper, paper); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
(*env)->DeleteLocalRef(env, paper);
|
||||
}
|
||||
@ -263,9 +300,12 @@ static void javaPageFormatToNSPrintInfo(JNIEnv* env, jobject srcPrintJob, jobjec
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_getOrientation, sjc_PageFormat, "getOrientation", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_getPaper, sjc_PageFormat, "getPaper", "()Ljava/awt/print/Paper;");
|
||||
static JNF_MEMBER_CACHE(jm_getPrinterName, sjc_CPrinterJob, "getPrinterName", "()Ljava/lang/String;");
|
||||
GET_CPRINTERJOB_CLASS();
|
||||
GET_PAGEFORMAT_CLASS();
|
||||
GET_PAPER_CLASS();
|
||||
DECLARE_METHOD(jm_getOrientation, sjc_PageFormat, "getOrientation", "()I");
|
||||
DECLARE_METHOD(jm_getPaper, sjc_PageFormat, "getPaper", "()Ljava/awt/print/Paper;");
|
||||
DECLARE_METHOD(jm_getPrinterName, sjc_CPrinterJob, "getPrinterName", "()Ljava/lang/String;");
|
||||
|
||||
// When setting page information (orientation, size) in NSPrintInfo, set the
|
||||
// rectangle first. This is because setting the orientation will change the
|
||||
@ -274,11 +314,12 @@ static void javaPageFormatToNSPrintInfo(JNIEnv* env, jobject srcPrintJob, jobjec
|
||||
// Set up the paper. This will force Portrait since java Paper is
|
||||
// not oriented. Then setting the NSPrintInfo orientation below
|
||||
// will flip NSPrintInfo's info as necessary.
|
||||
jobject paper = JNFCallObjectMethod(env, srcPageFormat, jm_getPaper); // AWT_THREADING Safe (!appKit)
|
||||
jobject paper = (*env)->CallObjectMethod(env, srcPageFormat, jm_getPaper); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
javaPaperToNSPrintInfo(env, paper, dstPrintInfo);
|
||||
(*env)->DeleteLocalRef(env, paper);
|
||||
|
||||
switch (JNFCallIntMethod(env, srcPageFormat, jm_getOrientation)) { // AWT_THREADING Safe (!appKit)
|
||||
switch ((*env)->CallIntMethod(env, srcPageFormat, jm_getOrientation)) { // AWT_THREADING Safe (!appKit)
|
||||
case java_awt_print_PageFormat_PORTRAIT:
|
||||
[dstPrintInfo setOrientation:NS_PORTRAIT];
|
||||
break;
|
||||
@ -296,11 +337,13 @@ static void javaPageFormatToNSPrintInfo(JNIEnv* env, jobject srcPrintJob, jobjec
|
||||
[dstPrintInfo setOrientation:NS_PORTRAIT];
|
||||
break;
|
||||
}
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// <rdar://problem/4022422> NSPrinterInfo is not correctly set to the selected printer
|
||||
// from the Java side of CPrinterJob. Has always assumed the default printer was the one we wanted.
|
||||
if (srcPrintJob == NULL) return;
|
||||
jobject printerNameObj = JNFCallObjectMethod(env, srcPrintJob, jm_getPrinterName);
|
||||
jobject printerNameObj = (*env)->CallObjectMethod(env, srcPrintJob, jm_getPrinterName);
|
||||
CHECK_EXCEPTION();
|
||||
if (printerNameObj == NULL) return;
|
||||
NSString *printerName = JNFJavaToNSString(env, printerNameObj);
|
||||
if (printerName == nil) return;
|
||||
@ -311,40 +354,47 @@ static void javaPageFormatToNSPrintInfo(JNIEnv* env, jobject srcPrintJob, jobjec
|
||||
|
||||
static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject dstPrinterJob, jobject dstPageable)
|
||||
{
|
||||
static JNF_MEMBER_CACHE(jm_setService, sjc_CPrinterJob, "setPrinterServiceFromNative", "(Ljava/lang/String;)V");
|
||||
static JNF_MEMBER_CACHE(jm_setCopiesAttribute, sjc_CPrinterJob, "setCopiesAttribute", "(I)V");
|
||||
static JNF_MEMBER_CACHE(jm_setCollated, sjc_CPrinterJob, "setCollated", "(Z)V");
|
||||
static JNF_MEMBER_CACHE(jm_setPageRangeAttribute, sjc_CPrinterJob, "setPageRangeAttribute", "(IIZ)V");
|
||||
static JNF_MEMBER_CACHE(jm_setPrintToFile, sjc_CPrinterJob, "setPrintToFile", "(Z)V");
|
||||
static JNF_MEMBER_CACHE(jm_setDestinationFile, sjc_CPrinterJob, "setDestinationFile", "(Ljava/lang/String;)V");
|
||||
GET_CPRINTERJOB_CLASS();
|
||||
DECLARE_METHOD(jm_setService, sjc_CPrinterJob, "setPrinterServiceFromNative", "(Ljava/lang/String;)V");
|
||||
DECLARE_METHOD(jm_setCopiesAttribute, sjc_CPrinterJob, "setCopiesAttribute", "(I)V");
|
||||
DECLARE_METHOD(jm_setCollated, sjc_CPrinterJob, "setCollated", "(Z)V");
|
||||
DECLARE_METHOD(jm_setPageRangeAttribute, sjc_CPrinterJob, "setPageRangeAttribute", "(IIZ)V");
|
||||
DECLARE_METHOD(jm_setPrintToFile, sjc_CPrinterJob, "setPrintToFile", "(Z)V");
|
||||
DECLARE_METHOD(jm_setDestinationFile, sjc_CPrinterJob, "setDestinationFile", "(Ljava/lang/String;)V");
|
||||
|
||||
// get the selected printer's name, and set the appropriate PrintService on the Java side
|
||||
NSString *name = [[src printer] name];
|
||||
jstring printerName = JNFNSToJavaString(env, name);
|
||||
JNFCallVoidMethod(env, dstPrinterJob, jm_setService, printerName);
|
||||
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setService, printerName);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
NSMutableDictionary* printingDictionary = [src dictionary];
|
||||
|
||||
if (src.jobDisposition == NSPrintSaveJob) {
|
||||
JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, true);
|
||||
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, true);
|
||||
CHECK_EXCEPTION();
|
||||
NSURL *url = [printingDictionary objectForKey:NSPrintJobSavingURL];
|
||||
NSString *nsStr = [url absoluteString];
|
||||
jstring str = JNFNSToJavaString(env, nsStr);
|
||||
JNFCallVoidMethod(env, dstPrinterJob, jm_setDestinationFile, str);
|
||||
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setDestinationFile, str);
|
||||
CHECK_EXCEPTION();
|
||||
} else {
|
||||
JNFCallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, false);
|
||||
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setPrintToFile, false);
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
NSNumber* nsCopies = [printingDictionary objectForKey:NSPrintCopies];
|
||||
if ([nsCopies respondsToSelector:@selector(integerValue)])
|
||||
{
|
||||
JNFCallVoidMethod(env, dstPrinterJob, jm_setCopiesAttribute, [nsCopies integerValue]); // AWT_THREADING Safe (known object)
|
||||
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setCopiesAttribute, [nsCopies integerValue]); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
NSNumber* nsCollated = [printingDictionary objectForKey:NSPrintMustCollate];
|
||||
if ([nsCollated respondsToSelector:@selector(boolValue)])
|
||||
{
|
||||
JNFCallVoidMethod(env, dstPrinterJob, jm_setCollated, [nsCollated boolValue] ? JNI_TRUE : JNI_FALSE); // AWT_THREADING Safe (known object)
|
||||
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setCollated, [nsCollated boolValue] ? JNI_TRUE : JNI_FALSE); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
NSNumber* nsPrintAllPages = [printingDictionary objectForKey:NSPrintAllPages];
|
||||
@ -367,9 +417,9 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d
|
||||
}
|
||||
isRangeSet = true;
|
||||
}
|
||||
JNFCallVoidMethod(env, dstPrinterJob, jm_setPageRangeAttribute,
|
||||
jFirstPage, jLastPage, isRangeSet);
|
||||
// AWT_THREADING Safe (known object)
|
||||
(*env)->CallVoidMethod(env, dstPrinterJob, jm_setPageRangeAttribute,
|
||||
jFirstPage, jLastPage, isRangeSet); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
}
|
||||
}
|
||||
@ -378,29 +428,33 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_CLASS_CACHE(jc_Pageable, "java/awt/print/Pageable");
|
||||
static JNF_MEMBER_CACHE(jm_getCopies, sjc_CPrinterJob, "getCopiesInt", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z");
|
||||
static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_getMinPage, sjc_CPrinterJob, "getMinPageAttrib", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
|
||||
static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
|
||||
static JNF_MEMBER_CACHE(jm_getDestinationFile, sjc_CPrinterJob,
|
||||
"getDestinationFile", "()Ljava/lang/String;");
|
||||
DECLARE_CLASS(jc_Pageable, "java/awt/print/Pageable");
|
||||
DECLARE_METHOD(jm_getCopies, sjc_CPrinterJob, "getCopiesInt", "()I");
|
||||
DECLARE_METHOD(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z");
|
||||
DECLARE_METHOD(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I");
|
||||
DECLARE_METHOD(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I");
|
||||
DECLARE_METHOD(jm_getMinPage, sjc_CPrinterJob, "getMinPageAttrib", "()I");
|
||||
DECLARE_METHOD(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I");
|
||||
DECLARE_METHOD(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
|
||||
DECLARE_METHOD(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
|
||||
DECLARE_METHOD(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
|
||||
DECLARE_METHOD(jm_getDestinationFile, sjc_CPrinterJob, "getDestinationFile", "()Ljava/lang/String;");
|
||||
|
||||
NSMutableDictionary* printingDictionary = [dst dictionary];
|
||||
|
||||
jint copies = JNFCallIntMethod(env, srcPrinterJob, jm_getCopies); // AWT_THREADING Safe (known object)
|
||||
jint copies = (*env)->CallIntMethod(env, srcPrinterJob, jm_getCopies); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
[printingDictionary setObject:[NSNumber numberWithInteger:copies] forKey:NSPrintCopies];
|
||||
|
||||
jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object)
|
||||
jboolean collated = (*env)->CallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
[printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate];
|
||||
jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
|
||||
jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage);
|
||||
jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage);
|
||||
jint selectID = (*env)->CallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
|
||||
CHECK_EXCEPTION();
|
||||
jint fromPage = (*env)->CallIntMethod(env, srcPrinterJob, jm_getFromPage);
|
||||
CHECK_EXCEPTION();
|
||||
jint toPage = (*env)->CallIntMethod(env, srcPrinterJob, jm_getToPage);
|
||||
CHECK_EXCEPTION();
|
||||
if (selectID ==0) {
|
||||
[printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
|
||||
} else if (selectID == 2) {
|
||||
@ -409,8 +463,10 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
|
||||
[printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
|
||||
[printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly];
|
||||
} else {
|
||||
jint minPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMinPage);
|
||||
jint maxPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMaxPage);
|
||||
jint minPage = (*env)->CallIntMethod(env, srcPrinterJob, jm_getMinPage);
|
||||
CHECK_EXCEPTION();
|
||||
jint maxPage = (*env)->CallIntMethod(env, srcPrinterJob, jm_getMaxPage);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// for PD_SELECTION or PD_NOSELECTION, check from/to page
|
||||
// to determine which radio button to select
|
||||
@ -425,12 +481,14 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
|
||||
[printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
|
||||
[printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
|
||||
|
||||
jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat);
|
||||
jobject page = (*env)->CallObjectMethod(env, srcPrinterJob, jm_getPageFormat);
|
||||
CHECK_EXCEPTION();
|
||||
if (page != NULL) {
|
||||
javaPageFormatToNSPrintInfo(env, NULL, page, dst);
|
||||
}
|
||||
|
||||
jstring dest = JNFCallObjectMethod(env, srcPrinterJob, jm_getDestinationFile);
|
||||
jstring dest = (*env)->CallObjectMethod(env, srcPrinterJob, jm_getDestinationFile);
|
||||
CHECK_EXCEPTION();
|
||||
if (dest != NULL) {
|
||||
[dst setJobDisposition:NSPrintSaveJob];
|
||||
NSString *nsDestStr = JNFJavaToNSString(env, dest);
|
||||
@ -484,6 +542,7 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPrinterJob_validatePaper
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
|
||||
|
||||
NSPrintInfo* printInfo = createDefaultNSPrintInfo(env, NULL);
|
||||
javaPaperToNSPrintInfo(env, origpaper, printInfo);
|
||||
makeBestFit(printInfo);
|
||||
@ -542,26 +601,32 @@ JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CPrinterJob_printLoop
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;");
|
||||
static JNF_MEMBER_CACHE(jm_getPageFormatArea, sjc_CPrinterJob, "getPageFormatArea", "(Ljava/awt/print/PageFormat;)Ljava/awt/geom/Rectangle2D;");
|
||||
static JNF_MEMBER_CACHE(jm_getPrinterName, sjc_CPrinterJob, "getPrinterName", "()Ljava/lang/String;");
|
||||
static JNF_MEMBER_CACHE(jm_getPageable, sjc_CPrinterJob, "getPageable", "()Ljava/awt/print/Pageable;");
|
||||
static JNF_MEMBER_CACHE(jm_getPrinterTray, sjc_CPrinterJob, "getPrinterTray", "()Ljava/lang/String;");
|
||||
GET_CPRINTERJOB_CLASS_RETURN(NO);
|
||||
DECLARE_METHOD_RETURN(jm_getPageFormat, sjc_CPrinterJob, "getPageFormat", "(I)Ljava/awt/print/PageFormat;", NO);
|
||||
DECLARE_METHOD_RETURN(jm_getPageFormatArea, sjc_CPrinterJob, "getPageFormatArea", "(Ljava/awt/print/PageFormat;)Ljava/awt/geom/Rectangle2D;", NO);
|
||||
DECLARE_METHOD_RETURN(jm_getPrinterName, sjc_CPrinterJob, "getPrinterName", "()Ljava/lang/String;", NO);
|
||||
DECLARE_METHOD_RETURN(jm_getPageable, sjc_CPrinterJob, "getPageable", "()Ljava/awt/print/Pageable;", NO);
|
||||
DECLARE_METHOD_RETURN(jm_getPrinterTray, sjc_CPrinterJob, "getPrinterTray", "()Ljava/lang/String;", NO);
|
||||
|
||||
jboolean retVal = JNI_FALSE;
|
||||
|
||||
JNF_COCOA_ENTER(env);
|
||||
// Get the first page's PageFormat for setting things up (This introduces
|
||||
// and is a facet of the same problem in Radar 2818593/2708932).
|
||||
jobject page = JNFCallObjectMethod(env, jthis, jm_getPageFormat, 0); // AWT_THREADING Safe (!appKit)
|
||||
jobject page = (*env)->CallObjectMethod(env, jthis, jm_getPageFormat, 0); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
if (page != NULL) {
|
||||
jobject pageFormatArea = JNFCallObjectMethod(env, jthis, jm_getPageFormatArea, page); // AWT_THREADING Safe (!appKit)
|
||||
jobject pageFormatArea = (*env)->CallObjectMethod(env, jthis, jm_getPageFormatArea, page); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
PrinterView* printerView = [[PrinterView alloc] initWithFrame:JavaToNSRect(env, pageFormatArea) withEnv:env withPrinterJob:jthis];
|
||||
[printerView setFirstPage:firstPage lastPage:lastPage];
|
||||
|
||||
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr(JNFCallLongMethod(env, jthis, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
|
||||
jobject printerTrayObj = JNFCallObjectMethod(env, jthis, jm_getPrinterTray);
|
||||
GET_NSPRINTINFO_METHOD_RETURN(NO)
|
||||
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr((*env)->CallLongMethod(env, jthis, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
jobject printerTrayObj = (*env)->CallObjectMethod(env, jthis, jm_getPrinterTray);
|
||||
CHECK_EXCEPTION();
|
||||
if (printerTrayObj != NULL) {
|
||||
NSString *printerTray = JNFJavaToNSString(env, printerTrayObj);
|
||||
if (printerTray != nil) {
|
||||
@ -574,7 +639,8 @@ JNF_COCOA_ENTER(env);
|
||||
|
||||
// <rdar://problem/4093799> NSPrinterInfo is not correctly set to the selected printer
|
||||
// from the Java side of CPrinterJob. Had always assumed the default printer was the one we wanted.
|
||||
jobject printerNameObj = JNFCallObjectMethod(env, jthis, jm_getPrinterName);
|
||||
jobject printerNameObj = (*env)->CallObjectMethod(env, jthis, jm_getPrinterName);
|
||||
CHECK_EXCEPTION();
|
||||
if (printerNameObj != NULL) {
|
||||
NSString *printerName = JNFJavaToNSString(env, printerNameObj);
|
||||
if (printerName != nil) {
|
||||
@ -584,7 +650,7 @@ JNF_COCOA_ENTER(env);
|
||||
}
|
||||
|
||||
// <rdar://problem/4367998> JTable.print attributes are ignored
|
||||
jobject pageable = JNFCallObjectMethod(env, jthis, jm_getPageable); // AWT_THREADING Safe (!appKit)
|
||||
jobject pageable = (*env)->CallObjectMethod(env, jthis, jm_getPageable); // AWT_THREADING Safe (!appKit)
|
||||
javaPrinterJobToNSPrintInfo(env, jthis, pageable, printInfo);
|
||||
|
||||
PrintModel* printModel = [[PrintModel alloc] initWithPrintInfo:printInfo];
|
||||
@ -620,15 +686,20 @@ JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CPrinterPageDialog_showDialog
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
|
||||
static JNF_CLASS_CACHE(jc_CPrinterPageDialog, "sun/lwawt/macosx/CPrinterPageDialog");
|
||||
static JNF_MEMBER_CACHE(jm_page, jc_CPrinterPageDialog, "fPage", "Ljava/awt/print/PageFormat;");
|
||||
DECLARE_CLASS_RETURN(jc_CPrinterPageDialog, "sun/lwawt/macosx/CPrinterPageDialog", NO);
|
||||
DECLARE_FIELD_RETURN(jm_page, jc_CPrinterPageDialog, "fPage", "Ljava/awt/print/PageFormat;", NO);
|
||||
|
||||
jboolean result = JNI_FALSE;
|
||||
JNF_COCOA_ENTER(env);
|
||||
jobject printerJob = JNFGetObjectField(env, jthis, sjm_printerJob);
|
||||
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr(JNFCallLongMethod(env, printerJob, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
|
||||
GET_CPRINTERDIALOG_METHOD_RETURN(NO);
|
||||
GET_NSPRINTINFO_METHOD_RETURN(NO)
|
||||
jobject printerJob = (*env)->GetObjectField(env, jthis, sjm_printerJob);
|
||||
if (printerJob == NULL) return NO;
|
||||
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr((*env)->CallLongMethod(env, printerJob, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
|
||||
if (printInfo == NULL) return result;
|
||||
|
||||
jobject page = JNFGetObjectField(env, jthis, jm_page);
|
||||
jobject page = (*env)->GetObjectField(env, jthis, jm_page);
|
||||
if (page == NULL) return NO;
|
||||
|
||||
// <rdar://problem/4156975> passing NULL, because only a CPrinterJob has a real printer associated with it
|
||||
javaPageFormatToNSPrintInfo(env, NULL, page, printInfo);
|
||||
@ -664,15 +735,19 @@ JNF_COCOA_EXIT(env);
|
||||
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CPrinterJobDialog_showDialog
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
static JNF_CLASS_CACHE(jc_CPrinterJobDialog, "sun/lwawt/macosx/CPrinterJobDialog");
|
||||
static JNF_MEMBER_CACHE(jm_pageable, jc_CPrinterJobDialog, "fPageable", "Ljava/awt/print/Pageable;");
|
||||
DECLARE_CLASS_RETURN(jc_CPrinterJobDialog, "sun/lwawt/macosx/CPrinterJobDialog", NO);
|
||||
DECLARE_FIELD_RETURN(jm_pageable, jc_CPrinterJobDialog, "fPageable", "Ljava/awt/print/Pageable;", NO);
|
||||
|
||||
jboolean result = JNI_FALSE;
|
||||
JNF_COCOA_ENTER(env);
|
||||
jobject printerJob = JNFGetObjectField(env, jthis, sjm_printerJob);
|
||||
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr(JNFCallLongMethod(env, printerJob, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
|
||||
GET_CPRINTERDIALOG_METHOD_RETURN(NO);
|
||||
jobject printerJob = (*env)->GetObjectField(env, jthis, sjm_printerJob);
|
||||
if (printerJob == NULL) return NO;
|
||||
GET_NSPRINTINFO_METHOD_RETURN(NO)
|
||||
NSPrintInfo* printInfo = (NSPrintInfo*)jlong_to_ptr((*env)->CallLongMethod(env, printerJob, sjm_getNSPrintInfo)); // AWT_THREADING Safe (known object)
|
||||
|
||||
jobject pageable = JNFGetObjectField(env, jthis, jm_pageable);
|
||||
jobject pageable = (*env)->GetObjectField(env, jthis, jm_pageable);
|
||||
if (pageable == NULL) return NO;
|
||||
|
||||
javaPrinterJobToNSPrintInfo(env, printerJob, pageable, printInfo);
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
|
||||
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
NSColor **sColors = nil;
|
||||
NSColor **appleColors = nil;
|
||||
@ -46,8 +47,6 @@ JNF_COCOA_ENTER(env);
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemColorsChanged", "()V");
|
||||
|
||||
+ (void)systemColorsDidChange:(NSNotification *)notification {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
@ -57,7 +56,11 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol
|
||||
// Call LWCToolkit with the news. LWCToolkit makes certain to do its duties
|
||||
// from a new thread.
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
JNFCallStaticVoidMethod(env, jm_systemColorsChanged); // AWT_THREADING Safe (event)
|
||||
DECLARE_CLASS(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
DECLARE_STATIC_METHOD(jm_systemColorsChanged, jc_LWCToolkit, "systemColorsChanged", "()V");
|
||||
(*env)->CallStaticVoidMethod(env, jc_LWCToolkit, jm_systemColorsChanged); // AWT_THREADING Safe (event)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#import "CoreTextSupport.h"
|
||||
#import "QuartzSurfaceData.h"
|
||||
#include "AWTStrike.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
static const CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
|
||||
|
||||
@ -322,7 +323,8 @@ static void DrawTextContext
|
||||
|
||||
-----------------------------------*/
|
||||
|
||||
static JNF_CLASS_CACHE(jc_StandardGlyphVector, "sun/font/StandardGlyphVector");
|
||||
static jclass jc_StandardGlyphVector = NULL;
|
||||
#define GET_SGV_CLASS() GET_CLASS(jc_StandardGlyphVector, "sun/font/StandardGlyphVector");
|
||||
|
||||
// Checks the GlyphVector Java object for any transforms that were applied to individual characters. If none are present,
|
||||
// strike the glyphs immediately in Core Graphics. Otherwise, obtain the arrays, and defer to above.
|
||||
@ -330,8 +332,9 @@ static inline void doDrawGlyphsPipe_checkForPerGlyphTransforms
|
||||
(JNIEnv *env, QuartzSDOps *qsdo, const AWTStrike *strike, jobject gVector, BOOL useSubstituion, int *uniChars, CGGlyph *glyphs, CGSize *advances, size_t length)
|
||||
{
|
||||
// if we have no character substitution, and no per-glyph transformations - strike now!
|
||||
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_gti, jc_StandardGlyphVector, "gti", "Lsun/font/StandardGlyphVector$GlyphTransformInfo;");
|
||||
jobject gti = JNFGetObjectField(env, gVector, jm_StandardGlyphVector_gti);
|
||||
GET_SGV_CLASS();
|
||||
DECLARE_FIELD(jm_StandardGlyphVector_gti, jc_StandardGlyphVector, "gti", "Lsun/font/StandardGlyphVector$GlyphTransformInfo;");
|
||||
jobject gti = (*env)->GetObjectField(env, gVector, jm_StandardGlyphVector_gti);
|
||||
if (gti == 0)
|
||||
{
|
||||
if (useSubstituion)
|
||||
@ -347,9 +350,9 @@ static inline void doDrawGlyphsPipe_checkForPerGlyphTransforms
|
||||
return;
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_StandardGlyphVector_GlyphTransformInfo, "sun/font/StandardGlyphVector$GlyphTransformInfo");
|
||||
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_transforms, jc_StandardGlyphVector_GlyphTransformInfo, "transforms", "[D");
|
||||
jdoubleArray g_gtiTransformsArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_transforms); //(*env)->GetObjectField(env, gti, g_gtiTransforms);
|
||||
DECLARE_CLASS(jc_StandardGlyphVector_GlyphTransformInfo, "sun/font/StandardGlyphVector$GlyphTransformInfo");
|
||||
DECLARE_FIELD(jm_StandardGlyphVector_GlyphTransformInfo_transforms, jc_StandardGlyphVector_GlyphTransformInfo, "transforms", "[D");
|
||||
jdoubleArray g_gtiTransformsArray = (*env)->GetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_transforms); //(*env)->GetObjectField(env, gti, g_gtiTransforms);
|
||||
if (g_gtiTransformsArray == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -359,8 +362,8 @@ static inline void doDrawGlyphsPipe_checkForPerGlyphTransforms
|
||||
return;
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_indices, jc_StandardGlyphVector_GlyphTransformInfo, "indices", "[I");
|
||||
jintArray g_gtiTXIndicesArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_indices);
|
||||
DECLARE_FIELD(jm_StandardGlyphVector_GlyphTransformInfo_indices, jc_StandardGlyphVector_GlyphTransformInfo, "indices", "[I");
|
||||
jintArray g_gtiTXIndicesArray = (*env)->GetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_indices);
|
||||
jint *g_gvTXIndicesAsInts = (*env)->GetPrimitiveArrayCritical(env, g_gtiTXIndicesArray, NULL);
|
||||
if (g_gvTXIndicesAsInts == NULL) {
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
|
||||
@ -437,8 +440,9 @@ static inline void doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, glyphsArray, glyphsAsInts, JNI_ABORT);
|
||||
|
||||
// fill the advance buffer
|
||||
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_positions, jc_StandardGlyphVector, "positions", "[F");
|
||||
jfloatArray posArray = JNFGetObjectField(env, gVector, jm_StandardGlyphVector_positions);
|
||||
GET_SGV_CLASS();
|
||||
DECLARE_FIELD(jm_StandardGlyphVector_positions, jc_StandardGlyphVector, "positions", "[F");
|
||||
jfloatArray posArray = (*env)->GetObjectField(env, gVector, jm_StandardGlyphVector_positions);
|
||||
jfloat *positions = NULL;
|
||||
if (posArray != NULL) {
|
||||
// in this case, the positions have already been pre-calculated for us on the Java side
|
||||
@ -497,8 +501,9 @@ static inline void doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers
|
||||
static inline void doDrawGlyphsPipe_getGlyphVectorLengthAndAlloc
|
||||
(JNIEnv *env, QuartzSDOps *qsdo, const AWTStrike *strike, jobject gVector)
|
||||
{
|
||||
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_glyphs, jc_StandardGlyphVector, "glyphs", "[I");
|
||||
jintArray glyphsArray = JNFGetObjectField(env, gVector, jm_StandardGlyphVector_glyphs);
|
||||
GET_SGV_CLASS();
|
||||
DECLARE_FIELD(jm_StandardGlyphVector_glyphs, jc_StandardGlyphVector, "glyphs", "[I");
|
||||
jintArray glyphsArray = (*env)->GetObjectField(env, gVector, jm_StandardGlyphVector_glyphs);
|
||||
jsize length = (*env)->GetArrayLength(env, glyphsArray);
|
||||
|
||||
if (length == 0)
|
||||
|
||||
@ -146,9 +146,9 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
deltaY = [event scrollingDeltaY] * 0.1;
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
|
||||
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
|
||||
DECLARE_CLASS(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
|
||||
DECLARE_METHOD(jctor_NSEvent, jc_NSEvent, "<init>", "(IIIIIIIIDDI)V");
|
||||
jobject jEvent = (*env)->NewObject(env, jc_NSEvent, jctor_NSEvent,
|
||||
[event type],
|
||||
[event modifierFlags],
|
||||
clickCount,
|
||||
@ -160,9 +160,10 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
[AWTToolkit scrollStateWithEvent: event]);
|
||||
CHECK_NULL(jEvent);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon");
|
||||
static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
|
||||
JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent);
|
||||
DECLARE_CLASS(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon");
|
||||
DECLARE_METHOD(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
|
||||
(*env)->CallVoidMethod(env, peer, jm_handleMouseEvent, jEvent);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jEvent);
|
||||
}
|
||||
|
||||
@ -268,9 +269,10 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
if (([event modifierFlags] & NSControlKeyMask) == 0) {
|
||||
//find CTrayIcon.getPopupMenuModel method and call it to get popup menu ptr.
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon");
|
||||
static JNF_MEMBER_CACHE(jm_getPopupMenuModel, jc_CTrayIcon, "getPopupMenuModel", "()J");
|
||||
jlong res = JNFCallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel);
|
||||
DECLARE_CLASS(jc_CTrayIcon, "sun/lwawt/macosx/CTrayIcon");
|
||||
DECLARE_METHOD(jm_getPopupMenuModel, jc_CTrayIcon, "getPopupMenuModel", "()J");
|
||||
jlong res = (*env)->CallLongMethod(env, trayIcon.peer, jm_getPopupMenuModel);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
if (res != 0) {
|
||||
CPopupMenu *cmenu = jlong_to_ptr(res);
|
||||
|
||||
@ -24,10 +24,9 @@
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "jni.h"
|
||||
#include "JNIUtilities.h"
|
||||
|
||||
jobject CGToJavaRect(JNIEnv *env, CGRect rect);
|
||||
CGRect JavaToCGRect(JNIEnv *env, jobject rect);
|
||||
|
||||
jobject NSToJavaRect(JNIEnv *env, NSRect rect);
|
||||
NSRect JavaToNSRect(JNIEnv *env, jobject rect);
|
||||
|
||||
@ -24,27 +24,13 @@
|
||||
*/
|
||||
|
||||
#import "GeomUtilities.h"
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_Point2D, "java/awt/geom/Point2D");
|
||||
static JNF_MEMBER_CACHE(jm_pt_getX, sjc_Point2D, "getX", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_pt_getY, sjc_Point2D, "getY", "()D");
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_Dimension2D, "java/awt/geom/Dimension2D");
|
||||
static JNF_MEMBER_CACHE(jm_sz_getWidth, sjc_Dimension2D, "getWidth", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_sz_getHeight, sjc_Dimension2D, "getHeight", "()D");
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_Rectangle2D, "java/awt/geom/Rectangle2D");
|
||||
static JNF_MEMBER_CACHE(jm_rect_getX, sjc_Rectangle2D, "getX", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_rect_getY, sjc_Rectangle2D, "getY", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_rect_getWidth, sjc_Rectangle2D, "getWidth", "()D");
|
||||
static JNF_MEMBER_CACHE(jm_rect_getHeight, sjc_Rectangle2D, "getHeight", "()D");
|
||||
|
||||
|
||||
static jobject NewJavaRect(JNIEnv *env, jdouble x, jdouble y, jdouble w, jdouble h) {
|
||||
static JNF_CLASS_CACHE(sjc_Rectangle2DDouble, "java/awt/geom/Rectangle2D$Double");
|
||||
static JNF_CTOR_CACHE(ctor_Rectangle2DDouble, sjc_Rectangle2DDouble, "(DDDD)V");
|
||||
return JNFNewObject(env, ctor_Rectangle2DDouble, x, y, w, h);
|
||||
DECLARE_CLASS_RETURN(sjc_Rectangle2DDouble, "java/awt/geom/Rectangle2D$Double", NULL);
|
||||
DECLARE_METHOD_RETURN(ctor_Rectangle2DDouble, sjc_Rectangle2DDouble, "<init>", "(DDDD)V", NULL);
|
||||
jobject o = (*env)->NewObject(env, sjc_Rectangle2DDouble, ctor_Rectangle2DDouble, x, y, w, h);
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
jobject CGToJavaRect(JNIEnv *env, CGRect rect) {
|
||||
@ -63,46 +49,55 @@ jobject NSToJavaRect(JNIEnv *env, NSRect rect) {
|
||||
rect.size.height);
|
||||
}
|
||||
|
||||
CGRect JavaToCGRect(JNIEnv *env, jobject rect) {
|
||||
return CGRectMake(JNFCallDoubleMethod(env, rect, jm_rect_getX),
|
||||
JNFCallDoubleMethod(env, rect, jm_rect_getY),
|
||||
JNFCallDoubleMethod(env, rect, jm_rect_getWidth),
|
||||
JNFCallDoubleMethod(env, rect, jm_rect_getHeight));
|
||||
}
|
||||
|
||||
NSRect JavaToNSRect(JNIEnv *env, jobject rect) {
|
||||
return NSMakeRect(JNFCallDoubleMethod(env, rect, jm_rect_getX),
|
||||
JNFCallDoubleMethod(env, rect, jm_rect_getY),
|
||||
JNFCallDoubleMethod(env, rect, jm_rect_getWidth),
|
||||
JNFCallDoubleMethod(env, rect, jm_rect_getHeight));
|
||||
DECLARE_CLASS_RETURN(sjc_Rectangle2D, "java/awt/geom/Rectangle2D", NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_rect_getX, sjc_Rectangle2D, "getX", "()D", NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_rect_getY, sjc_Rectangle2D, "getY", "()D", NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_rect_getWidth, sjc_Rectangle2D, "getWidth", "()D", NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_rect_getHeight, sjc_Rectangle2D, "getHeight", "()D", NSZeroRect);
|
||||
return NSMakeRect((*env)->CallDoubleMethod(env, rect, jm_rect_getX),
|
||||
(*env)->CallDoubleMethod(env, rect, jm_rect_getY),
|
||||
(*env)->CallDoubleMethod(env, rect, jm_rect_getWidth),
|
||||
(*env)->CallDoubleMethod(env, rect, jm_rect_getHeight));
|
||||
}
|
||||
|
||||
jobject NSToJavaPoint(JNIEnv *env, NSPoint point) {
|
||||
static JNF_CLASS_CACHE(sjc_Point2DDouble, "java/awt/geom/Point2D$Double");
|
||||
static JNF_CTOR_CACHE(ctor_Point2DDouble, sjc_Point2DDouble, "(DD)V");
|
||||
return JNFNewObject(env, ctor_Point2DDouble, (jdouble)point.x, (jdouble)point.y);
|
||||
DECLARE_CLASS_RETURN(sjc_Point2DDouble, "java/awt/geom/Point2D$Double", NULL);
|
||||
DECLARE_METHOD_RETURN(ctor_Point2DDouble, sjc_Point2DDouble, "<init>", "(DD)V", NULL);
|
||||
jobject o = (*env)->NewObject(env, sjc_Point2DDouble, ctor_Point2DDouble, (jdouble)point.x, (jdouble)point.y);
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
NSPoint JavaToNSPoint(JNIEnv *env, jobject point) {
|
||||
return NSMakePoint(JNFCallDoubleMethod(env, point, jm_pt_getX),
|
||||
JNFCallDoubleMethod(env, point, jm_pt_getY));
|
||||
DECLARE_CLASS_RETURN(sjc_Point2D, "java/awt/geom/Point2D", NSZeroPoint);
|
||||
DECLARE_METHOD_RETURN(jm_pt_getX, sjc_Point2D, "getX", "()D", NSZeroPoint);
|
||||
DECLARE_METHOD_RETURN(jm_pt_getY, sjc_Point2D, "getY", "()D", NSZeroPoint);
|
||||
|
||||
return NSMakePoint((*env)->CallDoubleMethod(env, point, jm_pt_getX),
|
||||
(*env)->CallDoubleMethod(env, point, jm_pt_getY));
|
||||
}
|
||||
|
||||
jobject NSToJavaSize(JNIEnv *env, NSSize size) {
|
||||
static JNF_CLASS_CACHE(sjc_Dimension2DDouble, "java/awt/Dimension"); // No Dimension2D$Double :-(
|
||||
static JNF_CTOR_CACHE(ctor_Dimension2DDouble, sjc_Dimension2DDouble, "(II)V");
|
||||
return JNFNewObject(env, ctor_Dimension2DDouble, (jint)size.width, (jint)size.height);
|
||||
DECLARE_CLASS_RETURN(sjc_Dimension2DDouble, "java/awt/Dimension", NULL); // No Dimension2D$Double :-(
|
||||
DECLARE_METHOD_RETURN(ctor_Dimension2DDouble, sjc_Dimension2DDouble, "<init>", "(II)V", NULL);
|
||||
jobject o = (*env)->NewObject(env, sjc_Dimension2DDouble, ctor_Dimension2DDouble, (jint)size.width, (jint)size.height);
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
NSSize JavaToNSSize(JNIEnv *env, jobject dimension) {
|
||||
return NSMakeSize(JNFCallDoubleMethod(env, dimension, jm_sz_getWidth),
|
||||
JNFCallDoubleMethod(env, dimension, jm_sz_getHeight));
|
||||
DECLARE_CLASS_RETURN(sjc_Dimension2D, "java/awt/geom/Dimension2D", NSZeroSize);
|
||||
DECLARE_METHOD_RETURN(jm_sz_getWidth, sjc_Dimension2D, "getWidth", "()D", NSZeroSize);
|
||||
DECLARE_METHOD_RETURN(jm_sz_getHeight, sjc_Dimension2D, "getHeight", "()D", NSZeroSize);
|
||||
|
||||
return NSMakeSize((*env)->CallDoubleMethod(env, dimension, jm_sz_getWidth),
|
||||
(*env)->CallDoubleMethod(env, dimension, jm_sz_getHeight));
|
||||
}
|
||||
|
||||
static NSScreen *primaryScreen(JNIEnv *env) {
|
||||
NSScreen *primaryScreen = [[NSScreen screens] objectAtIndex:0];
|
||||
if (primaryScreen != nil) return primaryScreen;
|
||||
if (env != NULL) [JNFException raise:env as:kRuntimeException reason:"Failed to convert, no screen."];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,8 @@
|
||||
#import "sun_awt_image_BufImgSurfaceData.h"
|
||||
#import "sun_java2d_OSXOffScreenSurfaceData.h"
|
||||
|
||||
#import "jni_util.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
|
||||
#import "BufImgSurfaceData.h"
|
||||
@ -103,16 +104,9 @@ static jfieldID mapSizeID;
|
||||
static jfieldID CMpDataID;
|
||||
static jfieldID allGrayID;
|
||||
|
||||
|
||||
static JNF_CLASS_CACHE(jc_OSXOffScreenSurfaceData, "sun/java2d/OSXOffScreenSurfaceData");
|
||||
static JNF_MEMBER_CACHE(jm_syncFromCustom, jc_OSXOffScreenSurfaceData, "syncFromCustom", "()V");
|
||||
static JNF_MEMBER_CACHE(jm_syncToCustom, jc_OSXOffScreenSurfaceData, "syncToCustom", "()V");
|
||||
static JNF_CLASS_CACHE(jc_BufferedImage, "java/awt/image/BufferedImage");
|
||||
static JNF_MEMBER_CACHE(jm_SurfaceData, jc_BufferedImage, "sData", "Lsun/java2d/SurfaceData;");
|
||||
static JNF_CLASS_CACHE(jc_IndexColorModel, "java/awt/image/IndexColorModel");
|
||||
static JNF_MEMBER_CACHE(jm_rgb, jc_IndexColorModel, "rgb", "[I");
|
||||
static JNF_MEMBER_CACHE(jm_transparency, jc_IndexColorModel, "transparency", "I");
|
||||
static JNF_MEMBER_CACHE(jm_transparent_index, jc_IndexColorModel, "transparent_index", "I");
|
||||
static jclass jc_OSXOffScreenSurfaceData = NULL;
|
||||
#define GET_OSXOSD_CLASS() \
|
||||
GET_CLASS(jc_OSXOffScreenSurfaceData, "sun/java2d/OSXOffScreenSurfaceData");
|
||||
|
||||
CGColorSpaceRef gColorspaceRGB = NULL;
|
||||
CGColorSpaceRef gColorspaceGray = NULL;
|
||||
@ -192,7 +186,11 @@ IMAGE_SURFACE_INLINE void customPixelsFromJava(JNIEnv *env, ImageSDOps *isdo)
|
||||
PRINT(" customPixelsFromJava")
|
||||
|
||||
SurfaceDataOps *sdo = (SurfaceDataOps*)isdo;
|
||||
JNFCallVoidMethod(env, sdo->sdObject, jm_syncFromCustom); // AWT_THREADING Safe (known object)
|
||||
GET_OSXOSD_CLASS();
|
||||
DECLARE_METHOD(jm_syncFromCustom, jc_OSXOffScreenSurfaceData, "syncFromCustom", "()V");
|
||||
|
||||
(*env)->CallVoidMethod(env, sdo->sdObject, jm_syncFromCustom); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
IMAGE_SURFACE_INLINE void copyBits(jint w, jint h, jint javaPixelsBytesPerRow, Pixel8bit *pixelsSrc, jint dstPixelsBytesPerRow, Pixel8bit *pixelsDst)
|
||||
@ -423,7 +421,10 @@ IMAGE_SURFACE_INLINE void customPixelsToJava(JNIEnv *env, ImageSDOps *isdo)
|
||||
PRINT(" customPixelsToJava")
|
||||
|
||||
SurfaceDataOps *sdo = (SurfaceDataOps*)isdo;
|
||||
JNFCallVoidMethod(env, sdo->sdObject, jm_syncToCustom); // AWT_THREADING Safe (known object)
|
||||
GET_OSXOSD_CLASS();
|
||||
DECLARE_METHOD(jm_syncToCustom, jc_OSXOffScreenSurfaceData, "syncToCustom", "()V");
|
||||
(*env)->CallVoidMethod(env, sdo->sdObject, jm_syncToCustom); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
IMAGE_SURFACE_INLINE void removeAlphaPre_32bit(jint w, jint h, jint javaPixelsBytesPerRow, jint javaPixelBytes, Pixel32bit *pixelsSrc)
|
||||
@ -1622,12 +1623,16 @@ JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_initIDs(JNIEnv *e
|
||||
//fprintf(stderr, "gColorspaceRGB=%p, gColorspaceGray=%p\n", gColorspaceRGB, gColorspaceGray);
|
||||
}
|
||||
|
||||
static jclass jc_BufferedImage = NULL;
|
||||
static jfieldID jm_SurfaceData = NULL;
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_getSurfaceData
|
||||
(JNIEnv *env, jclass bisd, jobject bufImg)
|
||||
{
|
||||
PRINT("getSurfaceData")
|
||||
|
||||
return JNFGetObjectField(env, bufImg, jm_SurfaceData);
|
||||
GET_CLASS_RETURN(jc_BufferedImage, "java/awt/image/BufferedImage", NULL);
|
||||
GET_FIELD_RETURN(jm_SurfaceData, jc_BufferedImage, "sData", "Lsun/java2d/SurfaceData;", NULL);
|
||||
return (*env)->GetObjectField(env, bufImg, jm_SurfaceData);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_setSurfaceData
|
||||
@ -1635,7 +1640,9 @@ JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_setSurfaceData
|
||||
{
|
||||
PRINT("setSurfaceData")
|
||||
|
||||
JNFSetObjectField(env, bufImg, jm_SurfaceData, sData);
|
||||
GET_CLASS(jc_BufferedImage, "java/awt/image/BufferedImage");
|
||||
GET_FIELD(jm_SurfaceData, jc_BufferedImage, "sData", "Lsun/java2d/SurfaceData;");
|
||||
(*env)->SetObjectField(env, bufImg, jm_SurfaceData, sData);
|
||||
}
|
||||
|
||||
static jint ImageSD_Lock(JNIEnv *env, SurfaceDataOps *ops, SurfaceDataRasInfo *pRasInfo, jint lockflags)
|
||||
@ -1863,15 +1870,24 @@ PRINT("Java_sun_java2d_OSXOffScreenSurfaceData_initRaster")
|
||||
isdo->lutDataSize = 0;
|
||||
if ((type == java_awt_image_BufferedImage_TYPE_BYTE_INDEXED) && ((*env)->IsSameObject(env, icm, NULL) == NO))
|
||||
{
|
||||
jarray lutarray = JNFGetObjectField(env, icm, jm_rgb);
|
||||
static jclass jc_IndexColorModel = NULL;
|
||||
if (jc_IndexColorModel == NULL) {
|
||||
jc_IndexColorModel = (*env)->FindClass(env, "java/awt/image/IndexColorModel");
|
||||
}
|
||||
CHECK_NULL(jc_IndexColorModel);
|
||||
DECLARE_FIELD(jm_rgb, jc_IndexColorModel, "rgb", "[I");
|
||||
DECLARE_FIELD(jm_transparency, jc_IndexColorModel, "transparency", "I");
|
||||
DECLARE_FIELD(jm_transparent_index, jc_IndexColorModel, "transparent_index", "I");
|
||||
|
||||
jarray lutarray = (*env)->GetObjectField(env, icm, jm_rgb);
|
||||
isdo->lutDataSize = (*env)->GetArrayLength(env, lutarray);
|
||||
if (isdo->lutDataSize > 0)
|
||||
{
|
||||
jint transparency = JNFGetIntField(env, icm, jm_transparency);
|
||||
jint transparency = (*env)->GetIntField(env, icm, jm_transparency);
|
||||
jint transparent_index = -1;
|
||||
if (transparency == java_awt_Transparency_BITMASK)
|
||||
{
|
||||
transparent_index = JNFGetIntField(env, icm, jm_transparent_index);
|
||||
transparent_index = (*env)->GetIntField(env, icm, jm_transparent_index);
|
||||
}
|
||||
|
||||
Pixel32bit* lutdata = (Pixel32bit*)((*env)->GetPrimitiveArrayCritical(env, lutarray, NULL));
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
|
||||
@implementation JavaAxAction
|
||||
@ -57,20 +58,22 @@
|
||||
|
||||
- (NSString *)getDescription
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleActionDescription, sjc_CAccessibility, "getAccessibleActionDescription", "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)Ljava/lang/String;");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
DECLARE_CLASS_RETURN(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility", nil);
|
||||
DECLARE_METHOD_RETURN(jm_getAccessibleActionDescription, sjc_CAccessibility, "getAccessibleActionDescription",
|
||||
"(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)Ljava/lang/String;", nil);
|
||||
|
||||
jobject fCompLocal = (*env)->NewLocalRef(env, fComponent);
|
||||
if ((*env)->IsSameObject(env, fCompLocal, NULL)) {
|
||||
return nil;
|
||||
}
|
||||
NSString *str = nil;
|
||||
jstring jstr = JNFCallStaticObjectMethod( env,
|
||||
jstring jstr = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
|
||||
jm_getAccessibleActionDescription,
|
||||
fAccessibleAction,
|
||||
fIndex,
|
||||
fCompLocal );
|
||||
CHECK_EXCEPTION();
|
||||
if (jstr != NULL) {
|
||||
str = JNFJavaToNSString(env, jstr); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
(*env)->DeleteLocalRef(env, jstr);
|
||||
@ -81,11 +84,14 @@
|
||||
|
||||
- (void)perform
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction", "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
DECLARE_CLASS(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility");
|
||||
DECLARE_METHOD(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction",
|
||||
"(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V");
|
||||
|
||||
JNFCallStaticVoidMethod(env, jm_doAccessibleAction, fAccessibleAction, fIndex, fComponent); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_doAccessibleAction,
|
||||
fAccessibleAction, fIndex, fComponent); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -30,18 +30,10 @@ extern NSString *const JavaAccessibilityIgnore;
|
||||
extern NSMutableDictionary *sRoles;
|
||||
extern void initializeRoles();
|
||||
|
||||
extern JNFClassInfo sjc_CAccessibility;
|
||||
extern JNFClassInfo sjc_AccessibleComponent;
|
||||
extern JNFClassInfo sjc_AccessibleContext;
|
||||
extern JNFClassInfo sjc_Accessible;
|
||||
extern JNFClassInfo sjc_AccessibleRole;
|
||||
extern JNFClassInfo sjc_Point;
|
||||
extern JNFClassInfo sjc_AccessibleText;
|
||||
|
||||
extern JNFMemberInfo *sjm_getAccessibleRole;
|
||||
extern JNFMemberInfo *sjf_key;
|
||||
extern JNFMemberInfo *sjf_X;
|
||||
extern JNFMemberInfo *sjf_Y;
|
||||
#define GET_CACCESSIBILITY_CLASS() \
|
||||
GET_CLASS(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility");
|
||||
#define GET_CACCESSIBILITY_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility", ret);
|
||||
|
||||
NSSize getAxComponentSize(JNIEnv *env, jobject axComponent, jobject component);
|
||||
NSString *getJavaRole(JNIEnv *env, jobject axComponent, jobject component);
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
@ -43,38 +44,35 @@ NSMutableDictionary *sRoles = nil;
|
||||
void initializeRoles();
|
||||
|
||||
// Unique
|
||||
static JNF_CLASS_CACHE(sjc_AccessibleState, "javax/accessibility/AccessibleState");
|
||||
static jclass sjc_AccessibleState = NULL;
|
||||
#define GET_ACCESSIBLESTATE_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(sjc_AccessibleState, "javax/accessibility/AccessibleState", ret);
|
||||
|
||||
// Duplicate
|
||||
JNF_CLASS_CACHE(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility");
|
||||
JNF_CLASS_CACHE(sjc_AccessibleComponent, "javax/accessibility/AccessibleComponent");
|
||||
JNF_CLASS_CACHE(sjc_AccessibleContext, "javax/accessibility/AccessibleContext");
|
||||
JNF_CLASS_CACHE(sjc_Accessible, "javax/accessibility/Accessible");
|
||||
JNF_CLASS_CACHE(sjc_AccessibleRole, "javax/accessibility/AccessibleRole");
|
||||
JNF_CLASS_CACHE(sjc_Point, "java/awt/Point");
|
||||
JNF_CLASS_CACHE(sjc_AccessibleText, "javax/accessibility/AccessibleText");
|
||||
|
||||
JNF_MEMBER_CACHE(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;");
|
||||
JNF_MEMBER_CACHE(sjf_X, sjc_Point, "x", "I");
|
||||
JNF_MEMBER_CACHE(sjf_Y, sjc_Point, "y", "I");
|
||||
static jclass sjc_CAccessibility = NULL;
|
||||
|
||||
NSSize getAxComponentSize(JNIEnv *env, jobject axComponent, jobject component)
|
||||
{
|
||||
static JNF_CLASS_CACHE(jc_Dimension, "java/awt/Dimension");
|
||||
static JNF_MEMBER_CACHE(jf_width, jc_Dimension, "width", "I");
|
||||
static JNF_MEMBER_CACHE(jf_height, jc_Dimension, "height", "I");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getSize, sjc_CAccessibility, "getSize", "(Ljavax/accessibility/AccessibleComponent;Ljava/awt/Component;)Ljava/awt/Dimension;");
|
||||
DECLARE_CLASS_RETURN(jc_Dimension, "java/awt/Dimension", NSZeroSize);
|
||||
DECLARE_FIELD_RETURN(jf_width, jc_Dimension, "width", "I", NSZeroSize);
|
||||
DECLARE_FIELD_RETURN(jf_height, jc_Dimension, "height", "I", NSZeroSize);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getSize, sjc_CAccessibility, "getSize",
|
||||
"(Ljavax/accessibility/AccessibleComponent;Ljava/awt/Component;)Ljava/awt/Dimension;", NSZeroSize);
|
||||
|
||||
jobject dimension = JNFCallStaticObjectMethod(env, jm_getSize, axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
jobject dimension = (*env)->CallStaticObjectMethod(env, jc_Dimension, jm_getSize, axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
if (dimension == NULL) return NSZeroSize;
|
||||
return NSMakeSize(JNFGetIntField(env, dimension, jf_width), JNFGetIntField(env, dimension, jf_height));
|
||||
return NSMakeSize((*env)->GetIntField(env, dimension, jf_width), (*env)->GetIntField(env, dimension, jf_height));
|
||||
}
|
||||
|
||||
NSString *getJavaRole(JNIEnv *env, jobject axComponent, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleRole, sjc_CAccessibility, "getAccessibleRole", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
jobject axRole = JNFCallStaticObjectMethod(env, sjm_getAccessibleRole, axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleRole, sjc_CAccessibility, "getAccessibleRole",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil);
|
||||
jobject axRole = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleRole,
|
||||
axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
if (axRole == NULL) return @"unknown";
|
||||
|
||||
NSString* str = JNFJavaToNSString(env, axRole);
|
||||
@ -84,50 +82,84 @@ NSString *getJavaRole(JNIEnv *env, jobject axComponent, jobject component)
|
||||
|
||||
jobject getAxSelection(JNIEnv *env, jobject axContext, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleSelection, sjc_CAccessibility, "getAccessibleSelection", "(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleSelection;");
|
||||
return JNFCallStaticObjectMethod(env, jm_getAccessibleSelection, axContext, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleSelection, sjc_CAccessibility, "getAccessibleSelection",
|
||||
"(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleSelection;", nil);
|
||||
jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleSelection,
|
||||
axContext, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
jobject getAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_ax_getAccessibleSelection, sjc_CAccessibility, "ax_getAccessibleSelection", "(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)Ljavax/accessibility/Accessible;");
|
||||
return JNFCallStaticObjectMethod(env, jm_ax_getAccessibleSelection, axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_ax_getAccessibleSelection, sjc_CAccessibility, "ax_getAccessibleSelection",
|
||||
"(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)Ljavax/accessibility/Accessible;", nil);
|
||||
return (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_ax_getAccessibleSelection,
|
||||
axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
void setAxContextSelection(JNIEnv *env, jobject axContext, jint index, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_addAccessibleSelection, sjc_CAccessibility, "addAccessibleSelection", "(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)V");
|
||||
JNFCallStaticVoidMethod(env, jm_addAccessibleSelection, axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_addAccessibleSelection, sjc_CAccessibility, "addAccessibleSelection",
|
||||
"(Ljavax/accessibility/AccessibleContext;ILjava/awt/Component;)V");
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_addAccessibleSelection,
|
||||
axContext, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
jobject getAxContext(JNIEnv *env, jobject accessible, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleContext, sjc_CAccessibility, "getAccessibleContext", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleContext;");
|
||||
return JNFCallStaticObjectMethod(env, jm_getAccessibleContext, accessible, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleContext, sjc_CAccessibility, "getAccessibleContext",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleContext;", nil);
|
||||
jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleContext,
|
||||
accessible, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
BOOL isChildSelected(JNIEnv *env, jobject accessible, jint index, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_isAccessibleChildSelected, sjc_CAccessibility, "isAccessibleChildSelected", "(Ljavax/accessibility/Accessible;ILjava/awt/Component;)Z");
|
||||
return JNFCallStaticBooleanMethod(env, jm_isAccessibleChildSelected, accessible, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(NO);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_isAccessibleChildSelected, sjc_CAccessibility, "isAccessibleChildSelected",
|
||||
"(Ljavax/accessibility/Accessible;ILjava/awt/Component;)Z", NO);
|
||||
jboolean b = (*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_isAccessibleChildSelected,
|
||||
accessible, index, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
return b;
|
||||
}
|
||||
|
||||
jobject getAxStateSet(JNIEnv *env, jobject axContext, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleStateSet, sjc_CAccessibility, "getAccessibleStateSet", "(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleStateSet;");
|
||||
return JNFCallStaticObjectMethod(env, jm_getAccessibleStateSet, axContext, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleStateSet, sjc_CAccessibility, "getAccessibleStateSet",
|
||||
"(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleStateSet;", nil);
|
||||
jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleStateSet,
|
||||
axContext, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
BOOL containsAxState(JNIEnv *env, jobject axContext, jobject axState, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_contains, sjc_CAccessibility, "contains", "(Ljavax/accessibility/AccessibleContext;Ljavax/accessibility/AccessibleState;Ljava/awt/Component;)Z");
|
||||
return JNFCallStaticBooleanMethod(env, jm_contains, axContext, axState, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(NO);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_contains, sjc_CAccessibility, "contains",
|
||||
"(Ljavax/accessibility/AccessibleContext;Ljavax/accessibility/AccessibleState;Ljava/awt/Component;)Z", NO);
|
||||
jboolean b = (*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_contains, axContext, axState, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
return b;
|
||||
}
|
||||
|
||||
BOOL isVertical(JNIEnv *env, jobject axContext, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_VERTICAL, sjc_AccessibleState, "VERTICAL", "Ljavax/accessibility/AccessibleState;");
|
||||
jobject axVertState = JNFGetStaticObjectField(env, jm_VERTICAL);
|
||||
GET_ACCESSIBLESTATE_CLASS_RETURN(NO);
|
||||
DECLARE_STATIC_FIELD_RETURN(jm_VERTICAL, sjc_AccessibleState, "VERTICAL", "Ljavax/accessibility/AccessibleState;", NO);
|
||||
jobject axVertState = (*env)->GetStaticObjectField(env, sjc_AccessibleState, jm_VERTICAL);
|
||||
CHECK_EXCEPTION_NULL_RETURN(axVertState, NO);
|
||||
BOOL vertical = containsAxState(env, axContext, axVertState, component);
|
||||
(*env)->DeleteLocalRef(env, axVertState);
|
||||
return vertical;
|
||||
@ -135,8 +167,10 @@ BOOL isVertical(JNIEnv *env, jobject axContext, jobject component)
|
||||
|
||||
BOOL isHorizontal(JNIEnv *env, jobject axContext, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_HORIZONTAL, sjc_AccessibleState, "HORIZONTAL", "Ljavax/accessibility/AccessibleState;");
|
||||
jobject axHorizState = JNFGetStaticObjectField(env, jm_HORIZONTAL);
|
||||
GET_ACCESSIBLESTATE_CLASS_RETURN(NO);
|
||||
DECLARE_STATIC_FIELD_RETURN(jm_HORIZONTAL, sjc_AccessibleState, "HORIZONTAL", "Ljavax/accessibility/AccessibleState;", NO);
|
||||
jobject axHorizState = (*env)->GetStaticObjectField(env, sjc_AccessibleState, jm_HORIZONTAL);
|
||||
CHECK_EXCEPTION_NULL_RETURN(axHorizState, NO);
|
||||
BOOL horizontal = containsAxState(env, axContext, axHorizState, component);
|
||||
(*env)->DeleteLocalRef(env, axHorizState);
|
||||
return horizontal;
|
||||
@ -144,8 +178,10 @@ BOOL isHorizontal(JNIEnv *env, jobject axContext, jobject component)
|
||||
|
||||
BOOL isShowing(JNIEnv *env, jobject axContext, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_SHOWING, sjc_AccessibleState, "SHOWING", "Ljavax/accessibility/AccessibleState;");
|
||||
jobject axVisibleState = JNFGetStaticObjectField(env, jm_SHOWING);
|
||||
GET_ACCESSIBLESTATE_CLASS_RETURN(NO);
|
||||
DECLARE_STATIC_FIELD_RETURN(jm_SHOWING, sjc_AccessibleState, "SHOWING", "Ljavax/accessibility/AccessibleState;", NO);
|
||||
jobject axVisibleState = (*env)->GetStaticObjectField(env, sjc_AccessibleState, jm_SHOWING);
|
||||
CHECK_EXCEPTION_NULL_RETURN(axVisibleState, NO);
|
||||
BOOL showing = containsAxState(env, axContext, axVisibleState, component);
|
||||
(*env)->DeleteLocalRef(env, axVisibleState);
|
||||
return showing;
|
||||
@ -153,11 +189,13 @@ BOOL isShowing(JNIEnv *env, jobject axContext, jobject component)
|
||||
|
||||
BOOL isSelectable(JNIEnv *env, jobject axContext, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE( jm_SELECTABLE,
|
||||
GET_ACCESSIBLESTATE_CLASS_RETURN(NO);
|
||||
DECLARE_STATIC_FIELD_RETURN(jm_SELECTABLE,
|
||||
sjc_AccessibleState,
|
||||
"SELECTABLE",
|
||||
"Ljavax/accessibility/AccessibleState;" );
|
||||
jobject axSelectableState = JNFGetStaticObjectField(env, jm_SELECTABLE);
|
||||
"Ljavax/accessibility/AccessibleState;", NO );
|
||||
jobject axSelectableState = (*env)->GetStaticObjectField(env, sjc_AccessibleState, jm_SELECTABLE);
|
||||
CHECK_EXCEPTION_NULL_RETURN(axSelectableState, NO);
|
||||
BOOL selectable = containsAxState(env, axContext, axSelectableState, component);
|
||||
(*env)->DeleteLocalRef(env, axSelectableState);
|
||||
return selectable;
|
||||
@ -165,16 +203,27 @@ BOOL isSelectable(JNIEnv *env, jobject axContext, jobject component)
|
||||
|
||||
NSPoint getAxComponentLocationOnScreen(JNIEnv *env, jobject axComponent, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getLocationOnScreen, sjc_CAccessibility, "getLocationOnScreen", "(Ljavax/accessibility/AccessibleComponent;Ljava/awt/Component;)Ljava/awt/Point;");
|
||||
jobject jpoint = JNFCallStaticObjectMethod(env, jm_getLocationOnScreen, axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(NSZeroPoint);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getLocationOnScreen, sjc_CAccessibility, "getLocationOnScreen",
|
||||
"(Ljavax/accessibility/AccessibleComponent;Ljava/awt/Component;)Ljava/awt/Point;", NSZeroPoint);
|
||||
DECLARE_CLASS_RETURN(sjc_Point, "java/awt/Point", NSZeroPoint);
|
||||
DECLARE_FIELD_RETURN(sjf_X, sjc_Point, "x", "I", NSZeroPoint);
|
||||
DECLARE_FIELD_RETURN(sjf_Y, sjc_Point, "y", "I", NSZeroPoint);
|
||||
jobject jpoint = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getLocationOnScreen,
|
||||
axComponent, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
if (jpoint == NULL) return NSZeroPoint;
|
||||
return NSMakePoint(JNFGetIntField(env, jpoint, sjf_X), JNFGetIntField(env, jpoint, sjf_Y));
|
||||
return NSMakePoint((*env)->GetIntField(env, jpoint, sjf_X), (*env)->GetIntField(env, jpoint, sjf_Y));
|
||||
}
|
||||
|
||||
jint getAxTextCharCount(JNIEnv *env, jobject axText, jobject component)
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getCharCount, sjc_CAccessibility, "getCharCount", "(Ljavax/accessibility/AccessibleText;Ljava/awt/Component;)I");
|
||||
return JNFCallStaticIntMethod(env, jm_getCharCount, axText, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(0);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getCharCount, sjc_CAccessibility, "getCharCount",
|
||||
"(Ljavax/accessibility/AccessibleText;Ljava/awt/Component;)I", 0);
|
||||
int i = (*env)->CallStaticIntMethod(env, sjc_CAccessibility, jm_getCharCount, axText, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
return i;
|
||||
}
|
||||
|
||||
// The following JavaAccessibility methods are copied from the corresponding
|
||||
@ -265,7 +314,9 @@ static BOOL JavaAccessibilityIsSupportedAttribute(id element, NSString *attribut
|
||||
JNIEXPORT jstring JNICALL Java_sun_lwawt_macosx_CAccessibility_roleKey
|
||||
(JNIEnv *env, jclass clz, jobject axRole)
|
||||
{
|
||||
return JNFGetObjectField(env, axRole, sjf_key);
|
||||
DECLARE_CLASS_RETURN(sjc_AccessibleRole, "javax/accessibility/AccessibleRole", NULL);
|
||||
DECLARE_FIELD_RETURN(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;", NULL);
|
||||
return (*env)->GetObjectField(env, axRole, sjf_key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "JavaTextAccessibility.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
#import "AWTView.h"
|
||||
|
||||
|
||||
@ -53,19 +54,37 @@
|
||||
#define JAVA_AX_VISIBLE_CHILDREN (-3)
|
||||
// If the value is >=0, it's an index
|
||||
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getTableInfo, sjc_CAccessibility, "getTableInfo", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleComponent, sjc_CAccessibility, "getAccessibleComponent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleValue, sjc_CAccessibility, "getAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleValue;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_isFocusTraversable, sjc_CAccessibility, "isFocusTraversable", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
|
||||
// GET* macros defined in JavaAccessibilityUtilities.h, so they can be shared.
|
||||
static jclass sjc_CAccessibility = NULL;
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
|
||||
static jmethodID sjm_getAccessibleName = NULL;
|
||||
#define GET_ACCESSIBLENAME_METHOD_RETURN(ret) \
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(ret); \
|
||||
GET_STATIC_METHOD_RETURN(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", \
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", ret);
|
||||
|
||||
static jmethodID jm_getChildrenAndRoles = NULL;
|
||||
#define GET_CHILDRENANDROLES_METHOD_RETURN(ret) \
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(ret); \
|
||||
GET_STATIC_METHOD_RETURN(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles",\
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;", ret);
|
||||
|
||||
static jmethodID sjm_getAccessibleComponent = NULL;
|
||||
#define GET_ACCESSIBLECOMPONENT_STATIC_METHOD_RETURN(ret) \
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(ret); \
|
||||
GET_STATIC_METHOD_RETURN(sjm_getAccessibleComponent, sjc_CAccessibility, "getAccessibleComponent", \
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;", ret);
|
||||
|
||||
static jmethodID sjm_getAccessibleIndexInParent = NULL;
|
||||
#define GET_ACCESSIBLEINDEXINPARENT_STATIC_METHOD_RETURN(ret) \
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(ret); \
|
||||
GET_STATIC_METHOD_RETURN(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", \
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I", ret);
|
||||
|
||||
static jclass sjc_CAccessible = NULL;
|
||||
#define GET_CACCESSIBLE_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(sjc_CAccessible, "sun/lwawt/macosx/CAccessible", ret);
|
||||
|
||||
static JNF_MEMBER_CACHE(jf_ptr, sjc_CAccessible, "ptr", "J");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessible", "(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;");
|
||||
|
||||
static jobject sAccessibilityClass = NULL;
|
||||
|
||||
@ -288,7 +307,10 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
}
|
||||
|
||||
if (sAccessibilityClass == NULL) {
|
||||
JNF_STATIC_MEMBER_CACHE(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
GET_CACCESSIBILITY_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;");
|
||||
|
||||
#ifdef JAVA_AX_NO_IGNORES
|
||||
NSArray *ignoredKeys = [NSArray array];
|
||||
@ -298,10 +320,9 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
jobjectArray result = NULL;
|
||||
jsize count = [ignoredKeys count];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
static JNF_CLASS_CACHE(jc_String, "java/lang/String");
|
||||
result = JNFNewObjectArray(env, &jc_String, count);
|
||||
DECLARE_CLASS(jc_String, "java/lang/String");
|
||||
result = (*env)->NewObjectArray(env, count, jc_String, NULL);
|
||||
CHECK_EXCEPTION();
|
||||
if (!result) {
|
||||
NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__);
|
||||
return;
|
||||
@ -314,7 +335,8 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
(*env)->DeleteLocalRef(env, jString);
|
||||
}
|
||||
|
||||
sAccessibilityClass = JNFCallStaticObjectMethod(env, jm_getAccessibility, result); // AWT_THREADING Safe (known object)
|
||||
sAccessibilityClass = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibility, result); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,10 +347,16 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
}
|
||||
|
||||
+ (jobject) getCAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env {
|
||||
if (JNFIsInstanceOf(env, jaccessible, &sjc_CAccessible)) {
|
||||
DECLARE_CLASS_RETURN(sjc_Accessible, "javax/accessibility/Accessible", NULL);
|
||||
GET_CACCESSIBLE_CLASS_RETURN(NULL);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_getCAccessible, sjc_CAccessible, "getCAccessible",
|
||||
"(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;", NULL);
|
||||
if ((*env)->IsInstanceOf(env, jaccessible, sjc_CAccessible)) {
|
||||
return jaccessible;
|
||||
} else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) {
|
||||
return JNFCallStaticObjectMethod(env, sjm_getCAccessible, jaccessible);
|
||||
} else if ((*env)->IsInstanceOf(env, jaccessible, sjc_Accessible)) {
|
||||
jobject o = (*env)->CallStaticObjectMethod(env, sjc_CAccessible, sjm_getCAccessible, jaccessible);
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -336,7 +364,10 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
+ (NSArray *)childrenOfParent:(JavaComponentAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored
|
||||
{
|
||||
if (parent->fAccessible == NULL) return nil;
|
||||
jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CHILDRENANDROLES_METHOD_RETURN(nil);
|
||||
jobjectArray jchildrenAndRoles = (jobjectArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getChildrenAndRoles,
|
||||
parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (jchildrenAndRoles == NULL) return nil;
|
||||
|
||||
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
|
||||
@ -351,7 +382,10 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
NSString *childJavaRole = nil;
|
||||
if (jchildJavaRole != NULL) {
|
||||
jobject jkey = JNFGetObjectField(env, jchildJavaRole, sjf_key);
|
||||
DECLARE_CLASS_RETURN(sjc_AccessibleRole, "javax/accessibility/AccessibleRole", nil);
|
||||
DECLARE_FIELD_RETURN(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;", nil);
|
||||
jobject jkey = (*env)->GetObjectField(env, jchildJavaRole, sjf_key);
|
||||
CHECK_EXCEPTION();
|
||||
childJavaRole = JNFJavaToNSString(env, jkey);
|
||||
(*env)->DeleteLocalRef(env, jkey);
|
||||
}
|
||||
@ -371,9 +405,11 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
+ (JavaComponentAccessibility *)createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view
|
||||
{
|
||||
GET_ACCESSIBLEINDEXINPARENT_STATIC_METHOD_RETURN(nil);
|
||||
JavaComponentAccessibility *ret = nil;
|
||||
jobject jcomponent = [(AWTView *)view awtComponent:env];
|
||||
jint index = JNFCallStaticIntMethod(env, sjm_getAccessibleIndexInParent, jaccessible, jcomponent);
|
||||
jint index = (*env)->CallStaticIntMethod(env, sjc_CAccessibility, sjm_getAccessibleIndexInParent, jaccessible, jcomponent);
|
||||
CHECK_EXCEPTION();
|
||||
if (index >= 0) {
|
||||
NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
|
||||
ret = [self createWithAccessible:jaccessible role:javaRole index:index withEnv:env withView:view];
|
||||
@ -389,10 +425,12 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
+ (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
|
||||
{
|
||||
GET_CACCESSIBLE_CLASS_RETURN(NULL);
|
||||
DECLARE_FIELD_RETURN(jf_ptr, sjc_CAccessible, "ptr", "J", NULL);
|
||||
// try to fetch the jCAX from Java, and return autoreleased
|
||||
jobject jCAX = [JavaComponentAccessibility getCAccessible:jaccessible withEnv:env];
|
||||
if (jCAX == NULL) return nil;
|
||||
JavaComponentAccessibility *value = (JavaComponentAccessibility *) jlong_to_ptr(JNFGetLongField(env, jCAX, jf_ptr));
|
||||
JavaComponentAccessibility *value = (JavaComponentAccessibility *) jlong_to_ptr((*env)->GetLongField(env, jCAX, jf_ptr));
|
||||
if (value != nil) {
|
||||
(*env)->DeleteLocalRef(env, jCAX);
|
||||
return [[value retain] autorelease];
|
||||
@ -428,7 +466,7 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
// must hard retain pointer poked into Java object
|
||||
[newChild retain];
|
||||
JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild));
|
||||
(*env)->SetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild));
|
||||
(*env)->DeleteLocalRef(env, jCAX);
|
||||
|
||||
// return autoreleased instance
|
||||
@ -437,7 +475,9 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getInitialAttributeStates, sjc_CAccessibility, "getInitialAttributeStates", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[Z");
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getInitialAttributeStates, sjc_CAccessibility, "getInitialAttributeStates",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[Z", nil);
|
||||
|
||||
NSMutableArray *attributeNames = [NSMutableArray arrayWithCapacity:20];
|
||||
[attributeNames retain];
|
||||
@ -462,7 +502,9 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
// Get all the other accessibility attributes states we need in one swell foop.
|
||||
// javaRole isn't pulled in because we need protected access to AccessibleRole.key
|
||||
jbooleanArray attributeStates = (jbooleanArray)JNFCallStaticObjectMethod(env, jm_getInitialAttributeStates, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
jbooleanArray attributeStates = (jbooleanArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
|
||||
jm_getInitialAttributeStates, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (attributeStates == NULL) return nil;
|
||||
jboolean *attributeStatesArray = (*env)->GetBooleanArrayElements(env, attributeStates, 0);
|
||||
if (attributeStatesArray == NULL) {
|
||||
@ -554,11 +596,14 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
- (void)getActionsWithEnv:(JNIEnv *)env
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleAction, sjc_CAccessibility, "getAccessibleAction", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleAction;");
|
||||
GET_CACCESSIBILITY_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_getAccessibleAction, sjc_CAccessibility, "getAccessibleAction",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleAction;");
|
||||
|
||||
// On MacOSX, text doesn't have actions, in java it does.
|
||||
// cmcnote: NOT TRUE - Editable text has AXShowMenu. Textfields have AXConfirm. Static text has no actions.
|
||||
jobject axAction = JNFCallStaticObjectMethod(env, jm_getAccessibleAction, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
jobject axAction = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleAction, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axAction != NULL) {
|
||||
//+++gdb NOTE: In MacOSX, there is just a single Action, not multiple. In java,
|
||||
// the first one seems to be the most basic, so this will be used.
|
||||
@ -577,22 +622,26 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
- (id)parent
|
||||
{
|
||||
static JNF_CLASS_CACHE(sjc_Window, "java/awt/Window");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleParent, sjc_CAccessibility, "getAccessibleParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getSwingAccessible, sjc_CAccessible, "getSwingAccessible", "(Ljavax/accessibility/Accessible;)Ljavax/accessibility/Accessible;");
|
||||
|
||||
if(fParent == nil) {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleParent, sjc_CAccessibility, "getAccessibleParent",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;", nil);
|
||||
GET_CACCESSIBLE_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_getSwingAccessible, sjc_CAccessible, "getSwingAccessible",
|
||||
"(Ljavax/accessibility/Accessible;)Ljavax/accessibility/Accessible;", nil);
|
||||
DECLARE_CLASS_RETURN(sjc_Window, "java/awt/Window", nil);
|
||||
|
||||
jobject jparent = JNFCallStaticObjectMethod(env, sjm_getAccessibleParent, fAccessible, fComponent);
|
||||
jobject jparent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleParent, fAccessible, fComponent);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
if (jparent == NULL) {
|
||||
fParent = fView;
|
||||
} else {
|
||||
AWTView *view = fView;
|
||||
jobject jax = JNFCallStaticObjectMethod(env, sjm_getSwingAccessible, fAccessible);
|
||||
jobject jax = (*env)->CallStaticObjectMethod(env, sjc_CAccessible, sjm_getSwingAccessible, fAccessible);
|
||||
|
||||
if (JNFIsInstanceOf(env, jax, &sjc_Window)) {
|
||||
if ((*env)->IsInstanceOf(env, jax, sjc_Window)) {
|
||||
// In this case jparent is an owner toplevel and we should retrieve its own view
|
||||
view = [AWTView awtView:env ofAccessible:jparent];
|
||||
}
|
||||
@ -798,11 +847,15 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
return [super accessibilityIndexOfChild:child];
|
||||
}
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_ACCESSIBLEINDEXINPARENT_STATIC_METHOD_RETURN(0);
|
||||
jint returnValue =
|
||||
JNFCallStaticIntMethod( [ThreadUtilities getJNIEnv],
|
||||
(*env)->CallStaticIntMethod( env,
|
||||
sjc_CAccessibility,
|
||||
sjm_getAccessibleIndexInParent,
|
||||
((JavaComponentAccessibility *)child)->fAccessible,
|
||||
((JavaComponentAccessibility *)child)->fComponent );
|
||||
CHECK_EXCEPTION();
|
||||
return (returnValue == -1) ? NSNotFound : returnValue;
|
||||
}
|
||||
|
||||
@ -821,10 +874,12 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
// Flag indicating enabled state of element (NSNumber)
|
||||
- (NSNumber *)accessibilityEnabledAttribute
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_isEnabled, sjc_CAccessibility, "isEnabled", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
NSNumber *value = [NSNumber numberWithBool:JNFCallStaticBooleanMethod(env, jm_isEnabled, fAccessible, fComponent)]; // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_isEnabled, sjc_CAccessibility, "isEnabled", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z", nil);
|
||||
|
||||
NSNumber *value = [NSNumber numberWithBool:(*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, jm_isEnabled, fAccessible, fComponent)]; // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (value == nil) {
|
||||
NSLog(@"WARNING: %s called on component that has no accessible component: %@", __FUNCTION__, self);
|
||||
}
|
||||
@ -848,25 +903,31 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
- (BOOL)accessibilityIsFocusedAttributeSettable
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(NO);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_isFocusTraversable, sjc_CAccessibility, "isFocusTraversable",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z", NO);
|
||||
// According to javadoc, a component that is focusable will return true from isFocusTraversable,
|
||||
// as well as having AccessibleState.FOCUSABLE in its AccessibleStateSet.
|
||||
// We use the former heuristic; if the component focus-traversable, add a focused attribute
|
||||
// See also initializeAttributeNamesWithEnv:
|
||||
if (JNFCallStaticBooleanMethod(env, sjm_isFocusTraversable, fAccessible, fComponent)) { // AWT_THREADING Safe (AWTRunLoop)
|
||||
if ((*env)->CallStaticBooleanMethod(env, sjc_CAccessibility, sjm_isFocusTraversable, fAccessible, fComponent)) { // AWT_THREADING Safe (AWTRunLoop)
|
||||
return YES;
|
||||
}
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)accessibilitySetFocusedAttribute:(id)value
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_requestFocus, sjc_CAccessibility, "requestFocus", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V");
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
GET_CACCESSIBILITY_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_requestFocus, sjc_CAccessibility, "requestFocus", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V");
|
||||
|
||||
if ([(NSNumber*)value boolValue])
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
JNFCallStaticVoidMethod(env, jm_requestFocus, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_requestFocus, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
}
|
||||
}
|
||||
|
||||
@ -875,7 +936,12 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleDescription, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil);
|
||||
jobject val = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
|
||||
sjm_getAccessibleDescription, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (val == NULL) {
|
||||
return nil;
|
||||
}
|
||||
@ -904,11 +970,13 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
// Element's maximum value (id)
|
||||
- (id)accessibilityMaxValueAttribute
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getMaximumAccessibleValue, sjc_CAccessibility, "getMaximumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getMaximumAccessibleValue, sjc_CAccessibility, "getMaximumAccessibleValue",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;", nil);
|
||||
|
||||
jobject axValue = JNFCallStaticObjectMethod(env, jm_getMaximumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getMaximumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axValue == NULL) {
|
||||
return [NSNumber numberWithInt:0];
|
||||
}
|
||||
@ -925,11 +993,13 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
// Element's minimum value (id)
|
||||
- (id)accessibilityMinValueAttribute
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getMinimumAccessibleValue, sjc_CAccessibility, "getMinimumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getMinimumAccessibleValue, sjc_CAccessibility, "getMinimumAccessibleValue",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;", nil);
|
||||
|
||||
jobject axValue = JNFCallStaticObjectMethod(env, jm_getMinimumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getMinimumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axValue == NULL) {
|
||||
return [NSNumber numberWithInt:0];
|
||||
}
|
||||
@ -983,7 +1053,10 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
- (NSValue *)accessibilityPositionAttribute
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_ACCESSIBLECOMPONENT_STATIC_METHOD_RETURN(nil);
|
||||
jobject axComponent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleComponent,
|
||||
fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// NSAccessibility wants the bottom left point of the object in
|
||||
// bottom left based screen coords
|
||||
@ -1044,11 +1117,14 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
if (value == nil) {
|
||||
// query java if necessary
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleRoleDisplayString, sjc_CAccessibility, "getAccessibleRoleDisplayString", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getAccessibleRoleDisplayString, sjc_CAccessibility, "getAccessibleRoleDisplayString",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil);
|
||||
|
||||
jobject axRole = JNFCallStaticObjectMethod(env, jm_getAccessibleRoleDisplayString, fAccessible, fComponent);
|
||||
|
||||
jobject axRole = (*env)->CallStaticObjectMethod(env, jm_getAccessibleRoleDisplayString, fAccessible, fComponent);
|
||||
CHECK_EXCEPTION();
|
||||
if (axRole != NULL) {
|
||||
value = JNFJavaToNSString(env, axRole);
|
||||
(*env)->DeleteLocalRef(env, axRole);
|
||||
@ -1098,21 +1174,26 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
- (void)accessibilitySetSelectedAttribute:(id)value
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE( jm_requestSelection,
|
||||
sjc_CAccessibility,
|
||||
"requestSelection",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V" );
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
GET_CACCESSIBILITY_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_requestSelection,
|
||||
sjc_CAccessibility,
|
||||
"requestSelection",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V");
|
||||
|
||||
if ([(NSNumber*)value boolValue]) {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
JNFCallStaticVoidMethod(env, jm_requestSelection, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_requestSelection, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
}
|
||||
|
||||
// Element size (NSValue)
|
||||
- (NSValue *)accessibilitySizeAttribute {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_ACCESSIBLECOMPONENT_STATIC_METHOD_RETURN(nil);
|
||||
jobject axComponent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
|
||||
sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
NSValue* size = [NSValue valueWithSize:getAxComponentSize(env, axComponent, fComponent)];
|
||||
(*env)->DeleteLocalRef(env, axComponent);
|
||||
return size;
|
||||
@ -1172,7 +1253,9 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_ACCESSIBLENAME_METHOD_RETURN(nil);
|
||||
jobject val = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (val == NULL) {
|
||||
return nil;
|
||||
}
|
||||
@ -1202,8 +1285,6 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
// (https://docs.oracle.com/javase/8/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue-java.lang.Number-)
|
||||
- (id)accessibilityValueAttribute
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
// Need to handle popupmenus differently.
|
||||
@ -1228,11 +1309,14 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
JavaComponentAccessibility *selectedMenuItem =
|
||||
[selectedChildrenOfMenu objectAtIndex:0];
|
||||
if (selectedMenuItem != nil) {
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
GET_ACCESSIBLENAME_METHOD_RETURN(nil);
|
||||
jobject itemValue =
|
||||
JNFCallStaticObjectMethod( env,
|
||||
(*env)->CallStaticObjectMethod( env,
|
||||
sjm_getAccessibleName,
|
||||
selectedMenuItem->fAccessible,
|
||||
selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (itemValue == NULL) {
|
||||
return nil;
|
||||
}
|
||||
@ -1250,9 +1334,16 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
// cmcnote should coalesce these calls into one java call
|
||||
NSNumber *num = nil;
|
||||
jobject axValue = JNFCallStaticObjectMethod(env, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleValue, sjc_CAccessibility, "getAccessibleValue",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleValue;", nil);
|
||||
jobject axValue = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axValue != NULL) {
|
||||
jobject str = JNFCallStaticObjectMethod(env, jm_getCurrentAccessibleValue, axValue, fComponent);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue",
|
||||
"(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;", nil);
|
||||
jobject str = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getCurrentAccessibleValue, axValue, fComponent);
|
||||
CHECK_EXCEPTION();
|
||||
if (str != NULL) {
|
||||
num = JNFJavaToNSNumber(env, str); // AWT_THREADING Safe (AWTRunLoop)
|
||||
(*env)->DeleteLocalRef(env, str);
|
||||
@ -1350,8 +1441,9 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
- (id)accessibilityHitTest:(NSPoint)point withEnv:(JNIEnv *)env
|
||||
{
|
||||
static JNF_CLASS_CACHE(jc_Container, "java/awt/Container");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_accessibilityHitTest, sjc_CAccessibility, "accessibilityHitTest", "(Ljava/awt/Container;FF)Ljavax/accessibility/Accessible;");
|
||||
DECLARE_CLASS_RETURN(jc_Container, "java/awt/Container", nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_accessibilityHitTest, sjc_CAccessibility, "accessibilityHitTest",
|
||||
"(Ljava/awt/Container;FF)Ljavax/accessibility/Accessible;", nil);
|
||||
|
||||
// Make it into java screen coords
|
||||
point.y = [[[[self view] window] screen] frame].size.height - point.y;
|
||||
@ -1360,7 +1452,9 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
id value = nil;
|
||||
if (JNFIsInstanceOf(env, jparent, &jc_Container)) {
|
||||
jobject jaccessible = JNFCallStaticObjectMethod(env, jm_accessibilityHitTest, jparent, (jfloat)point.x, (jfloat)point.y); // AWT_THREADING Safe (AWTRunLoop)
|
||||
jobject jaccessible = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_accessibilityHitTest,
|
||||
jparent, (jfloat)point.x, (jfloat)point.y); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (jaccessible != NULL) {
|
||||
value = [JavaComponentAccessibility createWithAccessible:jaccessible withEnv:env withView:fView];
|
||||
(*env)->DeleteLocalRef(env, jaccessible);
|
||||
@ -1383,19 +1477,22 @@ static NSObject *sAttributeNamesLOCK = nil;
|
||||
|
||||
- (id)accessibilityFocusedUIElement
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getFocusOwner, sjc_CAccessibility, "getFocusOwner", "(Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getFocusOwner, sjc_CAccessibility, "getFocusOwner",
|
||||
"(Ljava/awt/Component;)Ljavax/accessibility/Accessible;", nil);
|
||||
id value = nil;
|
||||
|
||||
NSWindow* hostWindow = [[self->fView window] retain];
|
||||
jobject focused = JNFCallStaticObjectMethod(env, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
jobject focused = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
[hostWindow release];
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
if (focused != NULL) {
|
||||
if (JNFIsInstanceOf(env, focused, &sjc_Accessible)) {
|
||||
DECLARE_CLASS_RETURN(sjc_Accessible, "javax/accessibility/Accessible", nil);
|
||||
if ((*env)->IsInstanceOf(env, focused, sjc_Accessible)) {
|
||||
value = [JavaComponentAccessibility createWithAccessible:focused withEnv:env withView:fView];
|
||||
}
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, focused);
|
||||
}
|
||||
|
||||
@ -1586,7 +1683,10 @@ JNF_COCOA_EXIT(env);
|
||||
|
||||
- (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored
|
||||
{
|
||||
jobjectArray jtabsAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, fAccessible, fComponent, whichTabs, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CHILDRENANDROLES_METHOD_RETURN(nil);
|
||||
jobjectArray jtabsAndRoles = (jobjectArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getChildrenAndRoles,
|
||||
fAccessible, fComponent, whichTabs, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if(jtabsAndRoles == NULL) return nil;
|
||||
|
||||
jsize arrayLen = (*env)->GetArrayLength(env, jtabsAndRoles);
|
||||
@ -1602,7 +1702,10 @@ JNF_COCOA_EXIT(env);
|
||||
(*env)->DeleteLocalRef(env, jtabsAndRoles);
|
||||
return nil;
|
||||
}
|
||||
jobject jkey = JNFGetObjectField(env, jtabJavaRole, sjf_key);
|
||||
DECLARE_CLASS_RETURN(sjc_AccessibleRole, "javax/accessibility/AccessibleRole", nil);
|
||||
DECLARE_FIELD_RETURN(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;", nil);
|
||||
jobject jkey = (*env)->GetObjectField(env, jtabJavaRole, sjf_key);
|
||||
CHECK_EXCEPTION();
|
||||
NSString *tabJavaRole = JNFJavaToNSString(env, jkey);
|
||||
(*env)->DeleteLocalRef(env, jkey);
|
||||
|
||||
@ -1918,8 +2021,12 @@ static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component);
|
||||
if (fAccessible == NULL) return 0;
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jint count = JNFCallStaticIntMethod(env, jm_getTableInfo, fAccessible,
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getTableInfo, sjc_CAccessibility, "getTableInfo",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I", nil);
|
||||
jint count = (*env)->CallStaticIntMethod(env, sjc_CAccessibility, jm_getTableInfo, fAccessible,
|
||||
fComponent, info);
|
||||
CHECK_EXCEPTION();
|
||||
NSNumber *index = [NSNumber numberWithInt:count];
|
||||
return index;
|
||||
}
|
||||
@ -1939,9 +2046,9 @@ static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component);
|
||||
- (NSRect)accessibilityFrame
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent,
|
||||
fAccessible, fComponent);
|
||||
|
||||
GET_ACCESSIBLECOMPONENT_STATIC_METHOD_RETURN(NSZeroRect);
|
||||
jobject axComponent = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleComponent, fAccessible, fComponent);
|
||||
CHECK_EXCEPTION();
|
||||
NSSize size = getAxComponentSize(env, axComponent, fComponent);
|
||||
NSPoint point = getAxComponentLocationOnScreen(env, axComponent, fComponent);
|
||||
(*env)->DeleteLocalRef(env, axComponent);
|
||||
@ -1965,20 +2072,24 @@ static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component);
|
||||
* This may use LWCToolkit.invokeAndWait(); don't call while holding fLock
|
||||
* and try to pass a component so the event happens on the correct thread.
|
||||
*/
|
||||
static JNF_CLASS_CACHE(sjc_Object, "java/lang/Object");
|
||||
static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component)
|
||||
{
|
||||
static JNF_MEMBER_CACHE(jm_equals, sjc_Object, "equals", "(Ljava/lang/Object;)Z");
|
||||
DECLARE_CLASS_RETURN(sjc_Object, "java/lang/Object", NO);
|
||||
DECLARE_METHOD_RETURN(jm_equals, sjc_Object, "equals", "(Ljava/lang/Object;)Z", NO);
|
||||
|
||||
if ((a == NULL) && (b == NULL)) return YES;
|
||||
if ((a == NULL) || (b == NULL)) return NO;
|
||||
|
||||
if (pthread_main_np() != 0) {
|
||||
// If we are on the AppKit thread
|
||||
static JNF_CLASS_CACHE(sjc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_doEquals, sjc_LWCToolkit, "doEquals", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/awt/Component;)Z");
|
||||
return JNFCallStaticBooleanMethod(env, jm_doEquals, a, b, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
DECLARE_CLASS_RETURN(sjc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit", NO);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_doEquals, sjc_LWCToolkit, "doEquals",
|
||||
"(Ljava/lang/Object;Ljava/lang/Object;Ljava/awt/Component;)Z", NO);
|
||||
return (*env)->CallStaticBooleanMethod(env, sjc_LWCToolkit, jm_doEquals, a, b, component); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
return JNFCallBooleanMethod(env, a, jm_equals, b); // AWT_THREADING Safe (!appKit)
|
||||
jboolean jb = (*env)->CallBooleanMethod(env, a, jm_equals, b); // AWT_THREADING Safe (!appKit)
|
||||
CHECK_EXCEPTION();
|
||||
return jb;
|
||||
}
|
||||
|
||||
@ -27,12 +27,32 @@
|
||||
#import "JavaAccessibilityAction.h"
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
static jclass sjc_CAccessibility = NULL;
|
||||
#define GET_CACCESSIBLITY_CLASS() \
|
||||
GET_CLASS(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility");
|
||||
#define GET_CACCESSIBLITY_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(sjc_CAccessibility, "sun/lwawt/macosx/CAccessibility", ret);
|
||||
|
||||
static jmethodID sjm_getAccessibleText = NULL;
|
||||
#define GET_ACCESSIBLETEXT_METHOD_RETURN(ret) \
|
||||
GET_CACCESSIBLITY_CLASS_RETURN(ret); \
|
||||
GET_STATIC_METHOD_RETURN(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", \
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;", ret);
|
||||
|
||||
static jclass sjc_CAccessibleText = NULL;
|
||||
#define GET_CACCESSIBLETEXT_CLASS() \
|
||||
GET_CLASS(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText");
|
||||
#define GET_CACCESSIBLETEXT_CLASS_RETURN(ret) \
|
||||
GET_CLASS_RETURN(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText", ret);
|
||||
|
||||
static jmethodID sjm_getAccessibleEditableText = NULL;
|
||||
#define GET_ACCESSIBLEEDITABLETEXT_METHOD_RETURN(ret) \
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(ret); \
|
||||
GET_STATIC_METHOD_RETURN(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", \
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;", ret);
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_CAccessibleText, "sun/lwawt/macosx/CAccessibleText");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleText, sjc_CAccessibility, "getAccessibleText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleText;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleEditableText, sjc_CAccessibleText, "getAccessibleEditableText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleEditableText;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
|
||||
/*
|
||||
* Converts an int array to an NSRange wrapped inside an NSValue
|
||||
@ -108,9 +128,14 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
- (NSString *)accessibilityValueAttribute
|
||||
{
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CACCESSIBLITY_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil);
|
||||
if ([[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityStaticTextRole]) {
|
||||
// if it's static text, the AppKit AXValue is the java accessibleName
|
||||
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
jobject axName = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
|
||||
sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axName != NULL) {
|
||||
NSString* str = JNFJavaToNSString(env, axName);
|
||||
(*env)->DeleteLocalRef(env, axName);
|
||||
@ -120,15 +145,25 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
}
|
||||
|
||||
// cmcnote: inefficient to make three distinct JNI calls. Coalesce. radr://3951923
|
||||
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_ACCESSIBLETEXT_METHOD_RETURN(@"");
|
||||
jobject axText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
|
||||
sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axText == NULL) return nil;
|
||||
(*env)->DeleteLocalRef(env, axText);
|
||||
|
||||
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_ACCESSIBLEEDITABLETEXT_METHOD_RETURN(nil);
|
||||
jobject axEditableText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText,
|
||||
sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axEditableText == NULL) return nil;
|
||||
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getTextRange, sjc_CAccessibleText, "getTextRange", "(Ljavax/accessibility/AccessibleEditableText;IILjava/awt/Component;)Ljava/lang/String;");
|
||||
jobject jrange = JNFCallStaticObjectMethod(env, jm_getTextRange, axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getTextRange, sjc_CAccessibleText, "getTextRange",
|
||||
"(Ljavax/accessibility/AccessibleEditableText;IILjava/awt/Component;)Ljava/lang/String;", nil);
|
||||
CHECK_EXCEPTION();
|
||||
jobject jrange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getTextRange,
|
||||
axEditableText, 0, getAxTextCharCount(env, axEditableText, fComponent), fComponent);
|
||||
CHECK_EXCEPTION();
|
||||
NSString *string = JNFJavaToNSString(env, jrange); // AWT_THREADING Safe (AWTRunLoop)
|
||||
|
||||
(*env)->DeleteLocalRef(env, jrange);
|
||||
@ -145,7 +180,10 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
if (!isEnabled) return NO;
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject axEditableText = JNFCallStaticObjectMethod(env, sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_ACCESSIBLEEDITABLETEXT_METHOD_RETURN(NO);
|
||||
jobject axEditableText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText,
|
||||
sjm_getAccessibleEditableText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axEditableText == NULL) return NO;
|
||||
(*env)->DeleteLocalRef(env, axEditableText);
|
||||
return YES;
|
||||
@ -163,8 +201,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
- (NSString *)accessibilitySelectedTextAttribute
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedText, sjc_CAccessibleText, "getSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
jobject axText = JNFCallStaticObjectMethod(env, jm_getSelectedText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getSelectedText, sjc_CAccessibleText, "getSelectedText",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", nil);
|
||||
jobject axText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getSelectedText,
|
||||
fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axText == NULL) return @"";
|
||||
NSString* str = JNFJavaToNSString(env, axText);
|
||||
(*env)->DeleteLocalRef(env, axText);
|
||||
@ -187,16 +229,24 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jstring jstringValue = JNFNSToJavaString(env, (NSString *)value);
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedText, sjc_CAccessibleText, "setSelectedText", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;Ljava/lang/String;)V");
|
||||
JNFCallStaticVoidMethod(env, jm_setSelectedText, fAccessible, fComponent, jstringValue); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_setSelectedText, sjc_CAccessibleText, "setSelectedText",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;Ljava/lang/String;)V");
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibleText, jm_setSelectedText,
|
||||
fAccessible, fComponent, jstringValue); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
// Range of selected text (NSValue)
|
||||
- (NSValue *)accessibilitySelectedTextRangeAttribute
|
||||
{
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getSelectedTextRange, sjc_CAccessibleText, "getSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
|
||||
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getSelectedTextRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getSelectedTextRange, sjc_CAccessibleText, "getSelectedTextRange",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I", nil);
|
||||
jintArray axTextRange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText,
|
||||
jm_getSelectedTextRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axTextRange == NULL) return nil;
|
||||
|
||||
return javaIntArrayToNSRangeValue(env, axTextRange);
|
||||
@ -221,8 +271,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
jint endIndex = startIndex + range.length;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_setSelectedTextRange, sjc_CAccessibleText, "setSelectedTextRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)V");
|
||||
JNFCallStaticVoidMethod(env, jm_setSelectedTextRange, fAccessible, fComponent, startIndex, endIndex); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS();
|
||||
DECLARE_STATIC_METHOD(jm_setSelectedTextRange, sjc_CAccessibleText, "setSelectedTextRange",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)V");
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibleText, jm_setSelectedTextRange,
|
||||
fAccessible, fComponent, startIndex, endIndex); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
- (NSNumber *)accessibilityNumberOfCharactersAttribute
|
||||
@ -230,7 +284,10 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
// cmcnote: should coalesce these two calls - radr://3951923
|
||||
// also, static text doesn't always have accessibleText. if axText is null, should get the charcount of the accessibleName instead
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axText = JNFCallStaticObjectMethod(env, sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_ACCESSIBLETEXT_METHOD_RETURN(nil);
|
||||
jobject axText = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility,
|
||||
sjm_getAccessibleText, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
NSNumber* num = [NSNumber numberWithInt:getAxTextCharCount(env, axText, fComponent)];
|
||||
(*env)->DeleteLocalRef(env, axText);
|
||||
return num;
|
||||
@ -244,8 +301,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
- (NSValue *)accessibilityVisibleCharacterRangeAttribute
|
||||
{
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I");
|
||||
jintArray axTextRange = JNFCallStaticObjectMethod(env, jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getVisibleCharacterRange, sjc_CAccessibleText, "getVisibleCharacterRange",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[I", nil);
|
||||
jintArray axTextRange = (*env)->CallStaticObjectMethod(env, sjc_CAccessibleText,
|
||||
jm_getVisibleCharacterRange, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axTextRange == NULL) return nil;
|
||||
|
||||
return javaIntArrayToNSRangeValue(env, axTextRange);
|
||||
@ -262,8 +323,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
- (NSValue *)accessibilityInsertionPointLineNumberAttribute
|
||||
{
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForInsertionPoint, sjc_CAccessibleText, "getLineNumberForInsertionPoint", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
|
||||
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForInsertionPoint, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getLineNumberForInsertionPoint, sjc_CAccessibleText,
|
||||
"getLineNumberForInsertionPoint", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I", nil);
|
||||
jint row = (*env)->CallStaticIntMethod(env, sjc_CAccessibleText,
|
||||
jm_getLineNumberForInsertionPoint, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (row < 0) return nil;
|
||||
return [NSNumber numberWithInt:row];
|
||||
}
|
||||
@ -297,12 +362,17 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
NSRange range = [(NSValue *)parameter rangeValue];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getBoundsForRange, sjc_CAccessibleText, "getBoundsForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)[D");
|
||||
jdoubleArray axBounds = (jdoubleArray)JNFCallStaticObjectMethod(env, jm_getBoundsForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getBoundsForRange, sjc_CAccessibleText, "getBoundsForRange",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)[D", nil);
|
||||
jdoubleArray axBounds = (jdoubleArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getBoundsForRange,
|
||||
fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axBounds == NULL) return nil;
|
||||
|
||||
// We cheat because we know that the array is 4 elements long (x, y, width, height)
|
||||
jdouble *values = (*env)->GetDoubleArrayElements(env, axBounds, 0);
|
||||
CHECK_EXCEPTION();
|
||||
if (values == NULL) {
|
||||
// Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
|
||||
NSLog(@"%s failed calling GetDoubleArrayElements", __FUNCTION__);
|
||||
@ -324,8 +394,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
if (line == nil) return nil;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getLineNumberForIndex, sjc_CAccessibleText, "getLineNumberForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I");
|
||||
jint row = JNFCallStaticIntMethod(env, jm_getLineNumberForIndex, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getLineNumberForIndex, sjc_CAccessibleText, "getLineNumberForIndex",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I", nil);
|
||||
jint row = (*env)->CallStaticIntMethod(env, sjc_CAccessibleText, jm_getLineNumberForIndex,
|
||||
fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (row < 0) return nil;
|
||||
return [NSNumber numberWithInt:row];
|
||||
}
|
||||
@ -336,8 +410,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
if (line == nil) return nil;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForLine, sjc_CAccessibleText, "getRangeForLine", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
|
||||
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForLine, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getRangeForLine, sjc_CAccessibleText, "getRangeForLine",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I", nil);
|
||||
jintArray axTextRange = (jintArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText,
|
||||
jm_getRangeForLine, fAccessible, fComponent, [line intValue]); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axTextRange == NULL) return nil;
|
||||
|
||||
return javaIntArrayToNSRangeValue(env,axTextRange);
|
||||
@ -362,9 +440,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
NSRange range = [(NSValue *)parameter rangeValue];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;");
|
||||
jstring jstringForRange = (jstring)JNFCallStaticObjectMethod(env, jm_getStringForRange, fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
|
||||
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getStringForRange, sjc_CAccessibleText, "getStringForRange",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)Ljava/lang/String;", nil);
|
||||
jstring jstringForRange = (jstring)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getStringForRange,
|
||||
fAccessible, fComponent, range.location, range.length); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (jstringForRange == NULL) return @"";
|
||||
NSString* str = JNFJavaToNSString(env, jstringForRange);
|
||||
(*env)->DeleteLocalRef(env, jstringForRange);
|
||||
@ -391,8 +472,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
point.y = [[[[self view] window] screen] frame].size.height - point.y; // flip into java screen coords (0 is at upper-left corner of screen)
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getCharacterIndexAtPosition, sjc_CAccessibleText, "getCharacterIndexAtPosition", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)I");
|
||||
jint charIndex = JNFCallStaticIntMethod(env, jm_getCharacterIndexAtPosition, fAccessible, fComponent, point.x, point.y); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getCharacterIndexAtPosition, sjc_CAccessibleText, "getCharacterIndexAtPosition",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;II)I", nil);
|
||||
jint charIndex = (*env)->CallStaticIntMethod(env, sjc_CAccessibleText, jm_getCharacterIndexAtPosition,
|
||||
fAccessible, fComponent, point.x, point.y); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (charIndex == -1) return nil;
|
||||
|
||||
// AccessibleText.getIndexAtPoint returns -1 for an invalid point
|
||||
@ -420,8 +505,12 @@ NSValue *javaIntArrayToNSRangeValue(JNIEnv* env, jintArray array) {
|
||||
NSUInteger index = [(NSNumber *)parameter unsignedIntegerValue];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getRangeForIndex, sjc_CAccessibleText, "getRangeForIndex", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I");
|
||||
jintArray axTextRange = (jintArray)JNFCallStaticObjectMethod(env, jm_getRangeForIndex, fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
|
||||
GET_CACCESSIBLETEXT_CLASS_RETURN(nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getRangeForIndex, sjc_CAccessibleText, "getRangeForIndex",
|
||||
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)[I", nil);
|
||||
jintArray axTextRange = (jintArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibleText, jm_getRangeForIndex,
|
||||
fAccessible, fComponent, index); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
if (axTextRange == NULL) return nil;
|
||||
|
||||
return javaIntArrayToNSRangeValue(env, axTextRange);
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Security/AuthSession.h>
|
||||
|
||||
#include "jni_util.h"
|
||||
#import "JNIUtilities.h"
|
||||
#import "LWCToolkit.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "CSystemColors.h"
|
||||
@ -184,9 +184,10 @@ static BOOL inDoDragDropLoop;
|
||||
|
||||
- (void)perform {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||
static JNF_CLASS_CACHE(sjc_Runnable, "java/lang/Runnable");
|
||||
static JNF_MEMBER_CACHE(jm_Runnable_run, sjc_Runnable, "run", "()V");
|
||||
JNFCallVoidMethod(env, self.runnable, jm_Runnable_run);
|
||||
DECLARE_CLASS(sjc_Runnable, "java/lang/Runnable");
|
||||
DECLARE_METHOD(jm_Runnable_run, sjc_Runnable, "run", "()V");
|
||||
(*env)->CallVoidMethod(env, self.runnable, jm_Runnable_run);
|
||||
CHECK_EXCEPTION();
|
||||
[self release];
|
||||
}
|
||||
@end
|
||||
@ -195,15 +196,16 @@ void setBusy(BOOL busy) {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_AWTAutoShutdown, "sun/awt/AWTAutoShutdown");
|
||||
DECLARE_CLASS(jc_AWTAutoShutdown, "sun/awt/AWTAutoShutdown");
|
||||
|
||||
if (busy) {
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_notifyBusyMethod, jc_AWTAutoShutdown, "notifyToolkitThreadBusy", "()V");
|
||||
JNFCallStaticVoidMethod(env, jm_notifyBusyMethod);
|
||||
DECLARE_STATIC_METHOD(jm_notifyBusyMethod, jc_AWTAutoShutdown, "notifyToolkitThreadBusy", "()V");
|
||||
(*env)->CallStaticVoidMethod(env, jc_AWTAutoShutdown, jm_notifyBusyMethod);
|
||||
} else {
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_notifyFreeMethod, jc_AWTAutoShutdown, "notifyToolkitThreadFree", "()V");
|
||||
JNFCallStaticVoidMethod(env, jm_notifyFreeMethod);
|
||||
DECLARE_STATIC_METHOD(jm_notifyFreeMethod, jc_AWTAutoShutdown, "notifyToolkitThreadFree", "()V");
|
||||
(*env)->CallStaticVoidMethod(env, jc_AWTAutoShutdown, jm_notifyFreeMethod);
|
||||
}
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
static void setUpAWTAppKit(BOOL installObservers)
|
||||
@ -243,9 +245,11 @@ static void setUpAWTAppKit(BOOL installObservers)
|
||||
}
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadInJava, jc_LWCToolkit, "installToolkitThreadInJava", "()V");
|
||||
JNFCallStaticVoidMethod(env, jsm_installToolkitThreadInJava);
|
||||
DECLARE_CLASS(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||
DECLARE_STATIC_METHOD(jsm_installToolkitThreadInJava, jc_LWCToolkit, "installToolkitThreadInJava", "()V");
|
||||
(*env)->CallStaticVoidMethod(env, jc_LWCToolkit, jsm_installToolkitThreadInJava);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
}
|
||||
|
||||
BOOL isSWTInWebStart(JNIEnv* env) {
|
||||
@ -753,6 +757,7 @@ Java_sun_lwawt_macosx_LWCToolkit_initIDs
|
||||
jmethodID getButtonDownMasksID = (*env)->GetStaticMethodID(env, inputEventClazz, "getButtonDownMasks", "()[I");
|
||||
CHECK_NULL(getButtonDownMasksID);
|
||||
jintArray obj = (jintArray)(*env)->CallStaticObjectMethod(env, inputEventClazz, getButtonDownMasksID);
|
||||
CHECK_EXCEPTION();
|
||||
jint * tmp = (*env)->GetIntArrayElements(env, obj, JNI_FALSE);
|
||||
CHECK_NULL(tmp);
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#import "PrinterView.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
@implementation PrintModel
|
||||
|
||||
@ -88,9 +89,10 @@ AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
[self retain];
|
||||
[printerView retain];
|
||||
|
||||
static JNF_CLASS_CACHE(jc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_detachPrintLoop, jc_CPrinterJob, "detachPrintLoop", "(JJ)V");
|
||||
JNFCallStaticVoidMethod(env, jm_detachPrintLoop, ptr_to_jlong(self), ptr_to_jlong(printerView)); // AWT_THREADING Safe (known object)
|
||||
DECLARE_CLASS_RETURN(jc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob", NO);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_detachPrintLoop, jc_CPrinterJob, "detachPrintLoop", "(JJ)V", NO);
|
||||
(*env)->CallStaticVoidMethod(env, jc_CPrinterJob, jm_detachPrintLoop, ptr_to_jlong(self), ptr_to_jlong(printerView)); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
return fResult;
|
||||
|
||||
@ -32,10 +32,11 @@
|
||||
|
||||
#import "ThreadUtilities.h"
|
||||
#import "GeomUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob");
|
||||
static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
static jclass sjc_CPrinterJob = NULL;
|
||||
#define GET_CPRINTERJOB_CLASS() (sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob");
|
||||
#define GET_CPRINTERJOB_CLASS_RETURN(ret) GET_CLASS_RETURN(sjc_CPrinterJob, "sun/lwawt/macosx/CPrinterJob", ret);
|
||||
|
||||
@implementation PrinterView
|
||||
|
||||
@ -80,15 +81,17 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_printToPathGraphics, sjc_CPrinterJob, "printToPathGraphics", "(Lsun/print/PeekGraphics;Ljava/awt/print/PrinterJob;Ljava/awt/print/Printable;Ljava/awt/print/PageFormat;IJ)V");
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||
|
||||
GET_CPRINTERJOB_CLASS();
|
||||
DECLARE_METHOD(jm_printToPathGraphics, sjc_CPrinterJob, "printToPathGraphics",
|
||||
"(Lsun/print/PeekGraphics;Ljava/awt/print/PrinterJob;Ljava/awt/print/Printable;Ljava/awt/print/PageFormat;IJ)V");
|
||||
|
||||
// Create and draw into a new CPrinterGraphics with the current Context.
|
||||
assert(fCurPageFormat != NULL);
|
||||
assert(fCurPainter != NULL);
|
||||
assert(fCurPeekGraphics != NULL);
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||
|
||||
if ([self cancelCheck:env])
|
||||
{
|
||||
[self releaseReferences:env];
|
||||
@ -102,7 +105,9 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
CGContextRef cgRef = (CGContextRef)[[printLoop context] graphicsPort];
|
||||
CGContextSaveGState(cgRef); //04/28/2004: state needs to be saved here due to addition of lazy state management
|
||||
|
||||
JNFCallVoidMethod(env, fPrinterJob, jm_printToPathGraphics, fCurPeekGraphics, fPrinterJob, fCurPainter, fCurPageFormat, jPageIndex, context); // AWT_THREADING Safe (AWTRunLoop)
|
||||
(*env)->CallVoidMethod(env, fPrinterJob, jm_printToPathGraphics, fCurPeekGraphics, fPrinterJob,
|
||||
fCurPainter, fCurPageFormat, jPageIndex, context); // AWT_THREADING Safe (AWTRunLoop)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
CGContextRestoreGState(cgRef);
|
||||
|
||||
@ -113,11 +118,11 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_getJobName, sjc_CPrinterJob, "getJobName", "()Ljava/lang/String;");
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||
GET_CPRINTERJOB_CLASS_RETURN(nil);
|
||||
DECLARE_METHOD_RETURN(jm_getJobName, sjc_CPrinterJob, "getJobName", "()Ljava/lang/String;", nil);
|
||||
|
||||
jobject o = JNFCallObjectMethod(env, fPrinterJob, jm_getJobName); // AWT_THREADING Safe (known object)
|
||||
jobject o = (*env)->CallObjectMethod(env, fPrinterJob, jm_getJobName); // AWT_THREADING Safe (known object)
|
||||
id result = JNFJavaToNSString(env, o);
|
||||
(*env)->DeleteLocalRef(env, o);
|
||||
return result;
|
||||
@ -151,9 +156,14 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_getPageformatPrintablePeekgraphics, sjc_CPrinterJob, "getPageformatPrintablePeekgraphics", "(I)[Ljava/lang/Object;");
|
||||
static JNF_MEMBER_CACHE(jm_printAndGetPageFormatArea, sjc_CPrinterJob, "printAndGetPageFormatArea", "(Ljava/awt/print/Printable;Ljava/awt/Graphics;Ljava/awt/print/PageFormat;I)Ljava/awt/geom/Rectangle2D;");
|
||||
static JNF_MEMBER_CACHE(jm_getOrientation, sjc_PageFormat, "getOrientation", "()I");
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||
GET_CPRINTERJOB_CLASS_RETURN(NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_getPageformatPrintablePeekgraphics, sjc_CPrinterJob,
|
||||
"getPageformatPrintablePeekgraphics", "(I)[Ljava/lang/Object;", NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_printAndGetPageFormatArea, sjc_CPrinterJob, "printAndGetPageFormatArea",
|
||||
"(Ljava/awt/print/Printable;Ljava/awt/Graphics;Ljava/awt/print/PageFormat;I)Ljava/awt/geom/Rectangle2D;", NSZeroRect);
|
||||
DECLARE_CLASS_RETURN(sjc_PageFormat, "java/awt/print/PageFormat", NSZeroRect);
|
||||
DECLARE_METHOD_RETURN(jm_getOrientation, sjc_PageFormat, "getOrientation", "()I", NSZeroRect);
|
||||
|
||||
// Assertions removed, and corresponding JNFDeleteGlobalRefs added, for radr://3962543
|
||||
// Actual fix that will keep these assertions from being true is radr://3205462 ,
|
||||
@ -162,7 +172,6 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
//assert(fCurPainter == NULL);
|
||||
//assert(fCurPeekGraphics == NULL);
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||
if(fCurPageFormat != NULL) {
|
||||
JNFDeleteGlobalRef(env, fCurPageFormat);
|
||||
}
|
||||
@ -184,7 +193,9 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
jobjectArray objectArray = JNFCallObjectMethod(env, fPrinterJob, jm_getPageformatPrintablePeekgraphics, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
jobjectArray objectArray = (*env)->CallObjectMethod(env, fPrinterJob,
|
||||
jm_getPageformatPrintablePeekgraphics, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
if (objectArray != NULL) {
|
||||
// Get references to the return objects -> PageFormat, Printable, PeekGraphics
|
||||
// Cheat - we know we either got NULL or a 3 element array
|
||||
@ -201,12 +212,14 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
(*env)->DeleteLocalRef(env, peekGraphics);
|
||||
|
||||
// Actually print and get the PageFormatArea
|
||||
jobject pageFormatArea = JNFCallObjectMethod(env, fPrinterJob, jm_printAndGetPageFormatArea, fCurPainter, fCurPeekGraphics, fCurPageFormat, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
jobject pageFormatArea = (*env)->CallObjectMethod(env, fPrinterJob, jm_printAndGetPageFormatArea, fCurPainter,
|
||||
fCurPeekGraphics, fCurPageFormat, jPageNumber); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
if (pageFormatArea != NULL) {
|
||||
NSPrintingOrientation currentOrientation =
|
||||
[[[NSPrintOperation currentOperation] printInfo] orientation];
|
||||
// set page orientation
|
||||
switch (JNFCallIntMethod(env, fCurPageFormat, jm_getOrientation)) {
|
||||
switch ((*env)->CallIntMethod(env, fCurPageFormat, jm_getOrientation)) {
|
||||
case java_awt_print_PageFormat_PORTRAIT:
|
||||
default:
|
||||
if (currentOrientation != NSPortraitOrientation) {
|
||||
@ -223,6 +236,7 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
}
|
||||
break;
|
||||
}
|
||||
CHECK_EXCEPTION();
|
||||
result = JavaToNSRect(env, pageFormatArea);
|
||||
(*env)->DeleteLocalRef(env, pageFormatArea);
|
||||
} else {
|
||||
@ -243,9 +257,12 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_cancelCheck, sjc_CPrinterJob, "cancelCheck", "()Z");
|
||||
GET_CPRINTERJOB_CLASS_RETURN(NO);
|
||||
DECLARE_METHOD_RETURN(jm_cancelCheck, sjc_CPrinterJob, "cancelCheck", "()Z", NO);
|
||||
|
||||
return JNFCallBooleanMethod(env, fPrinterJob, jm_cancelCheck); // AWT_THREADING Safe (known object)
|
||||
BOOL b = (*env)->CallBooleanMethod(env, fPrinterJob, jm_cancelCheck); // AWT_THREADING Safe (known object)
|
||||
CHECK_EXCEPTION();
|
||||
return b;
|
||||
}
|
||||
|
||||
// This is called by -[PrintModel safePrintLoop]
|
||||
@ -253,8 +270,9 @@ static JNF_CLASS_CACHE(sjc_PageFormat, "java/awt/print/PageFormat");
|
||||
{
|
||||
AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
|
||||
static JNF_MEMBER_CACHE(jf_completePrintLoop, sjc_CPrinterJob, "completePrintLoop", "()V");
|
||||
JNFCallVoidMethod(env, fPrinterJob, jf_completePrintLoop);
|
||||
DECLARE_METHOD(jf_completePrintLoop, sjc_CPrinterJob, "completePrintLoop", "()V");
|
||||
(*env)->CallVoidMethod(env, fPrinterJob, jf_completePrintLoop);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
// Clean up after ourselves
|
||||
// Can't put these into -dealloc since that happens (potentially) after the JNIEnv is stale
|
||||
|
||||
@ -23,11 +23,10 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
#import "AWTSurfaceLayers.h"
|
||||
|
||||
#import "jni_util.h"
|
||||
|
||||
JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo
|
||||
(JAWT_DrawingSurface* ds)
|
||||
@ -37,32 +36,32 @@ JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceI
|
||||
JNIEnv *env = ds->env;
|
||||
jobject target = ds->target;
|
||||
|
||||
static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
|
||||
static JNF_MEMBER_CACHE(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;");
|
||||
jobject peer = JNFGetObjectField(env, target, jf_peer);
|
||||
DECLARE_CLASS_RETURN(jc_Component, "java/awt/Component", NULL);
|
||||
DECLARE_FIELD_RETURN(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;", NULL);
|
||||
jobject peer = (*env)->GetObjectField(env, target, jf_peer);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_ComponentPeer, "sun/lwawt/LWComponentPeer");
|
||||
static JNF_MEMBER_CACHE(jf_platformComponent, jc_ComponentPeer,
|
||||
"platformComponent", "Lsun/lwawt/PlatformComponent;");
|
||||
jobject platformComponent = JNFGetObjectField(env, peer, jf_platformComponent);
|
||||
DECLARE_CLASS_RETURN(jc_ComponentPeer, "sun/lwawt/LWComponentPeer", NULL);
|
||||
DECLARE_FIELD_RETURN(jf_platformComponent, jc_ComponentPeer,
|
||||
"platformComponent", "Lsun/lwawt/PlatformComponent;", NULL);
|
||||
jobject platformComponent = (*env)->GetObjectField(env, peer, jf_platformComponent);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent");
|
||||
static JNF_MEMBER_CACHE(jm_getPointer, jc_PlatformComponent, "getPointer", "()J");
|
||||
AWTSurfaceLayers *surfaceLayers = jlong_to_ptr(JNFCallLongMethod(env, platformComponent, jm_getPointer));
|
||||
DECLARE_CLASS_RETURN(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent", NULL);
|
||||
DECLARE_METHOD_RETURN(jm_getPointer, jc_PlatformComponent, "getPointer", "()J", NULL);
|
||||
AWTSurfaceLayers *surfaceLayers = jlong_to_ptr((*env)->CallLongMethod(env, platformComponent, jm_getPointer));
|
||||
// REMIND: assert(surfaceLayers)
|
||||
|
||||
dsi->platformInfo = surfaceLayers;
|
||||
dsi->ds = ds;
|
||||
|
||||
static JNF_MEMBER_CACHE(jf_x, jc_Component, "x", "I");
|
||||
static JNF_MEMBER_CACHE(jf_y, jc_Component, "y", "I");
|
||||
static JNF_MEMBER_CACHE(jf_width, jc_Component, "width", "I");
|
||||
static JNF_MEMBER_CACHE(jf_height, jc_Component, "height", "I");
|
||||
DECLARE_FIELD_RETURN(jf_x, jc_Component, "x", "I", NULL);
|
||||
DECLARE_FIELD_RETURN(jf_y, jc_Component, "y", "I", NULL);
|
||||
DECLARE_FIELD_RETURN(jf_width, jc_Component, "width", "I", NULL);
|
||||
DECLARE_FIELD_RETURN(jf_height, jc_Component, "height", "I", NULL);
|
||||
|
||||
dsi->bounds.x = JNFGetIntField(env, target, jf_x);
|
||||
dsi->bounds.y = JNFGetIntField(env, target, jf_y);
|
||||
dsi->bounds.width = JNFGetIntField(env, target, jf_width);
|
||||
dsi->bounds.height = JNFGetIntField(env, target, jf_height);
|
||||
dsi->bounds.x = (*env)->GetIntField(env, target, jf_x);
|
||||
dsi->bounds.y = (*env)->GetIntField(env, target, jf_y);
|
||||
dsi->bounds.width = (*env)->GetIntField(env, target, jf_width);
|
||||
dsi->bounds.height = (*env)->GetIntField(env, target, jf_height);
|
||||
|
||||
dsi->clipSize = 1;
|
||||
dsi->clip = &(dsi->bounds);
|
||||
@ -148,7 +147,9 @@ JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
|
||||
mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V");
|
||||
CHECK_NULL_RETURN(mid, NULL);
|
||||
}
|
||||
return (*env)->NewObject(env, cls, mid, platformInfo);
|
||||
jobject o = (*env)->NewObject(env, cls, mid, platformInfo);
|
||||
CHECK_EXCEPTION();
|
||||
return o;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL awt_SetBounds
|
||||
@ -162,6 +163,7 @@ JNIEXPORT void JNICALL awt_SetBounds
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
(*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h);
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
|
||||
@ -175,4 +177,5 @@ JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
|
||||
CHECK_NULL(mid);
|
||||
}
|
||||
(*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate);
|
||||
CHECK_EXCEPTION();
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#import "AWTFont.h"
|
||||
#import "AWTStrike.h"
|
||||
#import "CoreTextSupport.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
@implementation AWTFont
|
||||
|
||||
@ -122,11 +123,12 @@ static NSString* uiBoldName = nil;
|
||||
return nil;
|
||||
}
|
||||
|
||||
static JNF_CLASS_CACHE(jc_Font, "java/awt/Font");
|
||||
DECLARE_CLASS_RETURN(jc_Font, "java/awt/Font", nil);
|
||||
|
||||
// obtain the Font2D
|
||||
static JNF_MEMBER_CACHE(jm_Font_getFont2D, jc_Font, "getFont2D", "()Lsun/font/Font2D;");
|
||||
jobject font2d = JNFCallObjectMethod(env, javaFont, jm_Font_getFont2D);
|
||||
DECLARE_METHOD_RETURN(jm_Font_getFont2D, jc_Font, "getFont2D", "()Lsun/font/Font2D;", nil);
|
||||
jobject font2d = (*env)->CallObjectMethod(env, javaFont, jm_Font_getFont2D);
|
||||
CHECK_EXCEPTION();
|
||||
if (font2d == NULL) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"nil font2d");
|
||||
@ -136,27 +138,28 @@ static NSString* uiBoldName = nil;
|
||||
|
||||
// if it's not a CFont, it's likely one of TTF or OTF fonts
|
||||
// from the Sun rendering loops
|
||||
static JNF_CLASS_CACHE(jc_CFont, "sun/font/CFont");
|
||||
if (!JNFIsInstanceOf(env, font2d, &jc_CFont)) {
|
||||
DECLARE_CLASS_RETURN(jc_CFont, "sun/font/CFont", nil);
|
||||
if (!(*env)->IsInstanceOf(env, font2d, jc_CFont)) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"font2d !instanceof CFont");
|
||||
#endif
|
||||
return nil;
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_CFont_getFontStrike, jc_CFont, "getStrike", "(Ljava/awt/Font;)Lsun/font/FontStrike;");
|
||||
jobject fontStrike = JNFCallObjectMethod(env, font2d, jm_CFont_getFontStrike, javaFont);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_CStrike, "sun/font/CStrike");
|
||||
if (!JNFIsInstanceOf(env, fontStrike, &jc_CStrike)) {
|
||||
DECLARE_METHOD_RETURN(jm_CFont_getFontStrike, jc_CFont, "getStrike", "(Ljava/awt/Font;)Lsun/font/FontStrike;", nil);
|
||||
jobject fontStrike = (*env)->CallObjectMethod(env, font2d, jm_CFont_getFontStrike, javaFont);
|
||||
CHECK_EXCEPTION();
|
||||
DECLARE_CLASS_RETURN(jc_CStrike, "sun/font/CStrike", nil);
|
||||
if (!(*env)->IsInstanceOf(env, fontStrike, jc_CStrike)) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"fontStrike !instanceof CStrike");
|
||||
#endif
|
||||
return nil;
|
||||
}
|
||||
|
||||
static JNF_MEMBER_CACHE(jm_CStrike_nativeStrikePtr, jc_CStrike, "getNativeStrikePtr", "()J");
|
||||
jlong awtStrikePtr = JNFCallLongMethod(env, fontStrike, jm_CStrike_nativeStrikePtr);
|
||||
DECLARE_METHOD_RETURN(jm_CStrike_nativeStrikePtr, jc_CStrike, "getNativeStrikePtr", "()J", nil);
|
||||
jlong awtStrikePtr = (*env)->CallLongMethod(env, fontStrike, jm_CStrike_nativeStrikePtr);
|
||||
CHECK_EXCEPTION();
|
||||
if (awtStrikePtr == 0L) {
|
||||
#ifdef DEBUG
|
||||
NSLog(@"nil nativeFontPtr from CFont");
|
||||
@ -285,71 +288,6 @@ static OSStatus CreateFSRef(FSRef *myFSRefPtr, NSString *inPath)
|
||||
myFSRefPtr, NULL);
|
||||
}
|
||||
|
||||
// /*
|
||||
// * Class: sun_font_CFontManager
|
||||
// * Method: loadFileFont
|
||||
// * Signature: (Ljava/lang/String;)Lsun/font/Font2D;
|
||||
// */
|
||||
// JNIEXPORT /* sun.font.CFont */ jobject JNICALL
|
||||
// Java_sun_font_CFontManager_loadFileFont
|
||||
// (JNIEnv *env, jclass obj, jstring fontpath)
|
||||
// {
|
||||
// jobject result = NULL;
|
||||
//
|
||||
// JNF_COCOA_ENTER(env);
|
||||
//
|
||||
// NSString *nsFilePath = JNFJavaToNSString(env, fontpath);
|
||||
// jstring javaFontName = NULL;
|
||||
//
|
||||
// //
|
||||
// // Note: This API uses ATS and can therefore return Carbon error codes.
|
||||
// // These codes can be found at:
|
||||
// // http://developer.apple.com/techpubs/macosx/Carbon/Files/FileManager/File_Manager/ResultCodes/ResultCodes.html
|
||||
// //
|
||||
//
|
||||
// FSRef iFile;
|
||||
// OSStatus status = CreateFSRef(&iFile, nsFilePath);
|
||||
//
|
||||
// if (status == noErr) {
|
||||
// ATSFontContainerRef oContainer;
|
||||
// status = ATSFontActivateFromFileReference(&iFile, kATSFontContextLocal,
|
||||
// kATSFontFormatUnspecified,
|
||||
// NULL,
|
||||
// kATSOptionFlagsUseDataFork,
|
||||
// &oContainer);
|
||||
// if (status == noErr) {
|
||||
// ATSFontRef ioArray[1];
|
||||
// ItemCount oCount;
|
||||
// status = ATSFontFindFromContainer(oContainer,
|
||||
// kATSOptionFlagsUseDataFork,
|
||||
// 1, ioArray, &oCount);
|
||||
//
|
||||
// if (status == noErr) {
|
||||
// CFStringRef oName;
|
||||
// status = ATSFontGetPostScriptName(ioArray[0],
|
||||
// kATSOptionFlagsUseDataFork,
|
||||
// &oName);
|
||||
// if (status == noErr) {
|
||||
// javaFontName = JNFNSToJavaString(env, (NSString *)oName);
|
||||
// CFRelease(oName);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (javaFontName != NULL) {
|
||||
// // create the CFont!
|
||||
// static JNF_CLASS_CACHE(sjc_CFont, "sun/font/CFont");
|
||||
// static JNF_CTOR_CACHE(sjf_CFont_ctor,
|
||||
// sjc_CFont, "(Ljava/lang/String;)V");
|
||||
// result = JNFNewObject(env, sjf_CFont_ctor, javaFontName);
|
||||
// }
|
||||
//
|
||||
// JNF_COCOA_EXIT(env);
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Class: sun_font_CFontManager
|
||||
* Method: loadNativeFonts
|
||||
@ -359,11 +297,8 @@ JNIEXPORT void JNICALL
|
||||
Java_sun_font_CFontManager_loadNativeFonts
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
static JNF_CLASS_CACHE(jc_CFontManager,
|
||||
"sun/font/CFontManager");
|
||||
static JNF_MEMBER_CACHE(jm_registerFont, jc_CFontManager,
|
||||
"registerFont",
|
||||
"(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
DECLARE_CLASS(jc_CFontManager, "sun/font/CFontManager");
|
||||
DECLARE_METHOD(jm_registerFont, jc_CFontManager, "registerFont", "(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
|
||||
jint num = 0;
|
||||
|
||||
@ -379,8 +314,8 @@ JNF_COCOA_ENTER(env);
|
||||
jobject jFontFamilyName =
|
||||
JNFNSToJavaString(env, GetFamilyNameForFontName(fontname));
|
||||
|
||||
JNFCallVoidMethod(env, jthis,
|
||||
jm_registerFont, jFontName, jFontFamilyName);
|
||||
(*env)->CallVoidMethod(env, jthis, jm_registerFont, jFontName, jFontFamilyName);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, jFontName);
|
||||
(*env)->DeleteLocalRef(env, jFontFamilyName);
|
||||
}
|
||||
@ -637,6 +572,9 @@ Java_sun_font_CFont_getCascadeList
|
||||
#endif
|
||||
jstring jFontName = (jstring)JNFNSToJavaString(env, fontname);
|
||||
(*env)->CallBooleanMethod(env, arrayListOfString, addMID, jFontName);
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
return;
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, jFontName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
#import "CGGlyphImages.h"
|
||||
#import "CGGlyphOutlines.h"
|
||||
#import "CoreTextSupport.h"
|
||||
#import "JNIUtilities.h"
|
||||
#include "fontscalerdefs.h"
|
||||
|
||||
@implementation AWTStrike
|
||||
@ -196,9 +197,11 @@ JNF_COCOA_ENTER(env);
|
||||
bbox.origin.y = -bbox.size.height + decender;
|
||||
|
||||
// Rectangle2D.Float.setRect(float x, float y, float width, float height);
|
||||
static JNF_CLASS_CACHE(sjc_Rectangle2D_Float, "java/awt/geom/Rectangle2D$Float"); // cache class id for Rectangle
|
||||
static JNF_MEMBER_CACHE(sjr_Rectangle2DFloat_setRect, sjc_Rectangle2D_Float, "setRect", "(FFFF)V");
|
||||
JNFCallVoidMethod(env, result, sjr_Rectangle2DFloat_setRect, (jfloat)bbox.origin.x, (jfloat)bbox.origin.y, (jfloat)bbox.size.width, (jfloat)bbox.size.height);
|
||||
DECLARE_CLASS(sjc_Rectangle2D_Float, "java/awt/geom/Rectangle2D$Float"); // cache class id for Rectangle
|
||||
DECLARE_METHOD(sjr_Rectangle2DFloat_setRect, sjc_Rectangle2D_Float, "setRect", "(FFFF)V");
|
||||
(*env)->CallVoidMethod(env, result, sjr_Rectangle2DFloat_setRect,
|
||||
(jfloat)bbox.origin.x, (jfloat)bbox.origin.y, (jfloat)bbox.size.width, (jfloat)bbox.size.height);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
@ -221,6 +224,9 @@ JNF_COCOA_ENTER(env);
|
||||
jfloatArray pointCoords = NULL;
|
||||
jbyteArray pointTypes = NULL;
|
||||
|
||||
DECLARE_CLASS_RETURN(jc_GeneralPath, "java/awt/geom/GeneralPath", NULL);
|
||||
DECLARE_METHOD_RETURN(jc_GeneralPath_ctor, jc_GeneralPath, "<init>", "(I[BI[FI)V", NULL);
|
||||
|
||||
AWT_FONT_CLEANUP_SETUP;
|
||||
|
||||
AWTStrike *awtStrike = (AWTStrike *)jlong_to_ptr(awtStrikePtr);
|
||||
@ -263,9 +269,8 @@ AWT_FONT_CLEANUP_CHECK(pointTypes);
|
||||
|
||||
(*env)->SetByteArrayRegion(env, pointTypes, 0, path->fNumberOfSegments, (jbyte*)path->fSegmentType);
|
||||
|
||||
static JNF_CLASS_CACHE(jc_GeneralPath, "java/awt/geom/GeneralPath");
|
||||
static JNF_CTOR_CACHE(jc_GeneralPath_ctor, jc_GeneralPath, "(I[BI[FI)V");
|
||||
generalPath = JNFNewObject(env, jc_GeneralPath_ctor, java_awt_geom_PathIterator_WIND_NON_ZERO, pointTypes, path->fNumberOfSegments, pointCoords, path->fNumberOfDataElements); // AWT_THREADING Safe (known object)
|
||||
generalPath = (*env)->NewObject(env, jc_GeneralPath, jc_GeneralPath_ctor, java_awt_geom_PathIterator_WIND_NON_ZERO, pointTypes,
|
||||
path->fNumberOfSegments, pointCoords, path->fNumberOfDataElements); // AWT_THREADING Safe (known object)
|
||||
|
||||
// Cleanup
|
||||
cleanup:
|
||||
@ -423,9 +428,9 @@ JNF_COCOA_ENTER(env);
|
||||
* advance: no need to set yMaxLinearAdvanceWidth - it will be zero.
|
||||
*/
|
||||
|
||||
JNF_CLASS_CACHE(sjc_StrikeMetrics, "sun/font/StrikeMetrics");
|
||||
JNF_CTOR_CACHE(strikeMetricsCtr, sjc_StrikeMetrics, "(FFFFFFFFFF)V");
|
||||
metrics = JNFNewObject(env, strikeMetricsCtr,
|
||||
DECLARE_CLASS_RETURN(sjc_StrikeMetrics, "sun/font/StrikeMetrics", NULL);
|
||||
DECLARE_METHOD_RETURN(strikeMetricsCtr, sjc_StrikeMetrics, "<init>", "(FFFFFFFFFF)V", NULL);
|
||||
metrics = (*env)->NewObject(env, sjc_StrikeMetrics, strikeMetricsCtr,
|
||||
0.0, ay, 0.0, dy, 1.0,
|
||||
0.0, 0.0, ly, mx, 0.0);
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#import "ThreadUtilities.h"
|
||||
#import "LWCToolkit.h"
|
||||
#import "CGLSurfaceData.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
|
||||
extern NSOpenGLPixelFormat *sharedPixelFormat;
|
||||
@ -129,8 +130,8 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_CLASS_CACHE(jc_JavaLayer, "sun/java2d/opengl/CGLLayer");
|
||||
static JNF_MEMBER_CACHE(jm_drawInCGLContext, jc_JavaLayer, "drawInCGLContext", "()V");
|
||||
DECLARE_CLASS(jc_JavaLayer, "sun/java2d/opengl/CGLLayer");
|
||||
DECLARE_METHOD(jm_drawInCGLContext, jc_JavaLayer, "drawInCGLContext", "()V");
|
||||
|
||||
jobject javaLayerLocalRef = [self.javaLayer jObjectWithEnv:env];
|
||||
if ((*env)->IsSameObject(env, javaLayerLocalRef, NULL)) {
|
||||
@ -146,7 +147,8 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
glViewport(0, 0, textureWidth, textureHeight);
|
||||
|
||||
JNFCallVoidMethod(env, javaLayerLocalRef, jm_drawInCGLContext);
|
||||
(*env)->CallVoidMethod(env, javaLayerLocalRef, jm_drawInCGLContext);
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, javaLayerLocalRef);
|
||||
|
||||
// Call super to finalize the drawing. By default all it does is call glFlush().
|
||||
|
||||
161
src/java.desktop/macosx/native/libosxapp/JNIUtilities.h
Normal file
161
src/java.desktop/macosx/native/libosxapp/JNIUtilities.h
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#ifndef __JNIUTILITIES_H
|
||||
#define __JNIUTILITIES_H
|
||||
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
|
||||
/******** LOGGING SUPPORT *********/
|
||||
|
||||
#define LOG_NULL(dst_var, name) \
|
||||
if (dst_var == NULL) { \
|
||||
NSLog(@"Bad JNI lookup %s\n", name); \
|
||||
}
|
||||
|
||||
/******** GET CLASS SUPPORT *********/
|
||||
|
||||
#define GET_CLASS(dst_var, cls) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->FindClass(env, cls); \
|
||||
if (dst_var != NULL) dst_var = (*env)->NewGlobalRef(env, dst_var); \
|
||||
} \
|
||||
LOG_NULL(dst_var, cls); \
|
||||
CHECK_NULL(dst_var);
|
||||
|
||||
#define DECLARE_CLASS(dst_var, cls) \
|
||||
static jclass dst_var = NULL; \
|
||||
GET_CLASS(dst_var, cls);
|
||||
|
||||
#define GET_CLASS_RETURN(dst_var, cls, ret) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->FindClass(env, cls); \
|
||||
if (dst_var != NULL) dst_var = (*env)->NewGlobalRef(env, dst_var); \
|
||||
} \
|
||||
LOG_NULL(dst_var, cls); \
|
||||
CHECK_NULL_RETURN(dst_var, ret);
|
||||
|
||||
#define DECLARE_CLASS_RETURN(dst_var, cls, ret) \
|
||||
static jclass dst_var = NULL; \
|
||||
GET_CLASS_RETURN(dst_var, cls, ret);
|
||||
|
||||
|
||||
/******** GET METHOD SUPPORT *********/
|
||||
|
||||
#define GET_METHOD(dst_var, cls, name, signature) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->GetMethodID(env, cls, name, signature); \
|
||||
} \
|
||||
LOG_NULL(dst_var, name); \
|
||||
CHECK_NULL(dst_var);
|
||||
|
||||
#define DECLARE_METHOD(dst_var, cls, name, signature) \
|
||||
static jmethodID dst_var = NULL; \
|
||||
GET_METHOD(dst_var, cls, name, signature);
|
||||
|
||||
#define GET_METHOD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->GetMethodID(env, cls, name, signature); \
|
||||
} \
|
||||
LOG_NULL(dst_var, name); \
|
||||
CHECK_NULL_RETURN(dst_var, ret);
|
||||
|
||||
#define DECLARE_METHOD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
static jmethodID dst_var = NULL; \
|
||||
GET_METHOD_RETURN(dst_var, cls, name, signature, ret);
|
||||
|
||||
#define GET_STATIC_METHOD(dst_var, cls, name, signature) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->GetStaticMethodID(env, cls, name, signature); \
|
||||
} \
|
||||
LOG_NULL(dst_var, name); \
|
||||
CHECK_NULL(dst_var);
|
||||
|
||||
#define DECLARE_STATIC_METHOD(dst_var, cls, name, signature) \
|
||||
static jmethodID dst_var = NULL; \
|
||||
GET_STATIC_METHOD(dst_var, cls, name, signature);
|
||||
|
||||
#define GET_STATIC_METHOD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->GetStaticMethodID(env, cls, name, signature); \
|
||||
} \
|
||||
LOG_NULL(dst_var, name); \
|
||||
CHECK_NULL_RETURN(dst_var, ret);
|
||||
|
||||
#define DECLARE_STATIC_METHOD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
static jmethodID dst_var = NULL; \
|
||||
GET_STATIC_METHOD_RETURN(dst_var, cls, name, signature, ret);
|
||||
|
||||
/******** GET FIELD SUPPORT *********/
|
||||
|
||||
|
||||
#define GET_FIELD(dst_var, cls, name, signature) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->GetFieldID(env, cls, name, signature); \
|
||||
} \
|
||||
LOG_NULL(dst_var, name); \
|
||||
CHECK_NULL(dst_var);
|
||||
|
||||
#define DECLARE_FIELD(dst_var, cls, name, signature) \
|
||||
static jfieldID dst_var = NULL; \
|
||||
GET_FIELD(dst_var, cls, name, signature);
|
||||
|
||||
#define GET_FIELD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->GetFieldID(env, cls, name, signature); \
|
||||
} \
|
||||
LOG_NULL(dst_var, name); \
|
||||
CHECK_NULL_RETURN(dst_var, ret);
|
||||
|
||||
#define DECLARE_FIELD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
static jfieldID dst_var = NULL; \
|
||||
GET_FIELD_RETURN(dst_var, cls, name, signature, ret);
|
||||
|
||||
#define GET_STATIC_FIELD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
if (dst_var == NULL) { \
|
||||
dst_var = (*env)->GetStaticFieldID(env, cls, name, signature); \
|
||||
} \
|
||||
LOG_NULL(dst_var, name); \
|
||||
CHECK_NULL_RETURN(dst_var, ret);
|
||||
|
||||
#define DECLARE_STATIC_FIELD_RETURN(dst_var, cls, name, signature, ret) \
|
||||
static jfieldID dst_var = NULL; \
|
||||
GET_STATIC_FIELD_RETURN(dst_var, cls, name, signature, ret);
|
||||
|
||||
/********* EXCEPTION_HANDLING *********/
|
||||
|
||||
#define CHECK_EXCEPTION() \
|
||||
if ((*env)->ExceptionOccurred(env) != NULL) { \
|
||||
(*env)->ExceptionClear(env); \
|
||||
};
|
||||
|
||||
#define CHECK_EXCEPTION_NULL_RETURN(x, y) \
|
||||
CHECK_EXCEPTION(); \
|
||||
if ((x) == NULL) { \
|
||||
return y; \
|
||||
};
|
||||
|
||||
#endif /* __JNIUTILITIES_H */
|
||||
@ -24,16 +24,19 @@
|
||||
*/
|
||||
|
||||
#import "PropertiesUtilities.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
@implementation PropertiesUtilities
|
||||
|
||||
+ (NSString *) javaSystemPropertyForKey:(NSString *)key withEnv:(JNIEnv *)env {
|
||||
static JNF_CLASS_CACHE(jc_System, "java/lang/System");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getProperty, jc_System, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
DECLARE_CLASS_RETURN(jc_System, "java/lang/System", nil);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_getProperty, jc_System,
|
||||
"getProperty", "(Ljava/lang/String;)Ljava/lang/String;", nil);
|
||||
|
||||
jstring jKey = JNFNSToJavaString(env, key);
|
||||
jstring jValue = JNFCallStaticObjectMethod(env, jm_getProperty, jKey);
|
||||
jstring jValue = (*env)->CallStaticObjectMethod(env, jc_System, jm_getProperty, jKey);
|
||||
(*env)->DeleteLocalRef(env, jKey);
|
||||
CHECK_EXCEPTION_NULL_RETURN(jValue, nil);
|
||||
|
||||
NSString *value = JNFJavaToNSString(env, jValue);
|
||||
(*env)->DeleteLocalRef(env, jValue);
|
||||
|
||||
@ -36,8 +36,11 @@
|
||||
|
||||
#import "ThreadUtilities.h"
|
||||
#import "CMenuBar.h"
|
||||
#import "JNIUtilities.h"
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_ScreenMenu, "com/apple/laf/ScreenMenu");
|
||||
static jclass sjc_ScreenMenu = NULL;
|
||||
#define GET_SCREENMENU_CLASS() \
|
||||
GET_CLASS(sjc_ScreenMenu, "com/apple/laf/ScreenMenu");
|
||||
|
||||
static jint ns2awtModifiers(NSUInteger keyMods) {
|
||||
jint result = 0;
|
||||
@ -104,8 +107,10 @@ static jint ns2awtMouseButton(NSInteger mouseButton) {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNF_COCOA_ENTER(env);
|
||||
//NSLog(@"menuWillOpen %@", [menu title]);
|
||||
static JNF_MEMBER_CACHE(jm_ScreenMenu_invokeOpenLater, sjc_ScreenMenu, "invokeOpenLater", "()V");
|
||||
JNFCallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_invokeOpenLater); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_SCREENMENU_CLASS();
|
||||
DECLARE_METHOD(jm_ScreenMenu_invokeOpenLater, sjc_ScreenMenu, "invokeOpenLater", "()V");
|
||||
(*env)->CallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_invokeOpenLater); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
||||
}
|
||||
@ -122,8 +127,10 @@ JNF_COCOA_EXIT(env);
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNF_COCOA_ENTER(env);
|
||||
//NSLog(@"menuDidClose %@", [menu title]);
|
||||
static JNF_MEMBER_CACHE(jm_ScreenMenu_invokeMenuClosing, sjc_ScreenMenu, "invokeMenuClosing", "()V");
|
||||
JNFCallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_invokeMenuClosing); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_SCREENMENU_CLASS();
|
||||
DECLARE_METHOD(jm_ScreenMenu_invokeMenuClosing, sjc_ScreenMenu, "invokeMenuClosing", "()V");
|
||||
(*env)->CallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_invokeMenuClosing); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
@ -140,9 +147,11 @@ JNF_COCOA_EXIT(env);
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNF_COCOA_ENTER(env);
|
||||
// Send that to Java so we can test which item was hit.
|
||||
static JNF_MEMBER_CACHE(jm_ScreenMenu_updateSelectedItem, sjc_ScreenMenu, "handleItemTargeted", "(IIIII)V");
|
||||
JNFCallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_updateSelectedItem, menuIndex,
|
||||
GET_SCREENMENU_CLASS();
|
||||
DECLARE_METHOD(jm_ScreenMenu_updateSelectedItem, sjc_ScreenMenu, "handleItemTargeted", "(IIIII)V");
|
||||
(*env)->CallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_updateSelectedItem, menuIndex,
|
||||
NSMinY(rect), NSMinX(rect), NSMaxY(rect), NSMaxX(rect)); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
@ -183,8 +192,11 @@ JNF_COCOA_EXIT(env);
|
||||
// Call the mouse event handler, which will generate Java mouse events.
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
JNF_COCOA_ENTER(env);
|
||||
static JNF_MEMBER_CACHE(jm_ScreenMenu_handleMouseEvent, sjc_ScreenMenu, "handleMouseEvent", "(IIIIJ)V");
|
||||
JNFCallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_handleMouseEvent, javaKind, javaX, javaY, javaModifiers, javaWhen); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
GET_SCREENMENU_CLASS();
|
||||
DECLARE_METHOD(jm_ScreenMenu_handleMouseEvent, sjc_ScreenMenu, "handleMouseEvent", "(IIIIJ)V");
|
||||
(*env)->CallVoidMethod(env, [self.javaObjectWrapper jObject], jm_ScreenMenu_handleMouseEvent,
|
||||
javaKind, javaX, javaY, javaModifiers, javaWhen); // AWT_THREADING Safe (AWTRunLoopMode)
|
||||
CHECK_EXCEPTION();
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user