Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
Dragonwell11
提交
10a4eb85
D
Dragonwell11
项目概览
LinuxSuRen
/
Dragonwell11
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dragonwell11
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
10a4eb85
编写于
3月 16, 2020
作者:
S
serb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8226806: [macOS 10.14] Methods of Java Robot should be called from appropriate thread
Reviewed-by: psadhukhan, prr
上级
2d2fc8ef
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
149 addition
and
54 deletion
+149
-54
src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m
src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m
+60
-54
test/jdk/java/awt/Robot/NonEmptyErrorStream.java
test/jdk/java/awt/Robot/NonEmptyErrorStream.java
+89
-0
未找到文件。
src/java.desktop/macosx/native/libawt_lwawt/awt/CRobot.m
浏览文件 @
10a4eb85
/*
* Copyright (c) 2016, 20
18
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 20
20
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -23,7 +23,6 @@
* questions.
*/
#import "jni_util.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
...
...
@@ -35,6 +34,7 @@
#import "java_awt_event_InputEvent.h"
#import "java_awt_event_KeyEvent.h"
#import "sizecalc.h"
#import "ThreadUtilities.h"
// Starting number for event numbers generated by Robot.
// Apple docs don't mention at all what are the requirements
...
...
@@ -97,38 +97,40 @@ Java_sun_lwawt_macosx_CRobot_initRobot
// Always set all states, in case Apple ever changes default behaviors.
static
int
setupDone
=
0
;
if
(
!
setupDone
)
{
int
i
;
jint
*
tmp
;
jboolean
copy
=
JNI_FALSE
;
setupDone
=
1
;
// Don't block local events after posting ours
CGSetLocalEventsSuppressionInterval
(
0
.
0
);
// Let our event's modifier key state blend with local hardware events
CGEnableEventStateCombining
(
TRUE
);
// Don't let our events block local hardware events
CGSetLocalEventsFilterDuringSupressionState
(
kCGEventFilterMaskPermitAllEvents
,
kCGEventSupressionStateSupressionInterval
);
CGSetLocalEventsFilterDuringSupressionState
(
kCGEventFilterMaskPermitAllEvents
,
kCGEventSupressionStateRemoteMouseDrag
);
gsClickCount
=
0
;
gsLastClickTime
=
0
;
gsEventNumber
=
ROBOT_EVENT_NUMBER_START
;
[
ThreadUtilities
performOnMainThreadWaiting
:
NO
block
:
^
(){
int
i
;
jint
*
tmp
;
jboolean
copy
=
JNI_FALSE
;
setupDone
=
1
;
// Don't block local events after posting ours
CGSetLocalEventsSuppressionInterval
(
0
.
0
);
// Let our event's modifier key state blend with local hardware events
CGEnableEventStateCombining
(
TRUE
);
// Don't let our events block local hardware events
CGSetLocalEventsFilterDuringSupressionState
(
kCGEventFilterMaskPermitAllEvents
,
kCGEventSupressionStateSupressionInterval
);
CGSetLocalEventsFilterDuringSupressionState
(
kCGEventFilterMaskPermitAllEvents
,
kCGEventSupressionStateRemoteMouseDrag
);
gsButtonEventNumber
=
(
int
*
)
SAFE_SIZE_ARRAY_ALLOC
(
malloc
,
sizeof
(
int
),
gNumberOfButtons
);
if
(
gsButtonEventNumber
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
NULL
);
return
;
}
gsClickCount
=
0
;
gsLastClickTime
=
0
;
gsEventNumber
=
ROBOT_EVENT_NUMBER_START
;
for
(
i
=
0
;
i
<
gNumberOfButtons
;
++
i
)
{
gsButtonEventNumber
[
i
]
=
ROBOT_EVENT_NUMBER_START
;
}
gsButtonEventNumber
=
(
int
*
)
SAFE_SIZE_ARRAY_ALLOC
(
malloc
,
sizeof
(
int
),
gNumberOfButtons
);
if
(
gsButtonEventNumber
==
NULL
)
{
JNU_ThrowOutOfMemoryError
(
env
,
NULL
);
return
;
}
for
(
i
=
0
;
i
<
gNumberOfButtons
;
++
i
)
{
gsButtonEventNumber
[
i
]
=
ROBOT_EVENT_NUMBER_START
;
}
}];
}
}
...
...
@@ -239,14 +241,15 @@ JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CRobot_mouseWheel
(
JNIEnv
*
env
,
jobject
peer
,
jint
wheelAmt
)
{
CGEventRef
event
=
CGEventCreateScrollWheelEvent
(
NULL
,
kCGScrollEventUnitLine
,
k_JAVA_ROBOT_WHEEL_COUNT
,
wheelAmt
);
if
(
event
!=
NULL
)
{
CGEventPost
(
kCGSessionEventTap
,
event
);
CFRelease
(
event
);
}
[
ThreadUtilities
performOnMainThreadWaiting
:
YES
block
:
^
(){
CGEventRef
event
=
CGEventCreateScrollWheelEvent
(
NULL
,
kCGScrollEventUnitLine
,
k_JAVA_ROBOT_WHEEL_COUNT
,
wheelAmt
);
if
(
event
!=
NULL
)
{
CGEventPost
(
kCGSessionEventTap
,
event
);
CFRelease
(
event
);
}
}];
}
/*
...
...
@@ -258,13 +261,14 @@ JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CRobot_keyEvent
(
JNIEnv
*
env
,
jobject
peer
,
jint
javaKeyCode
,
jboolean
keyPressed
)
{
CGKeyCode
keyCode
=
GetCGKeyCode
(
javaKeyCode
);
CGEventRef
event
=
CGEventCreateKeyboardEvent
(
NULL
,
keyCode
,
keyPressed
);
if
(
event
!=
NULL
)
{
CGEventPost
(
kCGSessionEventTap
,
event
);
CFRelease
(
event
);
}
[
ThreadUtilities
performOnMainThreadWaiting
:
YES
block
:
^
(){
CGKeyCode
keyCode
=
GetCGKeyCode
(
javaKeyCode
);
CGEventRef
event
=
CGEventCreateKeyboardEvent
(
NULL
,
keyCode
,
keyPressed
);
if
(
event
!=
NULL
)
{
CGEventPost
(
kCGSessionEventTap
,
event
);
CFRelease
(
event
);
}
}];
}
/*
...
...
@@ -333,13 +337,15 @@ Java_sun_lwawt_macosx_CRobot_nativeGetScreenPixels
static
void
PostMouseEvent
(
const
CGPoint
point
,
CGMouseButton
button
,
CGEventType
type
,
int
clickCount
,
int
eventNumber
)
{
CGEventRef
mouseEvent
=
CGEventCreateMouseEvent
(
NULL
,
type
,
point
,
button
);
if
(
mouseEvent
!=
NULL
)
{
CGEventSetIntegerValueField
(
mouseEvent
,
kCGMouseEventClickState
,
clickCount
);
CGEventSetIntegerValueField
(
mouseEvent
,
kCGMouseEventNumber
,
eventNumber
);
CGEventPost
(
kCGSessionEventTap
,
mouseEvent
);
CFRelease
(
mouseEvent
);
}
[
ThreadUtilities
performOnMainThreadWaiting
:
YES
block
:
^
(){
CGEventRef
mouseEvent
=
CGEventCreateMouseEvent
(
NULL
,
type
,
point
,
button
);
if
(
mouseEvent
!=
NULL
)
{
CGEventSetIntegerValueField
(
mouseEvent
,
kCGMouseEventClickState
,
clickCount
);
CGEventSetIntegerValueField
(
mouseEvent
,
kCGMouseEventNumber
,
eventNumber
);
CGEventPost
(
kCGSessionEventTap
,
mouseEvent
);
CFRelease
(
mouseEvent
);
}
}];
}
static
inline
CGKeyCode
GetCGKeyCode
(
jint
javaKeyCode
)
...
...
test/jdk/java/awt/Robot/NonEmptyErrorStream.java
0 → 100644
浏览文件 @
10a4eb85
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.Frame
;
import
java.awt.Robot
;
import
java.awt.*
;
import
java.awt.event.InputEvent
;
import
java.awt.event.KeyEvent
;
import
java.util.concurrent.TimeUnit
;
import
jdk.test.lib.process.OutputAnalyzer
;
import
jdk.test.lib.process.ProcessTools
;
/**
* @test
* @bug 8226806
* @key headful
* @library /test/lib
* @summary checks for unexpected output in stderr and stdout
*/
public
final
class
NonEmptyErrorStream
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
)
{
ProcessBuilder
pb
=
ProcessTools
.
createJavaProcessBuilder
(
NonEmptyErrorStream
.
class
.
getSimpleName
(),
"run"
);
Process
p
=
pb
.
start
();
OutputAnalyzer
output
=
new
OutputAnalyzer
(
p
);
p
.
waitFor
(
20
,
TimeUnit
.
SECONDS
);
p
.
destroy
();
output
.
shouldHaveExitValue
(
0
);
output
.
stdoutShouldBeEmpty
();
output
.
stderrShouldBeEmpty
();
return
;
}
Frame
frame
=
new
Frame
();
frame
.
setSize
(
400
,
300
);
frame
.
setLocationRelativeTo
(
null
);
frame
.
setVisible
(
true
);
Robot
robot
=
new
Robot
();
robot
.
setAutoDelay
(
50
);
robot
.
waitForIdle
();
frame
.
toFront
();
Rectangle
rect
=
frame
.
getBounds
();
int
x
=
(
int
)
rect
.
getCenterX
();
int
y
=
(
int
)
rect
.
getCenterY
();
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
robot
.
getPixelColor
(
x
,
y
);
robot
.
createScreenCapture
(
rect
);
}
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
robot
.
mouseMove
(
x
+
50
,
y
+
50
);
robot
.
mouseMove
(
x
-
50
,
y
-
50
);
}
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
robot
.
keyPress
(
KeyEvent
.
VK_ESCAPE
);
robot
.
keyRelease
(
KeyEvent
.
VK_ESCAPE
);
}
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
robot
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_MASK
);
}
robot
.
waitForIdle
();
frame
.
dispose
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录