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
23 * questions.
24 */
25
26 package sun.awt.X11;
27
28 import java.awt.Component;
29 import java.awt.peer.ComponentPeer;
30
31 import java.io.IOException;
32
33 import java.util.Iterator;
34
35 import sun.util.logging.PlatformLogger;
36
37 import sun.awt.AppContext;
38 import sun.awt.SunToolkit;
39
40 import sun.awt.dnd.SunDropTargetContextPeer;
41 import sun.awt.dnd.SunDropTargetEvent;
42
43 import sun.misc.Unsafe;
44
45 /**
46 * The XDropTargetContextPeer is the class responsible for handling
47 * the interaction between the XDnD/Motif DnD subsystem and Java drop targets.
48 *
49 * @since 1.5
50 */
51 final class XDropTargetContextPeer extends SunDropTargetContextPeer {
52 private static final PlatformLogger logger =
53 PlatformLogger.getLogger("sun.awt.X11.xembed.xdnd.XDropTargetContextPeer");
54
171 super.processExitMessage(event);
172 }
173 }
174
175 protected void processMotionMessage(SunDropTargetEvent event,
176 boolean operationChanged) {
177 if (!processSunDropTargetEvent(event)) {
178 super.processMotionMessage(event, operationChanged);
179 }
180 }
181
182 protected void processDropMessage(SunDropTargetEvent event) {
183 if (!processSunDropTargetEvent(event)) {
184 super.processDropMessage(event);
185 }
186 }
187
188 // If source is an XEmbedCanvasPeer, passes the event to it for processing and
189 // return true if the event is forwarded to the XEmbed child.
190 // Otherwise, does nothing and return false.
191 @SuppressWarnings("deprecation")
192 private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
193 Object source = event.getSource();
194
195 if (source instanceof Component) {
196 ComponentPeer peer = ((Component)source).getPeer();
197 if (peer instanceof XEmbedCanvasPeer) {
198 XEmbedCanvasPeer xEmbedCanvasPeer = (XEmbedCanvasPeer)peer;
199 /* The native context is the pointer to the XClientMessageEvent
200 structure. */
201 long ctxt = getNativeDragContext();
202
203 if (logger.isLoggable(PlatformLogger.Level.FINER)) {
204 logger.finer(" processing " + event + " ctxt=" + ctxt +
205 " consumed=" + event.isConsumed());
206 }
207 /* If the event is not consumed, pass it to the
208 XEmbedCanvasPeer for processing. */
209 if (!event.isConsumed()) {
210 // NOTE: ctxt can be zero at this point.
211 if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
212 event.getID())) {
213 event.consume();
214 return true;
215 }
216 }
|
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
23 * questions.
24 */
25
26 package sun.awt.X11;
27
28 import java.awt.Component;
29 import java.awt.peer.ComponentPeer;
30
31 import java.io.IOException;
32
33 import java.util.Iterator;
34
35 import sun.awt.AWTAccessor;
36 import sun.util.logging.PlatformLogger;
37
38 import sun.awt.AppContext;
39 import sun.awt.SunToolkit;
40
41 import sun.awt.dnd.SunDropTargetContextPeer;
42 import sun.awt.dnd.SunDropTargetEvent;
43
44 import sun.misc.Unsafe;
45
46 /**
47 * The XDropTargetContextPeer is the class responsible for handling
48 * the interaction between the XDnD/Motif DnD subsystem and Java drop targets.
49 *
50 * @since 1.5
51 */
52 final class XDropTargetContextPeer extends SunDropTargetContextPeer {
53 private static final PlatformLogger logger =
54 PlatformLogger.getLogger("sun.awt.X11.xembed.xdnd.XDropTargetContextPeer");
55
172 super.processExitMessage(event);
173 }
174 }
175
176 protected void processMotionMessage(SunDropTargetEvent event,
177 boolean operationChanged) {
178 if (!processSunDropTargetEvent(event)) {
179 super.processMotionMessage(event, operationChanged);
180 }
181 }
182
183 protected void processDropMessage(SunDropTargetEvent event) {
184 if (!processSunDropTargetEvent(event)) {
185 super.processDropMessage(event);
186 }
187 }
188
189 // If source is an XEmbedCanvasPeer, passes the event to it for processing and
190 // return true if the event is forwarded to the XEmbed child.
191 // Otherwise, does nothing and return false.
192 private boolean processSunDropTargetEvent(SunDropTargetEvent event) {
193 Object source = event.getSource();
194
195 if (source instanceof Component) {
196 Object peer = AWTAccessor.getComponentAccessor()
197 .getPeer((Component) source);
198 if (peer instanceof XEmbedCanvasPeer) {
199 XEmbedCanvasPeer xEmbedCanvasPeer = (XEmbedCanvasPeer)peer;
200 /* The native context is the pointer to the XClientMessageEvent
201 structure. */
202 long ctxt = getNativeDragContext();
203
204 if (logger.isLoggable(PlatformLogger.Level.FINER)) {
205 logger.finer(" processing " + event + " ctxt=" + ctxt +
206 " consumed=" + event.isConsumed());
207 }
208 /* If the event is not consumed, pass it to the
209 XEmbedCanvasPeer for processing. */
210 if (!event.isConsumed()) {
211 // NOTE: ctxt can be zero at this point.
212 if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
213 event.getID())) {
214 event.consume();
215 return true;
216 }
217 }
|