< prev index next >
src/java.desktop/unix/classes/sun/awt/X11/XDragSourceContextPeer.java
Print this page
@@ -81,10 +81,12 @@
/* The data formats supported by the drag source for the current drag
operation. */
private long[] sourceFormats = null;
/* The XID of the root subwindow that contains the current target. */
private long targetRootSubwindow = 0;
+ /* window scale factor */
+ int windowScale = 1;
/* The pointer location. */
private int xRoot = 0;
private int yRoot = 0;
/* Keyboard modifiers state. */
private int eventState = 0;
@@ -128,12 +130,12 @@
"Cannot find top-level for the drag source component");
}
long xcursor = 0;
long rootWindow = 0;
- long dragWindow = 0;
long timeStamp = 0;
+ windowScale = wpeer.getScale();
/* Retrieve the X cursor for the drag operation. */
{
Cursor cursor = getCursor();
if (cursor != null) {
@@ -154,12 +156,10 @@
{
long screen = XlibWrapper.XScreenNumberOfScreen(wpeer.getScreen());
rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen);
}
- dragWindow = XWindow.getXAWTRootWindow().getWindow();
-
timeStamp = XToolkit.getCurrentServerTime();
int dropActions = getDragSourceContext().getSourceActions();
Iterator<XDragSourceProtocol> dragProtocols =
@@ -439,12 +439,12 @@
}
private void updateTargetWindow(XMotionEvent xmotion) {
assert XToolkit.isAWTLockHeldByCurrentThread();
- int x = xmotion.get_x_root();
- int y = xmotion.get_y_root();
+ int x = scaleDown(xmotion.get_x_root());
+ int y = scaleDown(xmotion.get_y_root());
long time = xmotion.get_time();
long subwindow = xmotion.get_subwindow();
/*
* If this event had occurred before the pointer was grabbed,
@@ -496,13 +496,17 @@
*/
private void processMouseMove(XMotionEvent xmotion) {
if (!dragInProgress) {
return;
}
- if (xRoot != xmotion.get_x_root() || yRoot != xmotion.get_y_root()) {
- xRoot = xmotion.get_x_root();
- yRoot = xmotion.get_y_root();
+
+ int motionXRoot = scaleDown(xmotion.get_x_root());
+ int motionYRoot = scaleDown(xmotion.get_y_root());
+
+ if (xRoot != motionXRoot || yRoot != motionYRoot) {
+ xRoot = motionXRoot;
+ yRoot = motionYRoot;
postDragSourceDragEvent(targetAction,
XWindow.getModifiers(xmotion.get_state(),0,0),
xRoot, yRoot, DISPATCH_MOUSE_MOVED);
}
@@ -517,21 +521,21 @@
}
updateTargetWindow(xmotion);
if (dragProtocol != null) {
- dragProtocol.sendMoveMessage(xmotion.get_x_root(),
- xmotion.get_y_root(),
+ dragProtocol.sendMoveMessage(scaleDown(xmotion.get_x_root()),
+ scaleDown(xmotion.get_y_root()),
sourceAction, sourceActions,
xmotion.get_time());
}
}
private void processDrop(XButtonEvent xbutton) {
try {
- dragProtocol.initiateDrop(xbutton.get_x_root(),
- xbutton.get_y_root(),
+ dragProtocol.initiateDrop(scaleDown(xbutton.get_x_root()),
+ scaleDown(xbutton.get_y_root()),
sourceAction, sourceActions,
xbutton.get_time());
} catch (XException e) {
cleanup(xbutton.get_time());
}
@@ -803,6 +807,14 @@
dragDropFinished(success, action, x, y);
dndInProgress = false;
cleanup(XConstants.CurrentTime);
}
+
+ public int scaleUp(int x) {
+ return x * windowScale;
+ }
+
+ public int scaleDown(int x) {
+ return x / windowScale;
+ }
}
< prev index next >