if (c instanceof Window) {
wpeer = (XWindowPeer)c.getPeer();
}
if (wpeer == null) {
throw new InvalidDnDOperationException(
"Cannot find top-level for the drag source component");
}
long xcursor = 0;
long rootWindow = 0;
long dragWindow = 0;
long timeStamp = 0;
/* Retrieve the X cursor for the drag operation. */
{
Cursor cursor = getCursor();
if (cursor != null) {
xcursor = XGlobalCursorManager.getCursor(cursor);
}
}
XToolkit.awtLock();
try {
if (proxyModeSourceWindow != 0) {
throw new InvalidDnDOperationException("Proxy drag in progress");
}
if (dndInProgress) {
throw new InvalidDnDOperationException("Drag in progress");
}
/* Determine the root window for the drag operation. */
{
long screen = XlibWrapper.XScreenNumberOfScreen(wpeer.getScreen());
rootWindow = XlibWrapper.RootWindow(XToolkit.getDisplay(), screen);
}
dragWindow = XWindow.getXAWTRootWindow().getWindow();
timeStamp = XToolkit.getCurrentServerTime();
int dropActions = getDragSourceContext().getSourceActions();
Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
try {
dragProtocol.initializeDrag(dropActions, transferable,
formatMap, formats);
} catch (XException xe) {
throw (InvalidDnDOperationException)
new InvalidDnDOperationException().initCause(xe);
}
}
/* Install X grabs. */
{
int status;
XWindowAttributes wattr = new XWindowAttributes();
try {
status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
rootWindow, wattr.pData);
if (status == 0) {
throw new InvalidDnDOperationException("XGetWindowAttributes failed");
}
rootEventMask = wattr.get_your_event_mask();
XlibWrapper.XSelectInput(XToolkit.getDisplay(), rootWindow,