jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java
author yan
Mon, 06 Oct 2008 16:45:00 +0400
changeset 1966 12a51fb0db0d
parent 439 3488710b02f8
child 2802 d05a9dcc8296
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
/*
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
     2
 * Copyright 2003-2008 Sun Microsystems, Inc.  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
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.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Collections;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.List;
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 java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * The class responsible for registration/deregistration of drop sites.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
final class XDropTargetRegistry {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static final Logger logger =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        Logger.getLogger("sun.awt.X11.xembed.xdnd.XDropTargetRegistry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private static final long DELAYED_REGISTRATION_PERIOD = 200;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private static final XDropTargetRegistry theInstance =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        new XDropTargetRegistry();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private final HashMap<Long, Runnable> delayedRegistrationMap =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        new HashMap<Long, Runnable>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private XDropTargetRegistry() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static XDropTargetRegistry getRegistry() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        return theInstance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Returns the XID of the topmost window with WM_STATE set in the ancestor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * heirarchy of the specified window or 0 if none found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private long getToplevelWindow(long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        XBaseWindow candWindow = XToolkit.windowToXWindow(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        if (candWindow != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            XWindowPeer toplevel = candWindow.getToplevelXWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
            if (toplevel != null && !(toplevel instanceof XEmbeddedFramePeer)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                return toplevel.getWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        /* Traverse the ancestor tree from window up to the root and find
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
           the top-level client window nearest to the root. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            if (XlibUtil.isTrueToplevelWindow(window)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                return window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            window = XlibUtil.getParentWindow(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        } while (window != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    static final long getDnDProxyWindow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        return XWindow.getXAWTRootWindow().getWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private static final class EmbeddedDropSiteEntry {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        private final long root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        private final long event_mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        private List<XDropTargetProtocol> supportedProtocols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        private final HashSet<Long> nonXEmbedClientSites = new HashSet<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        private final List<Long> sites = new ArrayList<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        public EmbeddedDropSiteEntry(long root, long event_mask,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                                     List<XDropTargetProtocol> supportedProtocols) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            if (supportedProtocols == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                throw new NullPointerException("Null supportedProtocols");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            this.root = root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            this.event_mask = event_mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            this.supportedProtocols = supportedProtocols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        public long getRoot() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            return root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        public long getEventMask() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            return event_mask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        public boolean hasNonXEmbedClientSites() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            return !nonXEmbedClientSites.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        public synchronized void addSite(long window, boolean isXEmbedClient) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            Long lWindow = Long.valueOf(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            if (!sites.contains(lWindow)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                sites.add(lWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            if (!isXEmbedClient) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                nonXEmbedClientSites.add(lWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        public synchronized void removeSite(long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            Long lWindow = Long.valueOf(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            sites.remove(lWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            nonXEmbedClientSites.remove(lWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        public void setSupportedProtocols(List<XDropTargetProtocol> list) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            supportedProtocols = list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        public List<XDropTargetProtocol> getSupportedProtocols() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            return supportedProtocols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        public boolean hasSites() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            return !sites.isEmpty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        public long[] getSites() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            long[] ret = new long[sites.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            Iterator iter = sites.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            int index = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                Long l = (Long)iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                ret[index++] = l.longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        public long getSite(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            assert XToolkit.isAWTLockHeldByCurrentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            Iterator<Long> iter = sites.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            while (iter.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                Long l = iter.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                long window = l.longValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                Point p = XBaseWindow.toOtherWindow(getRoot(), window, x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                if (p == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                int dest_x = p.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                int dest_y = p.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                if (dest_x >= 0 && dest_y >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                    XWindowAttributes wattr = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                        XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                        int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                                                                      window, wattr.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                        XToolkit.RESTORE_XERROR_HANDLER();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                        if (status == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                            (XToolkit.saved_error != null &&
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   178
                             XToolkit.saved_error.get_error_code() != XConstants.Success)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   182
                        if (wattr.get_map_state() != XConstants.IsUnmapped
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                            && dest_x < wattr.get_width()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                            && dest_y < wattr.get_height()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                            return window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                    } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                        wattr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    private final HashMap<Long, EmbeddedDropSiteEntry> embeddedDropSiteRegistry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        new HashMap<Long, EmbeddedDropSiteEntry>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    private EmbeddedDropSiteEntry registerEmbedderDropSite(long embedder) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        assert XToolkit.isAWTLockHeldByCurrentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        // The list of protocols supported by the embedder.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        List<XDropTargetProtocol> embedderProtocols = new ArrayList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            if (dropTargetProtocol.isProtocolSupported(embedder)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                embedderProtocols.add(dropTargetProtocol);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        embedderProtocols = Collections.unmodifiableList(embedderProtocols);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        /* Grab server, since we are working with the window that belongs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
           another client. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        XlibWrapper.XGrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            long root = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            long event_mask = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            XWindowAttributes wattr = new XWindowAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                                              embedder, wattr.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                XToolkit.RESTORE_XERROR_HANDLER();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                if (status == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                    (XToolkit.saved_error != null &&
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   232
                     XToolkit.saved_error.get_error_code() != XConstants.Success)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                    throw new XException("XGetWindowAttributes failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                event_mask = wattr.get_your_event_mask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                root = wattr.get_root();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                wattr.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   242
            if ((event_mask & XConstants.PropertyChangeMask) == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   245
                                         event_mask | XConstants.PropertyChangeMask);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                XToolkit.RESTORE_XERROR_HANDLER();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                if (XToolkit.saved_error != null &&
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   249
                    XToolkit.saved_error.get_error_code() != XConstants.Success) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                    throw new XException("XSelectInput failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            return new EmbeddedDropSiteEntry(root, event_mask, embedderProtocols);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            XlibWrapper.XUngrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    private static final boolean XEMBED_PROTOCOLS = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    private static final boolean NON_XEMBED_PROTOCOLS = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    private void registerProtocols(long embedder, boolean protocols,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                                   List<XDropTargetProtocol> supportedProtocols) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        Iterator dropTargetProtocols = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
         * By default, we register a drop site that supports all dnd
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
         * protocols. This approach is not appropriate in plugin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
         * scenario if the browser supports Motif DnD and doesn't support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
         * XDnD. If we forcibly set XdndAware on the browser toplevel, any drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
         * source that supports both protocols and prefers XDnD will be unable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
         * to drop anything on the browser.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
         * The solution for this problem is not to register XDnD drop site
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         * if the browser supports only Motif DnD.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
         * In general, if the browser already supports some protocols, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
         * register the embedded drop site only for those protocols. Otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
         * we register the embedded drop site for all protocols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        if (!supportedProtocols.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            dropTargetProtocols = supportedProtocols.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        /* Grab server, since we are working with the window that belongs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
           another client. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        XlibWrapper.XGrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                if ((protocols == XEMBED_PROTOCOLS) ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    dropTargetProtocol.isXEmbedSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    dropTargetProtocol.registerEmbedderDropSite(embedder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            XlibWrapper.XUngrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public void updateEmbedderDropSite(long embedder) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        XBaseWindow xbaseWindow = XToolkit.windowToXWindow(embedder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        // No need to update our own drop sites.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        if (xbaseWindow != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        assert XToolkit.isAWTLockHeldByCurrentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        // The list of protocols supported by the embedder.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        List<XDropTargetProtocol> embedderProtocols = new ArrayList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            if (dropTargetProtocol.isProtocolSupported(embedder)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                embedderProtocols.add(dropTargetProtocol);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        embedderProtocols = Collections.unmodifiableList(embedderProtocols);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   328
        Long lToplevel = Long.valueOf(embedder);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        boolean isXEmbedServer = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            EmbeddedDropSiteEntry entry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            if (entry == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            entry.setSupportedProtocols(embedderProtocols);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            isXEmbedServer = !entry.hasNonXEmbedClientSites();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
         * By default, we register a drop site that supports all dnd
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
         * protocols. This approach is not appropriate in plugin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
         * scenario if the browser supports Motif DnD and doesn't support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
         * XDnD. If we forcibly set XdndAware on the browser toplevel, any drag
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
         * source that supports both protocols and prefers XDnD will be unable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
         * to drop anything on the browser.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
         * The solution for this problem is not to register XDnD drop site
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
         * if the browser supports only Motif DnD.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
         * In general, if the browser already supports some protocols, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
         * register the embedded drop site only for those protocols. Otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
         * we register the embedded drop site for all protocols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        if (!embedderProtocols.isEmpty()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            dropTargetProtocols = embedderProtocols.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        /* Grab server, since we are working with the window that belongs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
           another client. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        XlibWrapper.XGrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                    (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                if (!isXEmbedServer || !dropTargetProtocol.isXEmbedSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                    dropTargetProtocol.registerEmbedderDropSite(embedder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            XlibWrapper.XUngrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    private void unregisterEmbedderDropSite(long embedder,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                                            EmbeddedDropSiteEntry entry) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        assert XToolkit.isAWTLockHeldByCurrentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        /* Grab server, since we are working with the window that belongs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
           another client. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        XlibWrapper.XGrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                    (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                dropTargetProtocol.unregisterEmbedderDropSite(embedder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            long event_mask = entry.getEventMask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            /* Restore the original event mask for the embedder. */
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   396
            if ((event_mask & XConstants.PropertyChangeMask) == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                XToolkit.WITH_XERROR_HANDLER(XToolkit.IgnoreBadWindowHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                XlibWrapper.XSelectInput(XToolkit.getDisplay(), embedder,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                                         event_mask);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                XToolkit.RESTORE_XERROR_HANDLER();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                if (XToolkit.saved_error != null &&
439
3488710b02f8 6623459: Get rid of XConstant, XProtocolConstants and XUtilConstants antipattern
dav
parents: 438
diff changeset
   403
                    XToolkit.saved_error.get_error_code() != XConstants.Success) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                    throw new XException("XSelectInput failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            XlibWrapper.XUngrabServer(XToolkit.getDisplay());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    private void registerEmbeddedDropSite(long toplevel, long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        XBaseWindow xBaseWindow = XToolkit.windowToXWindow(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        boolean isXEmbedClient =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            (xBaseWindow instanceof XEmbeddedFramePeer) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            ((XEmbeddedFramePeer)xBaseWindow).isXEmbedActive();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        XEmbedCanvasPeer peer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            XBaseWindow xbaseWindow = XToolkit.windowToXWindow(toplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            if (xbaseWindow != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                if (xbaseWindow instanceof XEmbedCanvasPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                    peer = (XEmbedCanvasPeer)xbaseWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                    throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        Long lToplevel = Long.valueOf(toplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        EmbeddedDropSiteEntry entry = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            entry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            if (entry == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                    // Toplevel is an XEmbed server within this VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                    // Register an XEmbed drop site.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    peer.setXEmbedDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    // Create a dummy entry to register the embedded site.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    entry = new EmbeddedDropSiteEntry(0, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                                                      Collections.<XDropTargetProtocol>emptyList());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                    // Foreign toplevel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                    // Select for PropertyNotify events on the toplevel, so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                    // we can track changes of the properties relevant to DnD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                    // protocols.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                    entry = registerEmbedderDropSite(toplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                    // Register the toplevel with all DnD protocols that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    // supported by XEmbed - actually setup a proxy, so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                    // all DnD notifications sent to the toplevel are first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    // routed to us.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                    registerProtocols(toplevel, NON_XEMBED_PROTOCOLS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                      entry.getSupportedProtocols());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                embeddedDropSiteRegistry.put(lToplevel, entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        assert entry != null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        synchronized (entry) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            // For a foreign toplevel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                if (!isXEmbedClient) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                    // Since this is not an XEmbed client we can no longer rely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                    // on XEmbed to route DnD notifications even for DnD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                    // protocols that are supported by XEmbed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                    // We rollback to the XEmbed-unfriendly solution - setup
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                    // a proxy, so that all DnD notifications sent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                    // toplevel are first routed to us.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                    registerProtocols(toplevel, XEMBED_PROTOCOLS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                                      entry.getSupportedProtocols());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                    Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
                        XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                    // Register the embedded window as a plain drop site with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    // all DnD protocols that are supported by XEmbed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                        XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                            (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                        if (dropTargetProtocol.isXEmbedSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                            dropTargetProtocol.registerEmbedderDropSite(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            entry.addSite(window, isXEmbedClient);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    private void unregisterEmbeddedDropSite(long toplevel, long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        Long lToplevel = Long.valueOf(toplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        EmbeddedDropSiteEntry entry = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            entry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            if (entry == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            entry.removeSite(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            if (!entry.hasSites()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                embeddedDropSiteRegistry.remove(lToplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                XBaseWindow xbaseWindow = XToolkit.windowToXWindow(toplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                if (xbaseWindow != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    if (xbaseWindow instanceof XEmbedCanvasPeer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                        XEmbedCanvasPeer peer = (XEmbedCanvasPeer)xbaseWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
                        // Unregister an XEmbed drop site.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
                        peer.removeXEmbedDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                    unregisterEmbedderDropSite(toplevel, entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * Returns a drop site that is embedded in the specified embedder window and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * contains the point with the specified root coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    public long getEmbeddedDropSite(long embedder, int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        Long lToplevel = Long.valueOf(embedder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        EmbeddedDropSiteEntry entry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            (EmbeddedDropSiteEntry)embeddedDropSiteRegistry.get(lToplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        if (entry == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        return entry.getSite(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    public void registerDropSite(long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        if (window == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        XDropTargetEventProcessor.activate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            long toplevel = getToplevelWindow(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
             * No window with WM_STATE property is found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
             * Since the window can be a plugin window reparented to the browser
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
             * toplevel, we cannot determine which window will eventually have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
             * WM_STATE property set. So we schedule a timer callback that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
             * periodically attempt to find an ancestor with WM_STATE and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
             * register the drop site appropriately.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            if (toplevel == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                addDelayedRegistrationEntry(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            if (toplevel == window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                    XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                        (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                    dropTargetProtocol.registerDropTarget(toplevel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                registerEmbeddedDropSite(toplevel, window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    public void unregisterDropSite(long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        if (window == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            throw new IllegalArgumentException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            long toplevel = getToplevelWindow(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            if (toplevel == window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                Iterator dropProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                    XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                removeDelayedRegistrationEntry(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                while (dropProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                    XDropTargetProtocol dropProtocol = (XDropTargetProtocol)dropProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                    dropProtocol.unregisterDropTarget(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                unregisterEmbeddedDropSite(toplevel, window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    public void registerXEmbedClient(long canvasWindow, long clientWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        // If the client has an associated XDnD drop site, add a drop target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        // to the XEmbedCanvasPeer's target to route drag notifications to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        // client.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        XDragSourceProtocol xdndDragProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            XDragAndDropProtocols.getDragSourceProtocol(XDragAndDropProtocols.XDnD);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        XDragSourceProtocol.TargetWindowInfo info =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            xdndDragProtocol.getTargetWindowInfo(clientWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        if (info != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            info.getProtocolVersion() >= XDnDConstants.XDND_MIN_PROTOCOL_VERSION) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            if (logger.isLoggable(Level.FINE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                logger.fine("        XEmbed drop site will be registered for " + Long.toHexString(clientWindow));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            registerEmbeddedDropSite(canvasWindow, clientWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                    (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                dropTargetProtocol.registerEmbeddedDropSite(clientWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            if (logger.isLoggable(Level.FINE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                logger.fine("        XEmbed drop site has been registered for " + Long.toHexString(clientWindow));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    public void unregisterXEmbedClient(long canvasWindow, long clientWindow) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        if (logger.isLoggable(Level.FINE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            logger.fine("        XEmbed drop site will be unregistered for " + Long.toHexString(clientWindow));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        Iterator dropTargetProtocols =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            XDragAndDropProtocols.getDropTargetProtocols();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        while (dropTargetProtocols.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            XDropTargetProtocol dropTargetProtocol =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
                (XDropTargetProtocol)dropTargetProtocols.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            dropTargetProtocol.unregisterEmbeddedDropSite(clientWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        unregisterEmbeddedDropSite(canvasWindow, clientWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        if (logger.isLoggable(Level.FINE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            logger.fine("        XEmbed drop site has beed unregistered for " + Long.toHexString(clientWindow));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    /**************** Delayed drop site registration *******************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    private void addDelayedRegistrationEntry(final long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        Long lWindow = Long.valueOf(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        Runnable runnable = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                    removeDelayedRegistrationEntry(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                    registerDropSite(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            removeDelayedRegistrationEntry(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            delayedRegistrationMap.put(lWindow, runnable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            XToolkit.schedule(runnable, DELAYED_REGISTRATION_PERIOD);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    private void removeDelayedRegistrationEntry(long window) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        Long lWindow = Long.valueOf(window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        XToolkit.awtLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
            Runnable runnable = delayedRegistrationMap.remove(lWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            if (runnable != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                XToolkit.remove(runnable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            XToolkit.awtUnlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    /*******************************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
}