mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-24 17:20:06 +00:00
8257414: Drag n Drop target area is wrong on high DPI systems
Reviewed-by: serb
This commit is contained in:
parent
353416ffca
commit
d3398324e9
@ -37,6 +37,14 @@ import sun.util.logging.PlatformLogger;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import java.awt.GraphicsDevice;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
|
||||
import sun.awt.X11GraphicsConfig;
|
||||
|
||||
/**
|
||||
* XDropTargetProtocol implementation for XDnD protocol.
|
||||
*
|
||||
@ -597,7 +605,25 @@ class XDnDDropTargetProtocol extends XDropTargetProtocol {
|
||||
x = (int)(xclient.get_data(2) >> 16);
|
||||
y = (int)(xclient.get_data(2) & 0xFFFF);
|
||||
|
||||
if (xwindow == null) {
|
||||
if (xwindow != null) {
|
||||
x = xwindow.scaleDown(x);
|
||||
y = xwindow.scaleDown(y);
|
||||
} else {
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
for (GraphicsDevice gd : ge.getScreenDevices()) {
|
||||
X11GraphicsConfig gc = (X11GraphicsConfig)gd.getDefaultConfiguration();
|
||||
Rectangle rt = gc.getBounds();
|
||||
rt.x = gc.scaleUp(rt.x);
|
||||
rt.y = gc.scaleUp(rt.y);
|
||||
rt.width = gc.scaleUp(rt.width);
|
||||
rt.height = gc.scaleUp(rt.height);
|
||||
if (rt.contains(x, y)) {
|
||||
x = gc.scaleDown(x);
|
||||
y = gc.scaleDown(y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
long receiver =
|
||||
XDropTargetRegistry.getRegistry().getEmbeddedDropSite(
|
||||
xclient.get_window(), x, y);
|
||||
|
||||
@ -524,8 +524,8 @@ public final class XDragSourceContextPeer
|
||||
updateTargetWindow(xmotion);
|
||||
|
||||
if (dragProtocol != null) {
|
||||
dragProtocol.sendMoveMessage(scaleDown(xmotion.get_x_root()),
|
||||
scaleDown(xmotion.get_y_root()),
|
||||
dragProtocol.sendMoveMessage(xmotion.get_x_root(),
|
||||
xmotion.get_y_root(),
|
||||
sourceAction, sourceActions,
|
||||
xmotion.get_time());
|
||||
}
|
||||
@ -533,8 +533,8 @@ public final class XDragSourceContextPeer
|
||||
|
||||
private void processDrop(XButtonEvent xbutton) {
|
||||
try {
|
||||
dragProtocol.initiateDrop(scaleDown(xbutton.get_x_root()),
|
||||
scaleDown(xbutton.get_y_root()),
|
||||
dragProtocol.initiateDrop(xbutton.get_x_root(),
|
||||
xbutton.get_y_root(),
|
||||
sourceAction, sourceActions,
|
||||
xbutton.get_time());
|
||||
} catch (XException e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user