/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The XDragSourceContextPeer class is the class responsible for handling
*
* @since 1.5
*/
public final class XDragSourceContextPeer
extends SunDragSourceContextPeer implements XDragSourceProtocolListener {
/* The events selected on the root window when the drag begins. */
/* The events to be delivered during grab. */
/* The event mask of the root window before the drag operation starts. */
private boolean dndInProgress = false;
private boolean dragInProgress = false;
/* The protocol chosen for the communication with the current drop target. */
/* The drop action chosen by the current drop target. */
/* The set of drop actions supported by the drag source. */
/* The drop action selected by the drag source based on the modifiers state
and the action selected by the current drop target. */
/* The data formats supported by the drag source for the current drag
operation. */
/* The XID of the root subwindow that contains the current target. */
/* The pointer location. */
/* Keyboard modifiers state. */
/* XEmbed DnD support. We act as a proxy between source and target. */
/* The singleton instance. */
new XDragSourceContextPeer(null);
super(dge);
}
return theInstance;
}
throws InvalidDnDOperationException {
return theInstance;
}
if (c instanceof Window) {
}
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. */
{
}
}
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. */
{
}
while (dragProtocols.hasNext()) {
try {
} catch (XException xe) {
throw (InvalidDnDOperationException)
}
}
/* Install X grabs. */
{
int status;
try {
if (status == 0) {
throw new InvalidDnDOperationException("XGetWindowAttributes failed");
}
} finally {
}
0, GRAB_EVENT_MASK,
return;
}
0,
return;
}
}
/* Update the global state. */
dndInProgress = true;
dragInProgress = true;
} finally {
}
/* This implementation doesn't use native context */
setNativeContext(0);
}
public long getProxyModeSourceWindow() {
return proxyModeSourceWindow;
}
}
}
/**
* set cursor
*/
try {
super.setCursor(c);
} finally {
}
}
assert XToolkit.isAWTLockHeldByCurrentThread();
if (c == null) {
return;
}
if (xcursor == 0) {
return;
}
}
protected boolean needsBogusExitBeforeDrop() {
return false;
}
throws InvalidDnDOperationException {
switch (grabStatus) {
default: msgCause = "unknown failure"; break;
}
}
/**
* The caller must own awtLock.
*/
if (dndInProgress) {
if (dragProtocol != null) {
}
}
}
while (dragProtocols.hasNext()) {
try {
} catch (XException xe) {
// Ignore the exception.
}
}
dndInProgress = false;
dragInProgress = false;
dragRootWindow = 0;
eventState = 0;
xRoot = 0;
yRoot = 0;
}
/**
* The caller must own awtLock.
*/
private void cleanupTargetInfo() {
dragProtocol = null;
targetRootSubwindow = 0;
}
assert XToolkit.isAWTLockHeldByCurrentThread();
/* Restore the root event mask if it was changed. */
dragRootWindow != 0) {
}
rootEventMask = 0;
dragRootWindow = 0;
}
if (dragProtocol != null) {
}
return false;
}
/**
* Updates the source action according to the specified state.
*
* @returns true if the source
*/
int action = SunDragSourceContextPeer.convertModifiersToDropAction(XWindow.getModifiers(state, 0, 0),
if (sourceAction == action) {
return false;
}
return true;
}
/**
* Returns the client window under the specified root subwindow.
*/
return window;
}
if (win != 0) {
return win;
}
}
return 0;
}
long clientWindow = 0;
long proxyWindow = 0;
boolean isReceiver = false;
if (subwindow != 0) {
}
if (clientWindow != 0) {
while (dragProtocols.hasNext()) {
break;
}
}
}
/* Update the global state. */
}
assert XToolkit.isAWTLockHeldByCurrentThread();
int x = xmotion.get_x_root();
int y = xmotion.get_y_root();
/*
* If this event had occurred before the pointer was grabbed,
* query the server for the current root subwindow.
*/
}
if (targetRootSubwindow != subwindow) {
if (dragProtocol != null) {
/*
* 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.
*/
dragExit(x, y);
}
}
/* Update the global state. */
if (dragProtocol != null) {
time);
}
}
}
/*
* DO NOT USE is_hint field of xmotion since it could not be set when we
* convert XKeyEvent or XButtonRelease to XMotionEvent.
*/
if (!dragInProgress) {
return;
}
}
}
}
if (dragProtocol != null) {
}
}
try {
} catch (XException e) {
}
}
if (getProxyModeSourceWindow() == 0) {
return false;
}
return false;
}
" ev=" + ev);
}
while (dragProtocols.hasNext()) {
getProxyModeSourceWindow())) {
return true;
}
}
return false;
}
/**
* The caller must own awtLock.
*
* @returns true if the even was processed and shouldn't be passed along.
*/
assert XToolkit.isAWTLockHeldByCurrentThread();
if (processProxyModeEvent(ev)) {
return true;
}
if (!dndInProgress) {
return false;
}
case XConstants.ClientMessage: {
return processClientMessage(xclient);
}
case XConstants.DestroyNotify: {
/* Target crashed during drop processing - cleanup. */
if (!dragInProgress &&
dragProtocol != null &&
return true;
}
/* Pass along */
return false;
}
}
if (!dragInProgress) {
return false;
}
/* Process drag-only messages. */
case XConstants.KeyRelease:
case XConstants.KeyPress: {
switch ((int)keysym) {
case (int)XKeySymConstants.XK_Escape: {
}
break;
}
case (int)XKeySymConstants.XK_Control_R:
case (int)XKeySymConstants.XK_Control_L:
case (int)XKeySymConstants.XK_Shift_R:
case (int)XKeySymConstants.XK_Shift_L: {
try {
// we do not use this field, so it's unset for now
// xmotion.set_is_hint(???);
//It's safe to use key event as motion event since we use only their common fields.
} finally {
}
break;
}
}
return true;
}
case XConstants.ButtonPress:
return true;
case XConstants.MotionNotify:
return true;
case XConstants.ButtonRelease: {
/*
* Ignore the buttons above 20 due to the bit limit for
* InputEvent.BUTTON_DOWN_MASK.
* One more bit is reserved for FIRST_HIGH_BIT.
*/
return true;
}
/*
* On some X servers it could happen that ButtonRelease coordinates
* differ from the latest MotionNotify coordinates, so we need to
* process it as a mouse motion.
*/
try {
// we do not use this field, so it's unset for now
// xmotion.set_is_hint(???);
//It's safe to use key event as motion event since we use only their common fields.
} finally {
}
// drag is initiated with Button1 or Button2 pressed and
// ended on release of either of these buttons (as the same
// behavior was with our old Motif DnD-based implementation)
dragInProgress = false;
/*
* ACTION_NONE indicates that either the drop target rejects the
* drop or it haven't responded yet. The latter could happen in
* case of fast drag, slow target-server connection or slow
* drag notifications processing on the target side.
*/
} else {
}
}
return true;
}
}
return false;
}
try {
try {
} catch (XException e) {
e.printStackTrace();
return false;
}
} finally {
}
}
/* XDragSourceProtocolListener implementation */
// NOTE: we have to use the current pointer location, since
// the target didn't specify the coordinates for the reply.
}
// NOTE: we have to use the current modifiers state, since
// the target didn't specify the modifiers state for the reply.
}
dragExit(x, y);
int type = 0;
} else {
}
// Note that we use the modifiers state a
}
}
public void handleDragFinished() {
/* Assume that the drop was successful. */
handleDragFinished(true);
}
/* Assume that the performed drop action is the latest drop action
accepted by the drop target. */
handleDragFinished(true, targetAction);
}
// NOTE: we have to use the current pointer location, since
// the target didn't specify the coordinates for the reply.
}
dndInProgress = false;
}
}