jdk/src/solaris/classes/sun/awt/X11/XDropTargetContextPeer.java
author mchung
Tue, 29 Sep 2009 16:03:03 -0700
changeset 3938 ef327bd847c0
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes Summary: Replace calls to Logger with sun.util.logging.PlatformLogger Reviewed-by: prr, art, alexp, dcherepanov, igor, dav, 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;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    34
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    35
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.awt.dnd.SunDropTargetContextPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.awt.dnd.SunDropTargetEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.misc.Unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * The XDropTargetContextPeer is the class responsible for handling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * the interaction between the XDnD/Motif DnD subsystem and Java drop targets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
final class XDropTargetContextPeer extends SunDropTargetContextPeer {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    52
    private static final PlatformLogger logger =
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    53
        PlatformLogger.getLogger("sun.awt.X11.xembed.xdnd.XDropTargetContextPeer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static final Unsafe unsafe = XlibWrapper.unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * A key to store a peer instance for an AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static final Object DTCP_KEY = "DropTargetContextPeer";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private XDropTargetContextPeer() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    static XDropTargetContextPeer getPeer(AppContext appContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        synchronized (_globalLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            XDropTargetContextPeer peer =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                (XDropTargetContextPeer)appContext.get(DTCP_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
                peer = new XDropTargetContextPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                appContext.put(DTCP_KEY, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    static XDropTargetProtocolListener getXDropTargetProtocolListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        return XDropTargetProtocolListenerImpl.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @param returnValue the drop action selected by the Java drop target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    protected void eventProcessed(SunDropTargetEvent e, int returnValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                                  boolean dispatcherDone) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        /* If the event was not consumed, send a response to the source. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            if (ctxt != 0 && !e.isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                    XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                        (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                    if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                                        returnValue)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            if (dispatcherDone && ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                unsafe.freeMemory(ctxt);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    protected void doDropDone(boolean success, int dropAction,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                              boolean isLocal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                        (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    if (dropTargetProtocol.sendDropDone(ctxt, success,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                                                        dropAction)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                unsafe.freeMemory(ctxt);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    protected Object getNativeData(long format)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
      throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                    (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                // getData throws IAE if ctxt is not for this protocol.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                    return dropTargetProtocol.getData(ctxt, format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                } catch (IllegalArgumentException iae) {
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    private void cleanup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    protected void processEnterMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            super.processEnterMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    protected void processExitMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            super.processExitMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    protected void processMotionMessage(SunDropTargetEvent event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                                        boolean operationChanged) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            super.processMotionMessage(event, operationChanged);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    protected void processDropMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            super.processDropMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    // If source is an XEmbedCanvasPeer, passes the event to it for processing and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    // return true if the event is forwarded to the XEmbed child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    // Otherwise, does nothing and return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        Object source = event.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (source instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            ComponentPeer peer = ((Component)source).getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            if (peer instanceof XEmbedCanvasPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                XEmbedCanvasPeer xEmbedCanvasPeer = (XEmbedCanvasPeer)peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                   structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
   202
                if (logger.isLoggable(PlatformLogger.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                    logger.finer("        processing " + event + " ctxt=" + ctxt +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                                 " consumed=" + event.isConsumed());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                /* If the event is not consumed, pass it to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                   XEmbedCanvasPeer for processing. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                if (!event.isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                    // NOTE: ctxt can be zero at this point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                                               event.getID())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                        event.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                        return true;
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public void forwardEventToEmbedded(long embedded, long ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                                       int eventID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            if (dropTargetProtocol.forwardEventToEmbedded(embedded, ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                                                          eventID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                break;
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    static final class XDropTargetProtocolListenerImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        implements XDropTargetProtocolListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        private final static XDropTargetProtocolListener theInstance =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            new XDropTargetProtocolListenerImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        private XDropTargetProtocolListenerImpl() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        static XDropTargetProtocolListener getInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            return theInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        public void handleDropTargetNotification(XWindow xwindow, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                                 int dropAction, int actions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                                 long[] formats, long nativeCtxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                                                 int eventID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            Object target = xwindow.getTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            // The Every component is associated with some AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            assert target instanceof Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            Component component = (Component)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            AppContext appContext = SunToolkit.targetToAppContext(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            // Every component is associated with some AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            assert appContext != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            XDropTargetContextPeer peer = XDropTargetContextPeer.getPeer(appContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            peer.postDropTargetEvent(component, x, y, dropAction, actions, formats,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                                     nativeCtxt, eventID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                     !SunDropTargetContextPeer.DISPATCH_SYNC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
}