jdk/src/solaris/classes/sun/awt/X11/XDropTargetContextPeer.java
author yan
Mon, 06 Oct 2008 16:45:00 +0400
changeset 1966 12a51fb0db0d
parent 2 90ce3da70b43
child 3938 ef327bd847c0
permissions -rw-r--r--
5100701: Toolkit.getLockingKeyState() does not work on XToolkit, but works on Motif Summary: Does not work on Motif but works on XToolkit now; implemented using XQueryPointer. Reviewed-by: anthony
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.X11;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.ComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.logging.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.awt.dnd.SunDropTargetContextPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.awt.dnd.SunDropTargetEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.misc.Unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * The XDropTargetContextPeer is the class responsible for handling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * the interaction between the XDnD/Motif DnD subsystem and Java drop targets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
final class XDropTargetContextPeer extends SunDropTargetContextPeer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static final Logger logger =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        Logger.getLogger("sun.awt.X11.xembed.xdnd.XDropTargetContextPeer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static final Unsafe unsafe = XlibWrapper.unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * A key to store a peer instance for an AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static final Object DTCP_KEY = "DropTargetContextPeer";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private XDropTargetContextPeer() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    static XDropTargetContextPeer getPeer(AppContext appContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        synchronized (_globalLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            XDropTargetContextPeer peer =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                (XDropTargetContextPeer)appContext.get(DTCP_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                peer = new XDropTargetContextPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                appContext.put(DTCP_KEY, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    static XDropTargetProtocolListener getXDropTargetProtocolListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        return XDropTargetProtocolListenerImpl.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @param returnValue the drop action selected by the Java drop target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    protected void eventProcessed(SunDropTargetEvent e, int returnValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                  boolean dispatcherDone) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        /* If the event was not consumed, send a response to the source. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            if (ctxt != 0 && !e.isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                    XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                        (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                                                        returnValue)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            if (dispatcherDone && ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                unsafe.freeMemory(ctxt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    protected void doDropDone(boolean success, int dropAction,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                              boolean isLocal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        if (ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                        (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    if (dropTargetProtocol.sendDropDone(ctxt, success,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                                                        dropAction)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                unsafe.freeMemory(ctxt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    protected Object getNativeData(long format)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
      throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                    (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                // getData throws IAE if ctxt is not for this protocol.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                    return dropTargetProtocol.getData(ctxt, format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                } catch (IllegalArgumentException iae) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    private void cleanup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    protected void processEnterMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            super.processEnterMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    protected void processExitMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            super.processExitMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    protected void processMotionMessage(SunDropTargetEvent event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                        boolean operationChanged) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            super.processMotionMessage(event, operationChanged);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    protected void processDropMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            super.processDropMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    // If source is an XEmbedCanvasPeer, passes the event to it for processing and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    // return true if the event is forwarded to the XEmbed child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    // Otherwise, does nothing and return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        Object source = event.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        if (source instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            ComponentPeer peer = ((Component)source).getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            if (peer instanceof XEmbedCanvasPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                XEmbedCanvasPeer xEmbedCanvasPeer = (XEmbedCanvasPeer)peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                   structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                if (logger.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    logger.finer("        processing " + event + " ctxt=" + ctxt +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                                 " consumed=" + event.isConsumed());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                /* If the event is not consumed, pass it to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                   XEmbedCanvasPeer for processing. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                if (!event.isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    // NOTE: ctxt can be zero at this point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                    if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                                                               event.getID())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                        event.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public void forwardEventToEmbedded(long embedded, long ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                                       int eventID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            if (dropTargetProtocol.forwardEventToEmbedded(embedded, ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                                                          eventID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    static final class XDropTargetProtocolListenerImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        implements XDropTargetProtocolListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        private final static XDropTargetProtocolListener theInstance =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            new XDropTargetProtocolListenerImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        private XDropTargetProtocolListenerImpl() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        static XDropTargetProtocolListener getInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            return theInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        public void handleDropTargetNotification(XWindow xwindow, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                                 int dropAction, int actions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                                 long[] formats, long nativeCtxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                                 int eventID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            Object target = xwindow.getTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            // The Every component is associated with some AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            assert target instanceof Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            Component component = (Component)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            AppContext appContext = SunToolkit.targetToAppContext(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            // Every component is associated with some AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            assert appContext != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            XDropTargetContextPeer peer = XDropTargetContextPeer.getPeer(appContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            peer.postDropTargetEvent(component, x, y, dropAction, actions, formats,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                     nativeCtxt, eventID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                                     !SunDropTargetContextPeer.DISPATCH_SYNC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
}