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

Commit

Permalink
8257414: Drag n Drop target area is wrong on high DPI systems
Browse files Browse the repository at this point in the history
Backport-of: d339832
  • Loading branch information
Olga Mikhaltsova authored and Yuri Nesterenko committed Mar 16, 2021
1 parent d7a63fc commit 5850c58
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

1 comment on commit 5850c58

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.