Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
83a65790
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
83a65790
编写于
7月 30, 2014
作者:
A
anashaty
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8046495: KeyEvent can not be accepted in quick mouse clicking
Reviewed-by: art, pchelko
上级
55797926
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
146 addition
and
26 deletion
+146
-26
src/windows/native/sun/windows/awt_Component.cpp
src/windows/native/sun/windows/awt_Component.cpp
+6
-18
src/windows/native/sun/windows/awt_TrayIcon.cpp
src/windows/native/sun/windows/awt_TrayIcon.cpp
+8
-8
test/java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java
...ava/awt/event/InputEvent/EventWhenTest/EventWhenTest.java
+132
-0
未找到文件。
src/windows/native/sun/windows/awt_Component.cpp
浏览文件 @
83a65790
...
@@ -2141,19 +2141,7 @@ namespace TimeHelper {
...
@@ -2141,19 +2141,7 @@ namespace TimeHelper {
}
}
jlong
getMessageTimeUTC
()
{
jlong
getMessageTimeUTC
()
{
return
windowsToUTC
(
getMessageTimeWindows
());
return
::
JVM_CurrentTimeMillis
(
NULL
,
0
);
}
// If calling order of GetTickCount and JVM_CurrentTimeMillis
// is swapped, it would sometimes give different result.
// Anyway, we would not always have determinism
// and sortedness of time conversion here (due to Windows's
// timers peculiarities). Having some euristic algorithm might
// help here.
jlong
windowsToUTC
(
DWORD
windowsTime
)
{
jlong
offset
=
::
GetTickCount
()
-
windowsTime
;
jlong
jvm_time
=
::
JVM_CurrentTimeMillis
(
NULL
,
0
);
return
jvm_time
-
offset
;
}
}
}
//TimeHelper
}
//TimeHelper
...
@@ -3578,7 +3566,7 @@ MsgRouting AwtComponent::WmKeyDown(UINT wkey, UINT repCnt,
...
@@ -3578,7 +3566,7 @@ MsgRouting AwtComponent::WmKeyDown(UINT wkey, UINT repCnt,
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_PRESSED
,
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_PRESSED
,
TimeHelper
::
windowsToUTC
(
msg
.
time
),
jkey
,
character
,
TimeHelper
::
getMessageTimeUTC
(
),
jkey
,
character
,
modifiers
,
keyLocation
,
(
jlong
)
wkey
,
&
msg
);
modifiers
,
keyLocation
,
(
jlong
)
wkey
,
&
msg
);
// bugid 4724007: Windows does not create a WM_CHAR for the Del key
// bugid 4724007: Windows does not create a WM_CHAR for the Del key
...
@@ -3588,7 +3576,7 @@ MsgRouting AwtComponent::WmKeyDown(UINT wkey, UINT repCnt,
...
@@ -3588,7 +3576,7 @@ MsgRouting AwtComponent::WmKeyDown(UINT wkey, UINT repCnt,
// for Java - we don't want Windows trying to process it).
// for Java - we don't want Windows trying to process it).
if
(
jkey
==
java_awt_event_KeyEvent_VK_DELETE
)
{
if
(
jkey
==
java_awt_event_KeyEvent_VK_DELETE
)
{
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_TYPED
,
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_TYPED
,
TimeHelper
::
windowsToUTC
(
msg
.
time
),
TimeHelper
::
getMessageTimeUTC
(
),
java_awt_event_KeyEvent_VK_UNDEFINED
,
java_awt_event_KeyEvent_VK_UNDEFINED
,
character
,
modifiers
,
character
,
modifiers
,
java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN
,
(
jlong
)
0
);
java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN
,
(
jlong
)
0
);
...
@@ -3620,7 +3608,7 @@ MsgRouting AwtComponent::WmKeyUp(UINT wkey, UINT repCnt,
...
@@ -3620,7 +3608,7 @@ MsgRouting AwtComponent::WmKeyUp(UINT wkey, UINT repCnt,
UpdateDynPrimaryKeymap
(
wkey
,
jkey
,
keyLocation
,
modifiers
);
UpdateDynPrimaryKeymap
(
wkey
,
jkey
,
keyLocation
,
modifiers
);
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_RELEASED
,
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_RELEASED
,
TimeHelper
::
windowsToUTC
(
msg
.
time
),
jkey
,
character
,
TimeHelper
::
getMessageTimeUTC
(
),
jkey
,
character
,
modifiers
,
keyLocation
,
(
jlong
)
wkey
,
&
msg
);
modifiers
,
keyLocation
,
(
jlong
)
wkey
,
&
msg
);
return
mrConsume
;
return
mrConsume
;
}
}
...
@@ -3665,7 +3653,7 @@ MsgRouting AwtComponent::WmIMEChar(UINT character, UINT repCnt, UINT flags, BOOL
...
@@ -3665,7 +3653,7 @@ MsgRouting AwtComponent::WmIMEChar(UINT character, UINT repCnt, UINT flags, BOOL
jint
modifiers
=
GetJavaModifiers
();
jint
modifiers
=
GetJavaModifiers
();
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_TYPED
,
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_TYPED
,
TimeHelper
::
windowsToUTC
(
msg
.
time
),
TimeHelper
::
getMessageTimeUTC
(
),
java_awt_event_KeyEvent_VK_UNDEFINED
,
java_awt_event_KeyEvent_VK_UNDEFINED
,
unicodeChar
,
modifiers
,
unicodeChar
,
modifiers
,
java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN
,
(
jlong
)
0
,
java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN
,
(
jlong
)
0
,
...
@@ -3734,7 +3722,7 @@ MsgRouting AwtComponent::WmChar(UINT character, UINT repCnt, UINT flags,
...
@@ -3734,7 +3722,7 @@ MsgRouting AwtComponent::WmChar(UINT character, UINT repCnt, UINT flags,
InitMessage
(
&
msg
,
message
,
character
,
InitMessage
(
&
msg
,
message
,
character
,
MAKELPARAM
(
repCnt
,
flags
));
MAKELPARAM
(
repCnt
,
flags
));
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_TYPED
,
SendKeyEventToFocusOwner
(
java_awt_event_KeyEvent_KEY_TYPED
,
TimeHelper
::
windowsToUTC
(
msg
.
time
),
TimeHelper
::
getMessageTimeUTC
(
),
java_awt_event_KeyEvent_VK_UNDEFINED
,
java_awt_event_KeyEvent_VK_UNDEFINED
,
unicodeChar
,
modifiers
,
unicodeChar
,
modifiers
,
java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN
,
(
jlong
)
0
,
java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN
,
(
jlong
)
0
,
...
...
src/windows/native/sun/windows/awt_TrayIcon.cpp
浏览文件 @
83a65790
...
@@ -325,7 +325,7 @@ static int clickCount = 0;
...
@@ -325,7 +325,7 @@ static int clickCount = 0;
MsgRouting
AwtTrayIcon
::
WmMouseDown
(
UINT
flags
,
int
x
,
int
y
,
int
button
)
MsgRouting
AwtTrayIcon
::
WmMouseDown
(
UINT
flags
,
int
x
,
int
y
,
int
button
)
{
{
jlong
now
=
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
);
jlong
now
=
TimeHelper
::
getMessageTimeUTC
(
);
jint
javaModif
=
AwtComponent
::
GetJavaModifiers
();
jint
javaModif
=
AwtComponent
::
GetJavaModifiers
();
if
(
lastClickTrIc
==
this
&&
if
(
lastClickTrIc
==
this
&&
...
@@ -361,14 +361,14 @@ MsgRouting AwtTrayIcon::WmMouseUp(UINT flags, int x, int y, int button)
...
@@ -361,14 +361,14 @@ MsgRouting AwtTrayIcon::WmMouseUp(UINT flags, int x, int y, int button)
MSG
msg
;
MSG
msg
;
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
SendMouseEvent
(
java_awt_event_MouseEvent_MOUSE_RELEASED
,
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
),
SendMouseEvent
(
java_awt_event_MouseEvent_MOUSE_RELEASED
,
TimeHelper
::
getMessageTimeUTC
(
),
x
,
y
,
AwtComponent
::
GetJavaModifiers
(),
clickCount
,
x
,
y
,
AwtComponent
::
GetJavaModifiers
(),
clickCount
,
(
AwtComponent
::
GetButton
(
button
)
==
java_awt_event_MouseEvent_BUTTON3
?
(
AwtComponent
::
GetButton
(
button
)
==
java_awt_event_MouseEvent_BUTTON3
?
TRUE
:
FALSE
),
AwtComponent
::
GetButton
(
button
),
&
msg
);
TRUE
:
FALSE
),
AwtComponent
::
GetButton
(
button
),
&
msg
);
if
((
m_mouseButtonClickAllowed
&
AwtComponent
::
GetButtonMK
(
button
))
!=
0
)
{
// No up-button in the drag-state
if
((
m_mouseButtonClickAllowed
&
AwtComponent
::
GetButtonMK
(
button
))
!=
0
)
{
// No up-button in the drag-state
SendMouseEvent
(
java_awt_event_MouseEvent_MOUSE_CLICKED
,
SendMouseEvent
(
java_awt_event_MouseEvent_MOUSE_CLICKED
,
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
),
x
,
y
,
AwtComponent
::
GetJavaModifiers
(),
TimeHelper
::
getMessageTimeUTC
(
),
x
,
y
,
AwtComponent
::
GetJavaModifiers
(),
clickCount
,
JNI_FALSE
,
AwtComponent
::
GetButton
(
button
));
clickCount
,
JNI_FALSE
,
AwtComponent
::
GetButton
(
button
));
}
}
m_mouseButtonClickAllowed
&=
~
AwtComponent
::
GetButtonMK
(
button
);
// Exclude the up-button from the drag-state
m_mouseButtonClickAllowed
&=
~
AwtComponent
::
GetButtonMK
(
button
);
// Exclude the up-button from the drag-state
...
@@ -395,7 +395,7 @@ MsgRouting AwtTrayIcon::WmMouseMove(UINT flags, int x, int y)
...
@@ -395,7 +395,7 @@ MsgRouting AwtTrayIcon::WmMouseMove(UINT flags, int x, int y)
if
((
flags
&
ALL_MK_BUTTONS
)
!=
0
)
{
if
((
flags
&
ALL_MK_BUTTONS
)
!=
0
)
{
m_mouseButtonClickAllowed
=
0
;
m_mouseButtonClickAllowed
=
0
;
}
else
{
}
else
{
SendMouseEvent
(
java_awt_event_MouseEvent_MOUSE_MOVED
,
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
),
x
,
y
,
SendMouseEvent
(
java_awt_event_MouseEvent_MOUSE_MOVED
,
TimeHelper
::
getMessageTimeUTC
(
),
x
,
y
,
AwtComponent
::
GetJavaModifiers
(),
0
,
JNI_FALSE
,
AwtComponent
::
GetJavaModifiers
(),
0
,
JNI_FALSE
,
java_awt_event_MouseEvent_NOBUTTON
,
&
msg
);
java_awt_event_MouseEvent_NOBUTTON
,
&
msg
);
}
}
...
@@ -408,7 +408,7 @@ MsgRouting AwtTrayIcon::WmBalloonUserClick(UINT flags, int x, int y)
...
@@ -408,7 +408,7 @@ MsgRouting AwtTrayIcon::WmBalloonUserClick(UINT flags, int x, int y)
if
(
AwtComponent
::
GetJavaModifiers
()
&
java_awt_event_InputEvent_BUTTON1_DOWN_MASK
)
{
if
(
AwtComponent
::
GetJavaModifiers
()
&
java_awt_event_InputEvent_BUTTON1_DOWN_MASK
)
{
MSG
msg
;
MSG
msg
;
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
SendActionEvent
(
java_awt_event_ActionEvent_ACTION_PERFORMED
,
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
),
SendActionEvent
(
java_awt_event_ActionEvent_ACTION_PERFORMED
,
TimeHelper
::
getMessageTimeUTC
(
),
AwtComponent
::
GetJavaModifiers
(),
&
msg
);
AwtComponent
::
GetJavaModifiers
(),
&
msg
);
}
}
return
mrConsume
;
return
mrConsume
;
...
@@ -417,14 +417,14 @@ MsgRouting AwtTrayIcon::WmBalloonUserClick(UINT flags, int x, int y)
...
@@ -417,14 +417,14 @@ MsgRouting AwtTrayIcon::WmBalloonUserClick(UINT flags, int x, int y)
MsgRouting
AwtTrayIcon
::
WmKeySelect
(
UINT
flags
,
int
x
,
int
y
)
MsgRouting
AwtTrayIcon
::
WmKeySelect
(
UINT
flags
,
int
x
,
int
y
)
{
{
static
jlong
lastKeySelectTime
=
0
;
static
jlong
lastKeySelectTime
=
0
;
jlong
now
=
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
);
jlong
now
=
TimeHelper
::
getMessageTimeUTC
(
);
// If a user selects a notify icon with the ENTER key,
// If a user selects a notify icon with the ENTER key,
// Shell 5.0 sends double NIN_KEYSELECT notification.
// Shell 5.0 sends double NIN_KEYSELECT notification.
if
(
lastKeySelectTime
!=
now
)
{
if
(
lastKeySelectTime
!=
now
)
{
MSG
msg
;
MSG
msg
;
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
SendActionEvent
(
java_awt_event_ActionEvent_ACTION_PERFORMED
,
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
),
SendActionEvent
(
java_awt_event_ActionEvent_ACTION_PERFORMED
,
TimeHelper
::
getMessageTimeUTC
(
),
AwtComponent
::
GetJavaModifiers
(),
&
msg
);
AwtComponent
::
GetJavaModifiers
(),
&
msg
);
}
}
lastKeySelectTime
=
now
;
lastKeySelectTime
=
now
;
...
@@ -441,7 +441,7 @@ MsgRouting AwtTrayIcon::WmSelect(UINT flags, int x, int y)
...
@@ -441,7 +441,7 @@ MsgRouting AwtTrayIcon::WmSelect(UINT flags, int x, int y)
if
(
clickCount
==
2
)
{
if
(
clickCount
==
2
)
{
MSG
msg
;
MSG
msg
;
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
AwtComponent
::
InitMessage
(
&
msg
,
lastMessage
,
flags
,
MAKELPARAM
(
x
,
y
),
x
,
y
);
SendActionEvent
(
java_awt_event_ActionEvent_ACTION_PERFORMED
,
TimeHelper
::
windowsToUTC
(
::
GetTickCount
()
),
SendActionEvent
(
java_awt_event_ActionEvent_ACTION_PERFORMED
,
TimeHelper
::
getMessageTimeUTC
(
),
AwtComponent
::
GetJavaModifiers
(),
&
msg
);
AwtComponent
::
GetJavaModifiers
(),
&
msg
);
}
}
return
mrConsume
;
return
mrConsume
;
...
...
test/java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java
0 → 100644
浏览文件 @
83a65790
/*
* Copyright (c) 2014, 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
sun.awt.SunToolkit
;
import
java.awt.*
;
import
java.awt.event.AWTEventListener
;
import
java.awt.event.InputEvent
;
import
java.awt.event.KeyEvent
;
import
java.awt.event.MouseEvent
;
/*
* @test
* @bug 8046495
* @summary Verifies that mouse/key events has always increasing 'when' timestamps
* @author Anton Nashatyrev
* @run main EventWhenTest
*/
public
class
EventWhenTest
{
private
static
volatile
int
eventsCount
=
0
;
private
static
volatile
boolean
failed
=
false
;
static
{
Toolkit
.
getDefaultToolkit
().
addAWTEventListener
(
new
AWTEventListener
()
{
long
lastWhen
=
0
;
@Override
public
void
eventDispatched
(
AWTEvent
event
)
{
long
curWhen
;
if
(
event
instanceof
KeyEvent
)
{
curWhen
=
((
KeyEvent
)
event
).
getWhen
();
}
else
if
(
event
instanceof
MouseEvent
)
{
curWhen
=
((
MouseEvent
)
event
).
getWhen
();
}
else
{
return
;
}
eventsCount
++;
if
(
curWhen
<
lastWhen
)
{
System
.
err
.
println
(
"FAILED: "
+
curWhen
+
" < "
+
lastWhen
+
" for "
+
event
);
failed
=
true
;
}
else
{
lastWhen
=
curWhen
;
}
}
},
AWTEvent
.
KEY_EVENT_MASK
|
AWTEvent
.
MOUSE_EVENT_MASK
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
Frame
frame
=
new
Frame
();
try
{
Button
b
=
new
Button
(
"Button"
);
frame
.
setBounds
(
300
,
300
,
300
,
300
);
frame
.
add
(
b
);
frame
.
setVisible
(
true
);
toolkit
.
realSync
();
Robot
robot
=
new
Robot
();
robot
.
mouseMove
((
int
)
frame
.
getLocationOnScreen
().
getX
()
+
150
,
(
int
)
frame
.
getLocationOnScreen
().
getY
()
+
150
);
eventsCount
=
0
;
System
.
out
.
println
(
"Clicking mouse..."
);
for
(
int
i
=
0
;
i
<
300
&&
!
failed
;
i
++)
{
robot
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_MASK
);
Thread
.
sleep
(
10
);
b
.
setLabel
(
"Click: "
+
i
);
}
if
(
eventsCount
==
0
)
{
throw
new
RuntimeException
(
"No events were received"
);
}
if
(
failed
)
{
throw
new
RuntimeException
(
"Test failed."
);
}
System
.
out
.
println
(
"Clicking mouse done: "
+
eventsCount
+
" events."
);
b
.
requestFocusInWindow
();
toolkit
.
realSync
();
eventsCount
=
0
;
System
.
out
.
println
(
"Typing a key..."
);
for
(
int
i
=
0
;
i
<
300
&&
!
failed
;
i
++)
{
robot
.
keyPress
(
KeyEvent
.
VK_A
);
robot
.
keyRelease
(
KeyEvent
.
VK_A
);
Thread
.
sleep
(
10
);
b
.
setLabel
(
"Type: "
+
i
);
}
System
.
out
.
println
(
"Key typing done: "
+
eventsCount
+
" events."
);
if
(
eventsCount
==
0
)
{
throw
new
RuntimeException
(
"No events were received"
);
}
if
(
failed
)
{
throw
new
RuntimeException
(
"Test failed."
);
}
System
.
out
.
println
(
"Success!"
);
}
finally
{
frame
.
dispose
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录