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.datatransfer.Transferable;
29
30 import java.awt.dnd.DnDConstants;
31 import java.awt.dnd.InvalidDnDOperationException;
32
33 import java.util.Map;
34
35 import sun.misc.Unsafe;
36
37 /**
38 * XDragSourceProtocol implementation for Motif DnD protocol.
39 *
40 * @since 1.5
41 */
42 class MotifDnDDragSourceProtocol extends XDragSourceProtocol
43 implements XEventDispatcher {
44
45 private static final Unsafe unsafe = XlibWrapper.unsafe;
46
47 private long targetEnterServerTime = XConstants.CurrentTime;
48
49 protected MotifDnDDragSourceProtocol(XDragSourceProtocolListener listener) {
50 super(listener);
51 XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), this);
52 }
53
54 /**
55 * Creates an instance associated with the specified listener.
56 *
57 * @throws NullPointerException if listener is <code>null</code>.
58 */
59 static XDragSourceProtocol createInstance(XDragSourceProtocolListener listener) {
60 return new MotifDnDDragSourceProtocol(listener);
61 }
62
63 public String getProtocolName() {
64 return XDragAndDropProtocols.MotifDnD;
65 }
66
67 protected void initializeDragImpl(int actions, Transferable contents,
68 Map formatMap, long[] formats)
69 throws InvalidDnDOperationException,
70 IllegalArgumentException, XException {
71
72 long window = XDragSourceProtocol.getDragSourceWindow();
73
74 /* Write the Motif DnD initiator info on the root XWindow. */
75 try {
76 int index = MotifDnDConstants.getIndexForTargetList(formats);
77
78 MotifDnDConstants.writeDragInitiatorInfoStruct(window, index);
79 } catch (XException xe) {
80 cleanup();
81 throw xe;
82 } catch (InvalidDnDOperationException idoe) {
83 cleanup();
84 throw idoe;
85 }
86
87 if (!MotifDnDConstants.MotifDnDSelection.setOwner(contents, formatMap,
88 formats,
|
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.datatransfer.Transferable;
29 import java.awt.datatransfer.DataFlavor;
30
31 import java.awt.dnd.DnDConstants;
32 import java.awt.dnd.InvalidDnDOperationException;
33
34 import java.util.Map;
35
36 import sun.misc.Unsafe;
37
38 /**
39 * XDragSourceProtocol implementation for Motif DnD protocol.
40 *
41 * @since 1.5
42 */
43 class MotifDnDDragSourceProtocol extends XDragSourceProtocol
44 implements XEventDispatcher {
45
46 private static final Unsafe unsafe = XlibWrapper.unsafe;
47
48 private long targetEnterServerTime = XConstants.CurrentTime;
49
50 protected MotifDnDDragSourceProtocol(XDragSourceProtocolListener listener) {
51 super(listener);
52 XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), this);
53 }
54
55 /**
56 * Creates an instance associated with the specified listener.
57 *
58 * @throws NullPointerException if listener is <code>null</code>.
59 */
60 static XDragSourceProtocol createInstance(XDragSourceProtocolListener listener) {
61 return new MotifDnDDragSourceProtocol(listener);
62 }
63
64 public String getProtocolName() {
65 return XDragAndDropProtocols.MotifDnD;
66 }
67
68 protected void initializeDragImpl(int actions, Transferable contents,
69 Map<Long, DataFlavor> formatMap, long[] formats)
70 throws InvalidDnDOperationException,
71 IllegalArgumentException, XException {
72
73 long window = XDragSourceProtocol.getDragSourceWindow();
74
75 /* Write the Motif DnD initiator info on the root XWindow. */
76 try {
77 int index = MotifDnDConstants.getIndexForTargetList(formats);
78
79 MotifDnDConstants.writeDragInitiatorInfoStruct(window, index);
80 } catch (XException xe) {
81 cleanup();
82 throw xe;
83 } catch (InvalidDnDOperationException idoe) {
84 cleanup();
85 throw idoe;
86 }
87
88 if (!MotifDnDConstants.MotifDnDSelection.setOwner(contents, formatMap,
89 formats,
|