Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

8257414: Drag n Drop target area is wrong on high DPI systems #21

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
Expand Down
Expand Up @@ -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) {
Expand Down