JDK-4288230 : Robot does not work on the windows multiScreen environment
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_95
  • CPU: generic
  • Submitted: 1999-11-05
  • Updated: 2018-05-09
  • Resolved: 1999-12-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.3.0 kestrelFixed
Related Reports
Relates :  
Description
Robot should support new multiscreen api( bug rfe: 4251286 ), but
robot does not recognize the screen devices in the windows.
In our test, by using both constructor Robot() and Robot( ScreenDevice ), 
Robot.mouseMove() can not move mouse to the second or the third monitor.
 
Test file is attached.


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: kestrel FIXED IN: kestrel INTEGRATED IN: kestrel VERIFIED IN: kestrel
14-06-2004

EVALUATION should be filed by ###@###.### ###@###.### 1999-11-30 Name: dmC97671 Date: 12/01/99 ###@###.### 1. GraphicsDevice is not passed to Robot peer contructor so Robot always uses Virtual screen coordinates; 2. mouse_event can't move the mouse through absolute movements to another display, the reasons and the workaround are described in MSDN Q193003. ======================================================================
11-06-2004

SUGGESTED FIX Name: dmC97671 Date: 12/01/99 ###@###.### ------- awt_Robot.cpp ------- *** /tmp/d0ARdSG Wed Nov 24 10:24:27 1999 --- awt_Robot.cpp Wed Nov 24 10:24:24 1999 *************** *** 17,22 **** --- 17,23 ---- #include "awt_Robot.h" #include "sun_awt_windows_WRobotPeer.h" #include "java_awt_event_InputEvent.h" + #include <winuser.h> static const int MOUSE_MAX = 65535; *************** *** 38,52 **** env->DeleteWeakGlobalRef(m_peerObject); } void AwtRobot::MouseMove( jint x, jint y) { ! DWORD dwFlags = MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE; ! // mouse coordinate space is (0,0,64k,64k) so map ! // the screen coordinates to mouse coordinates ! int mousex = x * MOUSE_MAX/::GetSystemMetrics(SM_CXSCREEN); ! int mousey = y * MOUSE_MAX/::GetSystemMetrics(SM_CYSCREEN); ! mouse_event(dwFlags, mousex, mousey, 0, 0 ); } void AwtRobot::MousePress( jint buttonMask ) --- 39,82 ---- env->DeleteWeakGlobalRef(m_peerObject); } + #ifndef SPI_GETMOUSESPEED + #define SPI_GETMOUSESPEED 112 + #endif + + #ifndef SPI_SETMOUSESPEED + #define SPI_SETMOUSESPEED 113 + #endif + void AwtRobot::MouseMove( jint x, jint y) { ! // Fix for Bug 4288230. See Q193003 from MSDN. ! int oldAccel[3], newAccel[3], oldSpeed, newSpeed; ! BOOL bResult; ! // The following values set mouse ballistics to 1 mickey/pixel. ! newAccel[0] = 0; ! newAccel[1] = 0; ! newAccel[2] = 0; ! newSpeed = 1; ! ! // Save the Current Mouse Acceleration Constants ! bResult = SystemParametersInfo(SPI_GETMOUSE,0,oldAccel,0); ! bResult = SystemParametersInfo(SPI_GETMOUSESPEED, 0, &oldSpeed,0); ! // Set the new Mouse Acceleration Constants (Disabled). ! bResult = SystemParametersInfo(SPI_SETMOUSE,0,newAccel,SPIF_SENDCHANGE); ! bResult = SystemParametersInfo(SPI_SETMOUSESPEED, 0, &newSpeed,SPIF_SENDCHANGE); ! ! POINT curPos; ! ::GetCursorPos(&curPos); ! x -= curPos.x; ! y -= curPos.y; ! ! mouse_event(MOUSEEVENTF_MOVE,x,y,0,0); ! // Move the cursor to the desired coordinates. ! ! // Restore the old Mouse Acceleration Constants. ! bResult = SystemParametersInfo(SPI_SETMOUSE,0, oldAccel, SPIF_SENDCHANGE); ! bResult = SystemParametersInfo(SPI_SETMOUSESPEED, 0, &oldSpeed, SPIF_SENDCHANGE); } void AwtRobot::MousePress( jint buttonMask ) *************** *** 233,239 **** CATCH_BAD_ALLOC; } ! JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer_mouseMove( JNIEnv * env, jobject self, jint x, jint y) { TRY; --- 263,269 ---- CATCH_BAD_ALLOC; } ! JNIEXPORT void JNICALL Java_sun_awt_windows_WRobotPeer_mouseMoveImpl( JNIEnv * env, jobject self, jint x, jint y) { TRY; ------- WRobotPeer.java ------- *** /tmp/d04fAiC Tue Nov 23 12:25:32 1999 --- WRobotPeer.java Tue Nov 23 12:25:22 1999 *************** *** 19,27 **** --- 19,38 ---- class WRobotPeer extends WObjectPeer implements RobotPeer { + private Point offset = new Point(0, 0); + WRobotPeer() { create(); } + WRobotPeer(GraphicsDevice screen) { + if ( screen != null ) { + GraphicsConfiguration conf = screen.getDefaultConfiguration(); + if ( conf != null ) { + offset = conf.getBounds().getLocation(); + } + } + create(); + } private synchronized native void _dispose(); *************** *** 30,36 **** } public native void create(); ! public native void mouseMove(int x, int y); public native void mousePress( int buttons ); public native void mouseRelease( int buttons ); --- 41,52 ---- } public native void create(); ! public native void mouseMoveImpl(int x, int y); ! public void mouseMove(int x, int y) { ! x += offset.x; ! y += offset.y; ! mouseMoveImpl(x, y); ! } public native void mousePress( int buttons ); public native void mouseRelease( int buttons ); ------- WToolkit.java ------- *** /tmp/dlKl8x_ Tue Nov 23 11:43:32 1999 --- WToolkit.java Tue Nov 23 11:43:21 1999 *************** *** 332,338 **** // (target is unused for now) // Robot's don't need to go in the peer map since // they're not Component's ! return new WRobotPeer(); } public WEmbeddedFramePeer createEmbeddedFrame(WEmbeddedFrame target) { --- 332,338 ---- // (target is unused for now) // Robot's don't need to go in the peer map since // they're not Component's ! return new WRobotPeer(screen); } public WEmbeddedFramePeer createEmbeddedFrame(WEmbeddedFrame target) { ======================================================================
11-06-2004

PUBLIC COMMENTS After the bug fixing, the mouse can move to the second monitor.
10-06-2004