243 CGEventRef event = CGEventCreateScrollWheelEvent(NULL,
244 kCGScrollEventUnitLine,
245 k_JAVA_ROBOT_WHEEL_COUNT, wheelAmt);
246
247 if (event != NULL) {
248 CGEventPost(kCGSessionEventTap, event);
249 CFRelease(event);
250 }
251 }
252
253 /*
254 * Class: sun_lwawt_macosx_CRobot
255 * Method: keyEvent
256 * Signature: (IZ)V
257 */
258 JNIEXPORT void JNICALL
259 Java_sun_lwawt_macosx_CRobot_keyEvent
260 (JNIEnv *env, jobject peer, jint javaKeyCode, jboolean keyPressed)
261 {
262 CGKeyCode keyCode = GetCGKeyCode(javaKeyCode);
263
264 CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed);
265 if (event != NULL) {
266 CGEventPost(kCGSessionEventTap, event);
267 CFRelease(event);
268 }
269 }
270
271 /*
272 * Class: sun_lwawt_macosx_CRobot
273 * Method: nativeGetScreenPixels
274 * Signature: (IIIII[I)V
275 */
276 JNIEXPORT void JNICALL
277 Java_sun_lwawt_macosx_CRobot_nativeGetScreenPixels
278 (JNIEnv *env, jobject peer,
279 jint x, jint y, jint width, jint height, jdouble scale, jintArray pixels)
280 {
281 JNF_COCOA_ENTER(env);
282
283 jint picX = x;
284 jint picY = y;
285 jint picWidth = width;
|
243 CGEventRef event = CGEventCreateScrollWheelEvent(NULL,
244 kCGScrollEventUnitLine,
245 k_JAVA_ROBOT_WHEEL_COUNT, wheelAmt);
246
247 if (event != NULL) {
248 CGEventPost(kCGSessionEventTap, event);
249 CFRelease(event);
250 }
251 }
252
253 /*
254 * Class: sun_lwawt_macosx_CRobot
255 * Method: keyEvent
256 * Signature: (IZ)V
257 */
258 JNIEXPORT void JNICALL
259 Java_sun_lwawt_macosx_CRobot_keyEvent
260 (JNIEnv *env, jobject peer, jint javaKeyCode, jboolean keyPressed)
261 {
262 CGKeyCode keyCode = GetCGKeyCode(javaKeyCode);
263 CGEventRef event = CGEventCreateKeyboardEvent(NULL, keyCode, keyPressed);
264
265 if (event != NULL) {
266 CGEventPost(kCGSessionEventTap, event);
267 CFRelease(event);
268 }
269 }
270
271 /*
272 * Class: sun_lwawt_macosx_CRobot
273 * Method: keyEventUnicode
274 * Signature: (IZ)V
275 */
276 JNIEXPORT void JNICALL
277 Java_sun_lwawt_macosx_CRobot_keyEventUnicode
278 (JNIEnv *env, jobject peer, jint key, jboolean keyPressed)
279 {
280 CGEventRef event;
281 UniChar uCh = key;
282
283 // create a null keyboard event
284 event = CGEventCreateKeyboardEvent(NULL, 0, keyPressed);
285
286 if (event != NULL) {
287 /* Note that application frameworks may ignore the Unicode string in a
288 keyboard event and do their own translation based on the
289 virtual keycode and perceived event state.
290 */
291 CGEventKeyboardSetUnicodeString(event, 1, &uCh);
292 CGEventPost(kCGSessionEventTap, event);
293 CFRelease(event);
294 }
295 }
296
297 /*
298 * Class: sun_lwawt_macosx_CRobot
299 * Method: nativeGetScreenPixels
300 * Signature: (IIIII[I)V
301 */
302 JNIEXPORT void JNICALL
303 Java_sun_lwawt_macosx_CRobot_nativeGetScreenPixels
304 (JNIEnv *env, jobject peer,
305 jint x, jint y, jint width, jint height, jdouble scale, jintArray pixels)
306 {
307 JNF_COCOA_ENTER(env);
308
309 jint picX = x;
310 jint picY = y;
311 jint picWidth = width;
|