src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java

Print this page


   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


  79 
  80         long data = Native.allocateLongArray(3);
  81         int action_count = 0;
  82         try {
  83             if ((actions & DnDConstants.ACTION_COPY) != 0) {
  84                 Native.putLong(data, action_count,
  85                                XDnDConstants.XA_XdndActionCopy.getAtom());
  86                 action_count++;
  87             }
  88             if ((actions & DnDConstants.ACTION_MOVE) != 0) {
  89                 Native.putLong(data, action_count,
  90                                XDnDConstants.XA_XdndActionMove.getAtom());
  91                 action_count++;
  92             }
  93             if ((actions & DnDConstants.ACTION_LINK) != 0) {
  94                 Native.putLong(data, action_count,
  95                                XDnDConstants.XA_XdndActionLink.getAtom());
  96                 action_count++;
  97             }
  98 
  99             XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
 100             XDnDConstants.XA_XdndActionList.setAtomData(window,
 101                                                         XAtom.XA_ATOM,
 102                                                         data, action_count);
 103             XToolkit.RESTORE_XERROR_HANDLER();
 104 
 105             if (XToolkit.saved_error != null &&
 106                 XToolkit.saved_error.get_error_code() != XConstants.Success) {
 107                 cleanup();
 108                 throw new XException("Cannot write XdndActionList property");
 109             }
 110         } finally {
 111             unsafe.freeMemory(data);
 112             data = 0;
 113         }
 114 
 115         data = Native.allocateLongArray(formats.length);
 116 
 117         try {
 118             Native.put(data, formats);
 119 
 120             XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
 121             XDnDConstants.XA_XdndTypeList.setAtomData(window,
 122                                                       XAtom.XA_ATOM,
 123                                                       data, formats.length);
 124             XToolkit.RESTORE_XERROR_HANDLER();
 125 
 126             if (XToolkit.saved_error != null &&
 127                 XToolkit.saved_error.get_error_code() != XConstants.Success) {
 128                 cleanup();
 129                 throw new XException("Cannot write XdndActionList property");
 130             }
 131         } finally {
 132             unsafe.freeMemory(data);
 133             data = 0;
 134         }
 135 
 136         if (!XDnDConstants.XDnDSelection.setOwner(contents, formatMap, formats,
 137                                                   XConstants.CurrentTime)) {
 138             cleanup();
 139             throw new InvalidDnDOperationException("Cannot acquire selection ownership");
 140         }
 141     }
 142 
 143     private boolean processXdndStatus(XClientMessageEvent xclient) {
 144         int action = DnDConstants.ACTION_NONE;
 145 
 146         /* Ignore XDnD messages from all other windows. */
 147         if (xclient.get_data(0) != getTargetWindow()) {


   1 /*
   2  * Copyright (c) 2003, 2013, 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


  79 
  80         long data = Native.allocateLongArray(3);
  81         int action_count = 0;
  82         try {
  83             if ((actions & DnDConstants.ACTION_COPY) != 0) {
  84                 Native.putLong(data, action_count,
  85                                XDnDConstants.XA_XdndActionCopy.getAtom());
  86                 action_count++;
  87             }
  88             if ((actions & DnDConstants.ACTION_MOVE) != 0) {
  89                 Native.putLong(data, action_count,
  90                                XDnDConstants.XA_XdndActionMove.getAtom());
  91                 action_count++;
  92             }
  93             if ((actions & DnDConstants.ACTION_LINK) != 0) {
  94                 Native.putLong(data, action_count,
  95                                XDnDConstants.XA_XdndActionLink.getAtom());
  96                 action_count++;
  97             }
  98 
  99             XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
 100             XDnDConstants.XA_XdndActionList.setAtomData(window,
 101                                                         XAtom.XA_ATOM,
 102                                                         data, action_count);
 103             XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
 104 
 105             if ((XErrorHandlerUtil.saved_error) != null &&
 106                 (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success)) {
 107                 cleanup();
 108                 throw new XException("Cannot write XdndActionList property");
 109             }
 110         } finally {
 111             unsafe.freeMemory(data);
 112             data = 0;
 113         }
 114 
 115         data = Native.allocateLongArray(formats.length);
 116 
 117         try {
 118             Native.put(data, formats);
 119 
 120             XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
 121             XDnDConstants.XA_XdndTypeList.setAtomData(window,
 122                                                       XAtom.XA_ATOM,
 123                                                       data, formats.length);
 124             XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
 125 
 126             if ((XErrorHandlerUtil.saved_error != null) &&
 127                 (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success)) {
 128                 cleanup();
 129                 throw new XException("Cannot write XdndActionList property");
 130             }
 131         } finally {
 132             unsafe.freeMemory(data);
 133             data = 0;
 134         }
 135 
 136         if (!XDnDConstants.XDnDSelection.setOwner(contents, formatMap, formats,
 137                                                   XConstants.CurrentTime)) {
 138             cleanup();
 139             throw new InvalidDnDOperationException("Cannot acquire selection ownership");
 140         }
 141     }
 142 
 143     private boolean processXdndStatus(XClientMessageEvent xclient) {
 144         int action = DnDConstants.ACTION_NONE;
 145 
 146         /* Ignore XDnD messages from all other windows. */
 147         if (xclient.get_data(0) != getTargetWindow()) {