jdk/src/solaris/classes/sun/awt/X11/XDnDConstants.java
author yan
Mon, 06 Oct 2008 16:45:00 +0400
changeset 1966 12a51fb0db0d
parent 117 766ae458aaf1
child 5506 202f599c92aa
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
/*
117
766ae458aaf1 6538066: XSelection should be more passive
son
parents: 2
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.awt.dnd.DnDConstants;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * XDnD protocol global constants.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
class XDnDConstants {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    static final XAtom XA_XdndActionCopy = XAtom.get("XdndActionCopy");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    static final XAtom XA_XdndActionMove = XAtom.get("XdndActionMove");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    static final XAtom XA_XdndActionLink = XAtom.get("XdndActionLink");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    static final XAtom XA_XdndActionList = XAtom.get("XdndActionList");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    static final XAtom XA_XdndTypeList   = XAtom.get("XdndTypeList");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    static final XAtom XA_XdndAware      = XAtom.get("XdndAware");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    static final XAtom XA_XdndProxy      = XAtom.get("XdndProxy");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    static final XAtom XA_XdndSelection  = XAtom.get("XdndSelection");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    static final XAtom XA_XdndEnter      = XAtom.get("XdndEnter");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static final XAtom XA_XdndPosition   = XAtom.get("XdndPosition");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static final XAtom XA_XdndLeave      = XAtom.get("XdndLeave");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    static final XAtom XA_XdndDrop       = XAtom.get("XdndDrop");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static final XAtom XA_XdndStatus     = XAtom.get("XdndStatus");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    static final XAtom XA_XdndFinished   = XAtom.get("XdndFinished");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
117
766ae458aaf1 6538066: XSelection should be more passive
son
parents: 2
diff changeset
    51
    static final XSelection XDnDSelection = new XSelection(XA_XdndSelection);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public static final int XDND_MIN_PROTOCOL_VERSION = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    public static final int XDND_PROTOCOL_VERSION     = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    public static final int XDND_PROTOCOL_MASK        = 0xFF000000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    public static final int XDND_PROTOCOL_SHIFT       = 24;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    public static final int XDND_DATA_TYPES_BIT       = 0x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public static final int XDND_ACCEPT_DROP_FLAG     = 0x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private XDnDConstants() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    static long getXDnDActionForJavaAction(int javaAction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        switch (javaAction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        case DnDConstants.ACTION_COPY : return XA_XdndActionCopy.getAtom();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        case DnDConstants.ACTION_MOVE : return XA_XdndActionMove.getAtom();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        case DnDConstants.ACTION_LINK : return XA_XdndActionLink.getAtom();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        default                       : return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    static int getJavaActionForXDnDAction(long xdndAction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        if (xdndAction == XA_XdndActionCopy.getAtom()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            return DnDConstants.ACTION_COPY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        } else if (xdndAction == XA_XdndActionMove.getAtom()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            return DnDConstants.ACTION_MOVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        } else if (xdndAction == XA_XdndActionLink.getAtom()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            return DnDConstants.ACTION_LINK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            return DnDConstants.ACTION_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
}