private void updateTargetWindow(XMotionEvent xmotion) { assert XToolkit.isAWTLockHeldByCurrentThread(); int x = xmotion.get_x_root(); int y = xmotion.get_y_root(); long time = xmotion.get_time(); long subwindow = xmotion.get_subwindow(); /* * If this event had occurred before the pointer was grabbed, * query the server for the current root subwindow. */ if (xmotion.get_window() != xmotion.get_root()) { XlibWrapper.XQueryPointer( XToolkit.getDisplay(), xmotion.get_root(), XlibWrapper.larg1, // root XlibWrapper.larg2, // subwindow XlibWrapper.larg3, // x_root XlibWrapper.larg4, // y_root XlibWrapper.larg5, // x XlibWrapper.larg6, // y XlibWrapper.larg7); // modifiers subwindow = Native.getLong(XlibWrapper.larg2); } if (targetRootSubwindow != subwindow) { if (dragProtocol != null) { dragProtocol.sendLeaveMessage(time); /* * Neither Motif DnD nor XDnD provide a mean for the target * to notify the source that the pointer exits the drop site * that occupies the whole top level. * We detect this situation and post dragExit. */ if (targetAction != DnDConstants.ACTION_NONE) { dragExit(x, y); } } /* Update the global state. */ doUpdateTargetWindow(subwindow, time); if (dragProtocol != null) { dragProtocol.sendEnterMessage(sourceFormats, sourceAction, sourceActions, time); } } }
/** The caller must own awtLock. */ public void cleanup(long time) { if (dndInProgress) { if (dragProtocol != null) { dragProtocol.sendLeaveMessage(time); } if (targetAction != DnDConstants.ACTION_NONE) { dragExit(xRoot, yRoot); } dragDropFinished(false, DnDConstants.ACTION_NONE, xRoot, yRoot); } Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols(); while (dragProtocols.hasNext()) { XDragSourceProtocol dragProtocol = (XDragSourceProtocol) dragProtocols.next(); try { dragProtocol.cleanup(); } catch (XException xe) { // Ignore the exception. } } dndInProgress = false; dragInProgress = false; dragRootWindow = 0; sourceFormats = null; sourceActions = DnDConstants.ACTION_NONE; sourceAction = DnDConstants.ACTION_NONE; eventState = 0; xRoot = 0; yRoot = 0; cleanupTargetInfo(); removeDnDGrab(time); }