77 * Method: fillPointWithCoords 78 * Signature: (Ljava/awt/Point)I 79 */ 80 JNIEXPORT jint JNICALL 81 Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls, jobject point) 82 { 83 static jclass pointClass = NULL; 84 static jfieldID xID, yID; 85 POINT pt; 86 87 VERIFY(::GetCursorPos(&pt)); 88 if (pointClass == NULL) { 89 jclass pointClassLocal = env->FindClass("java/awt/Point"); 90 DASSERT(pointClassLocal != NULL); 91 if (pointClassLocal == NULL) { 92 return (jint)0; 93 } 94 pointClass = (jclass)env->NewGlobalRef(pointClassLocal); 95 env->DeleteLocalRef(pointClassLocal); 96 } 97 xID = env->GetFieldID(pointClass, "x", "I"); 98 CHECK_NULL_RETURN(xID, (jint)0); 99 yID = env->GetFieldID(pointClass, "y", "I"); 100 CHECK_NULL_RETURN(yID, (jint)0); 101 env->SetIntField(point, xID, pt.x); 102 env->SetIntField(point, yID, pt.y); 103 104 // Always return 0 on Windows: we assume there's always a 105 // virtual screen device used. 106 return (jint)0; 107 } 108 109 } // extern "C" | 77 * Method: fillPointWithCoords 78 * Signature: (Ljava/awt/Point)I 79 */ 80 JNIEXPORT jint JNICALL 81 Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls, jobject point) 82 { 83 static jclass pointClass = NULL; 84 static jfieldID xID, yID; 85 POINT pt; 86 87 VERIFY(::GetCursorPos(&pt)); 88 if (pointClass == NULL) { 89 jclass pointClassLocal = env->FindClass("java/awt/Point"); 90 DASSERT(pointClassLocal != NULL); 91 if (pointClassLocal == NULL) { 92 return (jint)0; 93 } 94 pointClass = (jclass)env->NewGlobalRef(pointClassLocal); 95 env->DeleteLocalRef(pointClassLocal); 96 } 97 98 int screen = AwtWin32GraphicsDevice::GetDefaultDeviceIndex(); 99 Devices::InstanceAccess devices; 100 AwtWin32GraphicsDevice *device = devices->GetDevice(screen); 101 102 xID = env->GetFieldID(pointClass, "x", "I"); 103 CHECK_NULL_RETURN(xID, (jint)0); 104 yID = env->GetFieldID(pointClass, "y", "I"); 105 CHECK_NULL_RETURN(yID, (jint)0); 106 107 int x = (device == NULL) ? pt.x : device->ScaleDownX(pt.x); 108 int y = (device == NULL) ? pt.y : device->ScaleDownY(pt.y); 109 110 env->SetIntField(point, xID, x); 111 env->SetIntField(point, yID, y); 112 113 // Always return 0 on Windows: we assume there's always a 114 // virtual screen device used. 115 return (jint)0; 116 } 117 118 } // extern "C" |