1 /* 2 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.awt.X11; 27 28 import java.awt.dnd.DnDConstants; 29 30 /** 31 * XDnD protocol global constants. 32 * 33 * @since 1.5 34 */ 35 class XDnDConstants { 36 static final XAtom XA_XdndActionCopy = XAtom.get("XdndActionCopy"); 37 static final XAtom XA_XdndActionMove = XAtom.get("XdndActionMove"); 38 static final XAtom XA_XdndActionLink = XAtom.get("XdndActionLink"); 39 static final XAtom XA_XdndActionList = XAtom.get("XdndActionList"); 40 static final XAtom XA_XdndTypeList = XAtom.get("XdndTypeList"); 41 static final XAtom XA_XdndAware = XAtom.get("XdndAware"); 42 static final XAtom XA_XdndProxy = XAtom.get("XdndProxy"); 43 static final XAtom XA_XdndSelection = XAtom.get("XdndSelection"); 44 static final XAtom XA_XdndEnter = XAtom.get("XdndEnter"); 45 static final XAtom XA_XdndPosition = XAtom.get("XdndPosition"); 46 static final XAtom XA_XdndLeave = XAtom.get("XdndLeave"); 47 static final XAtom XA_XdndDrop = XAtom.get("XdndDrop"); 48 static final XAtom XA_XdndStatus = XAtom.get("XdndStatus"); 49 static final XAtom XA_XdndFinished = XAtom.get("XdndFinished"); 50 51 static final XSelection XDnDSelection = new XSelection(XA_XdndSelection); 52 53 public static final int XDND_MIN_PROTOCOL_VERSION = 3; 54 public static final int XDND_PROTOCOL_VERSION = 5; 55 56 public static final int XDND_PROTOCOL_MASK = 0xFF000000; 57 public static final int XDND_PROTOCOL_SHIFT = 24; 58 public static final int XDND_DATA_TYPES_BIT = 0x1; 59 public static final int XDND_ACCEPT_DROP_FLAG = 0x1; 60 XDnDConstants()61 private XDnDConstants() {} 62 getXDnDActionForJavaAction(int javaAction)63 static long getXDnDActionForJavaAction(int javaAction) { 64 switch (javaAction) { 65 case DnDConstants.ACTION_COPY : return XA_XdndActionCopy.getAtom(); 66 case DnDConstants.ACTION_MOVE : return XA_XdndActionMove.getAtom(); 67 case DnDConstants.ACTION_LINK : return XA_XdndActionLink.getAtom(); 68 default : return 0; 69 } 70 } 71 getJavaActionForXDnDAction(long xdndAction)72 static int getJavaActionForXDnDAction(long xdndAction) { 73 if (xdndAction == XA_XdndActionCopy.getAtom()) { 74 return DnDConstants.ACTION_COPY; 75 } else if (xdndAction == XA_XdndActionMove.getAtom()) { 76 return DnDConstants.ACTION_MOVE; 77 } else if (xdndAction == XA_XdndActionLink.getAtom()) { 78 return DnDConstants.ACTION_LINK; 79 } else { 80 return DnDConstants.ACTION_NONE; 81 } 82 } 83 } 84