Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell11
提交
20d60b0e
D
dragonwell11
项目概览
openanolis
/
dragonwell11
通知
7
Star
2
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,发现更多精彩内容 >>
提交
20d60b0e
编写于
10月 30, 2017
作者:
P
pbansal
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8159062: [hidpi] DnD on Windows while scaling is non-integer
Reviewed-by: serb, pkbalakr Contributed-by: pankaj.b.bansal@oracle.com
上级
a9a8aa74
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
216 addition
and
6 deletion
+216
-6
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
...windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
+6
-5
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.h
...p/windows/native/libawt/windows/awt_Win32GraphicsDevice.h
+1
-1
test/jdk/java/awt/dnd/DnDTestWithHIDPI/DragTestWithHIDPI.java
.../jdk/java/awt/dnd/DnDTestWithHIDPI/DragTestWithHIDPI.java
+209
-0
未找到文件。
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
浏览文件 @
20d60b0e
...
...
@@ -632,26 +632,27 @@ void AwtWin32GraphicsDevice::SetScale(float sx, float sy)
int
AwtWin32GraphicsDevice
::
ScaleUpX
(
int
x
)
{
return
C
heckIntLimits
(
x
*
scaleX
);
return
C
lipRound
(
x
*
scaleX
);
}
int
AwtWin32GraphicsDevice
::
ScaleUpY
(
int
y
)
{
return
C
heckIntLimits
(
y
*
scaleY
);
return
C
lipRound
(
y
*
scaleY
);
}
int
AwtWin32GraphicsDevice
::
ScaleDownX
(
int
x
)
{
return
C
heckIntLimits
(
x
/
scaleX
);
return
C
lipRound
(
x
/
scaleX
);
}
int
AwtWin32GraphicsDevice
::
ScaleDownY
(
int
y
)
{
return
C
heckIntLimits
(
y
/
scaleY
);
return
C
lipRound
(
y
/
scaleY
);
}
int
AwtWin32GraphicsDevice
::
C
heckIntLimits
(
double
value
)
int
AwtWin32GraphicsDevice
::
C
lipRound
(
double
value
)
{
value
-=
0.5
;
if
(
value
<
INT_MIN
)
{
return
INT_MIN
;
...
...
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.h
浏览文件 @
20d60b0e
...
...
@@ -119,7 +119,7 @@ private:
float
scaleY
;
static
HDC
MakeDCFromMonitor
(
HMONITOR
);
static
int
C
heckIntLimits
(
double
value
);
static
int
C
lipRound
(
double
value
);
};
#endif AWT_WIN32GRAPHICSDEVICE_H
test/jdk/java/awt/dnd/DnDTestWithHIDPI/DragTestWithHIDPI.java
0 → 100644
浏览文件 @
20d60b0e
/*
* Copyright (c) 2017, 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.
*/
/*
* @test
* @key headful
* @bug 8159062
* @summary Tests DnD property with HIDPI scale set to non-interger value 2.5
* @run main/othervm -Dsun.java2d.uiScale=2.5 DragTestWithHIDPI
*/
import
javax.swing.JList
;
import
javax.swing.TransferHandler
;
import
javax.swing.JFrame
;
import
javax.swing.JComponent
;
import
javax.swing.SwingUtilities
;
import
java.awt.Robot
;
import
java.awt.BorderLayout
;
import
java.awt.Point
;
import
java.awt.Dimension
;
import
java.awt.MouseInfo
;
import
java.awt.event.InputEvent
;
public
class
DragTestWithHIDPI
extends
TransferHandler
{
private
static
boolean
didDrag
=
false
;
private
static
int
threshold
=
10
;
private
static
int
DEFAULT_DELAY
=
550
;
private
Robot
robot
=
null
;
private
static
JList
list
=
null
;
private
static
Point
listLocation
=
null
;
private
static
Dimension
listSize
=
null
;
private
static
JFrame
f
=
null
;
private
enum
Direction
{
RIGHT
,
LEFT
,
BOTTOM
,
TOP
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
DragTestWithHIDPI
test
=
new
DragTestWithHIDPI
();
// set the mouse move drag threshold
System
.
setProperty
(
"awt.dnd.drag.threshold"
,
String
.
valueOf
(
threshold
));
test
.
createGUI
();
test
.
doTest
();
System
.
out
.
println
(
"Test Passed"
);
test
.
disposeGUI
();
}
public
void
exportAsDrag
(
JComponent
comp
,
InputEvent
e
,
int
action
)
{
didDrag
=
true
;
}
public
DragTestWithHIDPI
()
{
super
(
"foreground"
);
}
private
void
createGUI
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
String
[]
listData
=
new
String
[]{
"Pacific Ocean"
,
"Atlantic Ocean"
,
"Indian Ocean"
,
"Arctic Ocean"
};
list
=
new
JList
(
listData
);
list
.
setDragEnabled
(
true
);
list
.
setTransferHandler
(
new
DragTestWithHIDPI
());
f
=
new
JFrame
(
"DragTestWithHIDPI"
);
f
.
getContentPane
().
add
(
list
,
BorderLayout
.
CENTER
);
f
.
pack
();
f
.
toFront
();
f
.
setVisible
(
true
);
listLocation
=
list
.
getLocationOnScreen
();
listSize
=
list
.
getSize
();
});
}
private
void
disposeGUI
()
throws
Exception
{
SwingUtilities
.
invokeAndWait
(()
->
{
f
.
dispose
();
});
}
private
void
doTest
()
throws
Exception
{
robot
=
new
Robot
();
robot
.
waitForIdle
();
for
(
Direction
direction
:
Direction
.
values
())
{
//Drag should not start only by moving (threshold - 1) pixels
didDrag
=
false
;
test
(
threshold
-
1
,
direction
);
if
(
didDrag
)
{
disposeGUI
();
throw
new
RuntimeException
(
"Shouldn't start drag until > "
+
threshold
+
" pixels "
+
" while moving "
+
direction
);
}
// Drag should not start only by moving threshold pixels
didDrag
=
false
;
test
(
threshold
,
direction
);
if
(
didDrag
)
{
disposeGUI
();
throw
new
RuntimeException
(
"Shouldn't start drag until > "
+
threshold
+
" pixels"
+
" while moving "
+
direction
);
}
// Drag should start after moving threshold + 1 pixel
didDrag
=
false
;
test
(
threshold
+
1
,
direction
);
if
(!
didDrag
)
{
disposeGUI
();
throw
new
RuntimeException
(
"Should start drag after > "
+
threshold
+
" pixels"
+
" while moving "
+
direction
);
}
}
}
private
void
test
(
int
threshold
,
Direction
direction
)
{
clickMouseOnList
(
InputEvent
.
BUTTON1_DOWN_MASK
);
Point
p
=
MouseInfo
.
getPointerInfo
().
getLocation
();
robot
.
mousePress
(
InputEvent
.
BUTTON1_DOWN_MASK
);
robot
.
delay
(
DEFAULT_DELAY
);
glide
(
p
,
direction
,
threshold
);
robot
.
mouseRelease
(
InputEvent
.
BUTTON1_DOWN_MASK
);
}
private
void
glide
(
Point
p
,
Direction
direction
,
int
toAdd
)
{
switch
(
direction
)
{
case
RIGHT:
// move towards right
glide
(
p
.
x
,
p
.
y
,
p
.
x
+
toAdd
,
p
.
y
);
break
;
case
LEFT:
// move towards left
glide
(
p
.
x
,
p
.
y
,
p
.
x
-
toAdd
,
p
.
y
);
break
;
case
BOTTOM:
// move towards bottom
glide
(
p
.
x
,
p
.
y
,
p
.
x
,
p
.
y
+
toAdd
);
break
;
case
TOP:
// move towards top
glide
(
p
.
x
,
p
.
y
,
p
.
x
,
p
.
y
-
toAdd
);
break
;
}
}
/*
Some utilities functions from JRobot class.
*/
private
void
moveMouseToList
()
{
int
x
=
listLocation
.
x
+
listSize
.
width
/
2
;
int
y
=
listLocation
.
y
+
listSize
.
height
/
2
;
robot
.
mouseMove
(
x
,
y
);
robot
.
delay
(
DEFAULT_DELAY
);
}
private
void
clickMouse
(
int
buttons
)
{
robot
.
mousePress
(
buttons
);
robot
.
mouseRelease
(
buttons
);
robot
.
delay
(
DEFAULT_DELAY
);
}
private
void
clickMouseOnList
(
int
buttons
)
{
moveMouseToList
();
clickMouse
(
buttons
);
}
private
void
glide
(
int
x0
,
int
y0
,
int
x1
,
int
y1
)
{
float
dmax
=
(
float
)
Math
.
max
(
Math
.
abs
(
x1
-
x0
),
Math
.
abs
(
y1
-
y0
));
float
dx
=
(
x1
-
x0
)
/
dmax
;
float
dy
=
(
y1
-
y0
)
/
dmax
;
robot
.
mouseMove
(
x0
,
y0
);
for
(
int
i
=
1
;
i
<=
dmax
;
i
++)
{
robot
.
mouseMove
((
int
)(
x0
+
dx
*
i
),
(
int
)(
y0
+
dy
*
i
));
}
robot
.
delay
(
DEFAULT_DELAY
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录