Skip to content
Permalink
Browse files
8257414: Drag n Drop target area is wrong on high DPI systems
Reviewed-by: serb
  • Loading branch information
Olga Mikhaltsova authored and mrserb committed Mar 2, 2021
1 parent 353416f commit d3398324e9c3944d2f1558ff1becea9ed1d4e8a2
@@ -37,6 +37,14 @@

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 @@ private boolean processXdndPosition(XClientMessageEvent xclient) {
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,17 +524,17 @@ private void processMouseMove(XMotionEvent xmotion) {
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());
}
}

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) {

1 comment on commit d339832

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on d339832 Mar 2, 2021

Please sign in to comment.