jdk/src/java.desktop/unix/classes/sun/awt/X11/XDropTargetContextPeer.java
author chegar
Wed, 11 Nov 2015 09:19:12 +0000
changeset 33674 566777f73c32
parent 32865 f9cb6e427f9e
permissions -rw-r--r--
8140606: Update library code to use internal Unsafe Reviewed-by: alanb, mchung, psandoz, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28231
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
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
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28231
diff changeset
    35
import sun.awt.AWTAccessor;
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    36
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.awt.dnd.SunDropTargetContextPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.awt.dnd.SunDropTargetEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
33674
566777f73c32 8140606: Update library code to use internal Unsafe
chegar
parents: 32865
diff changeset
    44
import jdk.internal.misc.Unsafe;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * The XDropTargetContextPeer is the class responsible for handling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * the interaction between the XDnD/Motif DnD subsystem and Java drop targets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
final class XDropTargetContextPeer extends SunDropTargetContextPeer {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    53
    private static final PlatformLogger logger =
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2
diff changeset
    54
        PlatformLogger.getLogger("sun.awt.X11.xembed.xdnd.XDropTargetContextPeer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static final Unsafe unsafe = XlibWrapper.unsafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * A key to store a peer instance for an AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static final Object DTCP_KEY = "DropTargetContextPeer";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private XDropTargetContextPeer() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static XDropTargetContextPeer getPeer(AppContext appContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        synchronized (_globalLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            XDropTargetContextPeer peer =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                (XDropTargetContextPeer)appContext.get(DTCP_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                peer = new XDropTargetContextPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                appContext.put(DTCP_KEY, peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            return peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    static XDropTargetProtocolListener getXDropTargetProtocolListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        return XDropTargetProtocolListenerImpl.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @param returnValue the drop action selected by the Java drop target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    protected void eventProcessed(SunDropTargetEvent e, int returnValue,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                  boolean dispatcherDone) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        /* If the event was not consumed, send a response to the source. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            if (ctxt != 0 && !e.isConsumed()) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
    93
                Iterator<XDropTargetProtocol> dropTargetProtocols =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    XDropTargetProtocol dropTargetProtocol =
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
    98
                        dropTargetProtocols.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                    if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                                                        returnValue)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            if (dispatcherDone && ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                unsafe.freeMemory(ctxt);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    protected void doDropDone(boolean success, int dropAction,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                              boolean isLocal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (ctxt != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            try {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   120
                Iterator<XDropTargetProtocol> dropTargetProtocols =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                    XDropTargetProtocol dropTargetProtocol =
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   125
                        dropTargetProtocols.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    if (dropTargetProtocol.sendDropDone(ctxt, success,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                                                        dropAction)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                unsafe.freeMemory(ctxt);
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    protected Object getNativeData(long format)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
      throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
           structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        if (ctxt != 0) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   144
            Iterator<XDropTargetProtocol> dropTargetProtocols =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                XDropTargetProtocol dropTargetProtocol =
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   149
                    dropTargetProtocols.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                // getData throws IAE if ctxt is not for this protocol.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                    return dropTargetProtocol.getData(ctxt, format);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                } catch (IllegalArgumentException iae) {
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    private void cleanup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    protected void processEnterMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            super.processEnterMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    protected void processExitMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            super.processExitMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    protected void processMotionMessage(SunDropTargetEvent event,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                        boolean operationChanged) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            super.processMotionMessage(event, operationChanged);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    protected void processDropMessage(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (!processSunDropTargetEvent(event)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            super.processDropMessage(event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    // If source is an XEmbedCanvasPeer, passes the event to it for processing and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    // return true if the event is forwarded to the XEmbed child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    // Otherwise, does nothing and return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        Object source = event.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        if (source instanceof Component) {
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28231
diff changeset
   196
            Object peer = AWTAccessor.getComponentAccessor()
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28231
diff changeset
   197
                                     .getPeer((Component) source);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            if (peer instanceof XEmbedCanvasPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                XEmbedCanvasPeer xEmbedCanvasPeer = (XEmbedCanvasPeer)peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                /* The native context is the pointer to the XClientMessageEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                   structure. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                long ctxt = getNativeDragContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 5506
diff changeset
   204
                if (logger.isLoggable(PlatformLogger.Level.FINER)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    logger.finer("        processing " + event + " ctxt=" + ctxt +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                 " consumed=" + event.isConsumed());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                /* If the event is not consumed, pass it to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                   XEmbedCanvasPeer for processing. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                if (!event.isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                    // NOTE: ctxt can be zero at this point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                                               event.getID())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                        event.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                        return true;
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
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public void forwardEventToEmbedded(long embedded, long ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                       int eventID) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   226
        Iterator<XDropTargetProtocol> dropTargetProtocols =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        while (dropTargetProtocols.hasNext()) {
24538
25bf8153fbfe 8039642: Fix raw and unchecked warnings in sun.awt.*
henryjen
parents: 23010
diff changeset
   230
            XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            if (dropTargetProtocol.forwardEventToEmbedded(embedded, ctxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                                          eventID)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                break;
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    static final class XDropTargetProtocolListenerImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        implements XDropTargetProtocolListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30469
diff changeset
   241
        private static final XDropTargetProtocolListener theInstance =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            new XDropTargetProtocolListenerImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        private XDropTargetProtocolListenerImpl() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        static XDropTargetProtocolListener getInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            return theInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        public void handleDropTargetNotification(XWindow xwindow, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                                 int dropAction, int actions,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                                                 long[] formats, long nativeCtxt,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                                                 int eventID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            Object target = xwindow.getTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            // The Every component is associated with some AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            assert target instanceof Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            Component component = (Component)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            AppContext appContext = SunToolkit.targetToAppContext(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            // Every component is associated with some AppContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            assert appContext != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            XDropTargetContextPeer peer = XDropTargetContextPeer.getPeer(appContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            peer.postDropTargetEvent(component, x, y, dropAction, actions, formats,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                     nativeCtxt, eventID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                                     !SunDropTargetContextPeer.DISPATCH_SYNC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
}