Compare commits

...

3 Commits

Author SHA1 Message Date
Elena Sayapina
5ba16da818 JBR-2630 Typing speed in IDE editor was dropped after switching to 11.0.8
New version of the fix as 0c16f30a caused java.security.AccessControlException on pre-commit.
Priviledged action is now ised to obtain sun.awt.osx.RobotSafeDelayMillis property value.
2020-08-05 23:01:02 +07:00
Elena Sayapina
c559bd3f9f Revert "JBR-2630 Typing speed in IDE editor was dropped after switching to 11.0.8" due to java.security.AccessControlException on pre-commit testing
This reverts commit 0c16f30a
2020-08-05 22:55:28 +07:00
Elena Sayapina
0c16f30ab0 JBR-2630 Typing speed in IDE editor was dropped after switching to 11.0.8
Introduced sun.awt.osx.RobotSafeDelayMillis property to control macOS specific safe delay for Robot methods.
50 ms safe delay was initially hardcoded in 3862142d (JDK-8242174: [macos] The NestedModelessDialogTest test make the macOS unstable) which affected performance tests execution.
2020-08-05 11:04:00 +07:00
2 changed files with 14 additions and 5 deletions

View File

@@ -31,10 +31,12 @@ import java.awt.Robot;
import java.awt.peer.RobotPeer;
import sun.awt.CGraphicsDevice;
import sun.security.action.GetIntegerAction;
final class CRobot implements RobotPeer {
private static final int MOUSE_LOCATION_UNKNOWN = -1;
private static final int DEFAULT_SAFE_DELAY_MILLIS = 50;
private final CGraphicsDevice fDevice;
private int mouseLastX = MOUSE_LOCATION_UNKNOWN;
@@ -51,7 +53,12 @@ final class CRobot implements RobotPeer {
*/
public CRobot(Robot r, CGraphicsDevice d) {
fDevice = d;
initRobot();
int safeDelayMillis = GetIntegerAction.privilegedGetProperty(
"sun.awt.osx.RobotSafeDelayMillis", DEFAULT_SAFE_DELAY_MILLIS);
if (safeDelayMillis < 0) {
safeDelayMillis = DEFAULT_SAFE_DELAY_MILLIS;
}
initRobot(safeDelayMillis);
}
@Override
@@ -193,7 +200,7 @@ final class CRobot implements RobotPeer {
return c;
}
private native void initRobot();
private native void initRobot(int safeDelayMillis);
private native void mouseEvent(int lastX, int lastY, int buttonsState,
boolean isButtonsDownState,
boolean isMouseMove);

View File

@@ -68,6 +68,7 @@ static NSTimeInterval gsLastClickTime;
static int gsEventNumber;
static int* gsButtonEventNumber;
static NSTimeInterval gNextKeyEventTime;
static NSTimeInterval safeDelay;
static inline CGKeyCode GetCGKeyCode(jint javaKeyCode);
@@ -104,17 +105,17 @@ static inline void autoDelay(BOOL isMove) {
[NSThread sleepForTimeInterval:delay];
}
}
gNextKeyEventTime = [[NSDate date] timeIntervalSinceReferenceDate] + 0.050;
gNextKeyEventTime = [[NSDate date] timeIntervalSinceReferenceDate] + safeDelay;
}
/*
* Class: sun_lwawt_macosx_CRobot
* Method: initRobot
* Signature: (V)V
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CRobot_initRobot
(JNIEnv *env, jobject peer)
(JNIEnv *env, jobject peer, jint safeDelayMillis)
{
// Set things up to let our app act like a synthetic keyboard and mouse.
// Always set all states, in case Apple ever changes default behaviors.
@@ -143,6 +144,7 @@ Java_sun_lwawt_macosx_CRobot_initRobot
gsClickCount = 0;
gsLastClickTime = 0;
gNextKeyEventTime = 0;
safeDelay = (NSTimeInterval)safeDelayMillis/1000;
gsEventNumber = ROBOT_EVENT_NUMBER_START;
gsButtonEventNumber = (int*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(int), gNumberOfButtons);