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

Print this page

        

*** 144,194 **** { JNF_COCOA_ENTER(env); // This is the native method called when Robot mouse events occur. // The CRobot tracks the mouse position, and which button was ! // pressed. If the mouse position is unknown it is obtained from ! // CGEvents. The peer also tracks the mouse button desired state, // the appropriate key modifier state, and whether the mouse action // is simply a mouse move with no mouse button state changes. - CGError err = kCGErrorSuccess; - - CGRect globalDeviceBounds = CGDisplayBounds(displayID); - - // Set unknown mouse location, if needed. - if ((mouseLastX == sun_lwawt_macosx_CRobot_MOUSE_LOCATION_UNKNOWN) || - (mouseLastY == sun_lwawt_macosx_CRobot_MOUSE_LOCATION_UNKNOWN)) - { - CGEventRef event = CGEventCreate(NULL); - if (event == NULL) { - return; - } - - CGPoint globalPos = CGEventGetLocation(event); - CFRelease(event); - - // Normalize the coords within this display device, as - // per Robot rules. - if (globalPos.x < CGRectGetMinX(globalDeviceBounds)) { - globalPos.x = CGRectGetMinX(globalDeviceBounds); - } - else if (globalPos.x > CGRectGetMaxX(globalDeviceBounds)) { - globalPos.x = CGRectGetMaxX(globalDeviceBounds); - } - - if (globalPos.y < CGRectGetMinY(globalDeviceBounds)) { - globalPos.y = CGRectGetMinY(globalDeviceBounds); - } - else if (globalPos.y > CGRectGetMaxY(globalDeviceBounds)) { - globalPos.y = CGRectGetMaxY(globalDeviceBounds); - } - - mouseLastX = (jint)globalPos.x; - mouseLastY = (jint)globalPos.y; - } - // volatile, otherwise it warns that it might be clobbered by 'longjmp' volatile CGPoint point; point.x = mouseLastX; point.y = mouseLastY; --- 144,157 ---- { JNF_COCOA_ENTER(env); // This is the native method called when Robot mouse events occur. // The CRobot tracks the mouse position, and which button was ! // pressed. The peer also tracks the mouse button desired state, // the appropriate key modifier state, and whether the mouse action // is simply a mouse move with no mouse button state changes. // volatile, otherwise it warns that it might be clobbered by 'longjmp' volatile CGPoint point; point.x = mouseLastX; point.y = mouseLastY;