Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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) {