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