src/java.desktop/unix/classes/sun/awt/X11/XDragSourceContextPeer.java

Print this page


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


  93     private long proxyModeSourceWindow = 0;
  94 
  95     /* The singleton instance. */
  96     private static final XDragSourceContextPeer theInstance =
  97         new XDragSourceContextPeer(null);
  98 
  99     private XDragSourceContextPeer(DragGestureEvent dge) {
 100         super(dge);
 101     }
 102 
 103     static XDragSourceProtocolListener getXDragSourceProtocolListener() {
 104         return theInstance;
 105     }
 106 
 107     static XDragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
 108       throws InvalidDnDOperationException {
 109     theInstance.setTrigger(dge);
 110         return theInstance;
 111     }
 112 
 113     @SuppressWarnings("deprecation")
 114     protected void startDrag(Transferable transferable,
 115                              long[] formats, Map<Long, DataFlavor> formatMap) {
 116         Component component = getTrigger().getComponent();
 117         Component c = null;
 118         XWindowPeer wpeer = null;
 119 
 120         for (c = component; c != null && !(c instanceof Window);
 121              c = AWTAccessor.getComponentAccessor().getParent(c));
 122 
 123         if (c instanceof Window) {
 124             wpeer = (XWindowPeer)c.getPeer();
 125         }
 126 
 127         if (wpeer == null) {
 128             throw new InvalidDnDOperationException(
 129                 "Cannot find top-level for the drag source component");
 130         }
 131 
 132         long xcursor = 0;
 133         long rootWindow = 0;
 134         long dragWindow = 0;
 135         long timeStamp = 0;
 136 
 137         /* Retrieve the X cursor for the drag operation. */
 138         {
 139             Cursor cursor = getCursor();
 140             if (cursor != null) {
 141                 xcursor = XGlobalCursorManager.getCursor(cursor);
 142             }
 143         }
 144 


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


  93     private long proxyModeSourceWindow = 0;
  94 
  95     /* The singleton instance. */
  96     private static final XDragSourceContextPeer theInstance =
  97         new XDragSourceContextPeer(null);
  98 
  99     private XDragSourceContextPeer(DragGestureEvent dge) {
 100         super(dge);
 101     }
 102 
 103     static XDragSourceProtocolListener getXDragSourceProtocolListener() {
 104         return theInstance;
 105     }
 106 
 107     static XDragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
 108       throws InvalidDnDOperationException {
 109     theInstance.setTrigger(dge);
 110         return theInstance;
 111     }
 112 

 113     protected void startDrag(Transferable transferable,
 114                              long[] formats, Map<Long, DataFlavor> formatMap) {
 115         Component component = getTrigger().getComponent();
 116         Component c = null;
 117         XWindowPeer wpeer = null;
 118 
 119         for (c = component; c != null && !(c instanceof Window);
 120              c = AWTAccessor.getComponentAccessor().getParent(c));
 121 
 122         if (c instanceof Window) {
 123             wpeer = AWTAccessor.getComponentAccessor().getPeer(c);
 124         }
 125 
 126         if (wpeer == null) {
 127             throw new InvalidDnDOperationException(
 128                 "Cannot find top-level for the drag source component");
 129         }
 130 
 131         long xcursor = 0;
 132         long rootWindow = 0;
 133         long dragWindow = 0;
 134         long timeStamp = 0;
 135 
 136         /* Retrieve the X cursor for the drag operation. */
 137         {
 138             Cursor cursor = getCursor();
 139             if (cursor != null) {
 140                 xcursor = XGlobalCursorManager.getCursor(cursor);
 141             }
 142         }
 143