72
73 return peer;
74 }
75 }
76
77 static XDropTargetProtocolListener getXDropTargetProtocolListener() {
78 return XDropTargetProtocolListenerImpl.getInstance();
79 }
80
81 /*
82 * @param returnValue the drop action selected by the Java drop target.
83 */
84 protected void eventProcessed(SunDropTargetEvent e, int returnValue,
85 boolean dispatcherDone) {
86 /* The native context is the pointer to the XClientMessageEvent
87 structure. */
88 long ctxt = getNativeDragContext();
89 /* If the event was not consumed, send a response to the source. */
90 try {
91 if (ctxt != 0 && !e.isConsumed()) {
92 Iterator dropTargetProtocols =
93 XDragAndDropProtocols.getDropTargetProtocols();
94
95 while (dropTargetProtocols.hasNext()) {
96 XDropTargetProtocol dropTargetProtocol =
97 (XDropTargetProtocol)dropTargetProtocols.next();
98 if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
99 returnValue)) {
100 break;
101 }
102 }
103 }
104 } finally {
105 if (dispatcherDone && ctxt != 0) {
106 unsafe.freeMemory(ctxt);
107 }
108 }
109 }
110
111 protected void doDropDone(boolean success, int dropAction,
112 boolean isLocal) {
113 /* The native context is the pointer to the XClientMessageEvent
114 structure. */
115 long ctxt = getNativeDragContext();
116
117 if (ctxt != 0) {
118 try {
119 Iterator dropTargetProtocols =
120 XDragAndDropProtocols.getDropTargetProtocols();
121
122 while (dropTargetProtocols.hasNext()) {
123 XDropTargetProtocol dropTargetProtocol =
124 (XDropTargetProtocol)dropTargetProtocols.next();
125 if (dropTargetProtocol.sendDropDone(ctxt, success,
126 dropAction)) {
127 break;
128 }
129 }
130 } finally {
131 unsafe.freeMemory(ctxt);
132 }
133 }
134 }
135
136 protected Object getNativeData(long format)
137 throws IOException {
138 /* The native context is the pointer to the XClientMessageEvent
139 structure. */
140 long ctxt = getNativeDragContext();
141
142 if (ctxt != 0) {
143 Iterator dropTargetProtocols =
144 XDragAndDropProtocols.getDropTargetProtocols();
145
146 while (dropTargetProtocols.hasNext()) {
147 XDropTargetProtocol dropTargetProtocol =
148 (XDropTargetProtocol)dropTargetProtocols.next();
149 // getData throws IAE if ctxt is not for this protocol.
150 try {
151 return dropTargetProtocol.getData(ctxt, format);
152 } catch (IllegalArgumentException iae) {
153 }
154 }
155 }
156
157 return null;
158 }
159
160 private void cleanup() {
161 }
162
163 protected void processEnterMessage(SunDropTargetEvent event) {
164 if (!processSunDropTargetEvent(event)) {
165 super.processEnterMessage(event);
166 }
167 }
168
204 " consumed=" + event.isConsumed());
205 }
206 /* If the event is not consumed, pass it to the
207 XEmbedCanvasPeer for processing. */
208 if (!event.isConsumed()) {
209 // NOTE: ctxt can be zero at this point.
210 if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
211 event.getID())) {
212 event.consume();
213 return true;
214 }
215 }
216 }
217 }
218
219 return false;
220 }
221
222 public void forwardEventToEmbedded(long embedded, long ctxt,
223 int eventID) {
224 Iterator dropTargetProtocols =
225 XDragAndDropProtocols.getDropTargetProtocols();
226
227 while (dropTargetProtocols.hasNext()) {
228 XDropTargetProtocol dropTargetProtocol =
229 (XDropTargetProtocol)dropTargetProtocols.next();
230 if (dropTargetProtocol.forwardEventToEmbedded(embedded, ctxt,
231 eventID)) {
232 break;
233 }
234 }
235 }
236
237 static final class XDropTargetProtocolListenerImpl
238 implements XDropTargetProtocolListener {
239
240 private final static XDropTargetProtocolListener theInstance =
241 new XDropTargetProtocolListenerImpl();
242
243 private XDropTargetProtocolListenerImpl() {}
244
245 static XDropTargetProtocolListener getInstance() {
246 return theInstance;
247 }
248
249 public void handleDropTargetNotification(XWindow xwindow, int x, int y,
|
72
73 return peer;
74 }
75 }
76
77 static XDropTargetProtocolListener getXDropTargetProtocolListener() {
78 return XDropTargetProtocolListenerImpl.getInstance();
79 }
80
81 /*
82 * @param returnValue the drop action selected by the Java drop target.
83 */
84 protected void eventProcessed(SunDropTargetEvent e, int returnValue,
85 boolean dispatcherDone) {
86 /* The native context is the pointer to the XClientMessageEvent
87 structure. */
88 long ctxt = getNativeDragContext();
89 /* If the event was not consumed, send a response to the source. */
90 try {
91 if (ctxt != 0 && !e.isConsumed()) {
92 Iterator<XDropTargetProtocol> dropTargetProtocols =
93 XDragAndDropProtocols.getDropTargetProtocols();
94
95 while (dropTargetProtocols.hasNext()) {
96 XDropTargetProtocol dropTargetProtocol =
97 dropTargetProtocols.next();
98 if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
99 returnValue)) {
100 break;
101 }
102 }
103 }
104 } finally {
105 if (dispatcherDone && ctxt != 0) {
106 unsafe.freeMemory(ctxt);
107 }
108 }
109 }
110
111 protected void doDropDone(boolean success, int dropAction,
112 boolean isLocal) {
113 /* The native context is the pointer to the XClientMessageEvent
114 structure. */
115 long ctxt = getNativeDragContext();
116
117 if (ctxt != 0) {
118 try {
119 Iterator<XDropTargetProtocol> dropTargetProtocols =
120 XDragAndDropProtocols.getDropTargetProtocols();
121
122 while (dropTargetProtocols.hasNext()) {
123 XDropTargetProtocol dropTargetProtocol =
124 dropTargetProtocols.next();
125 if (dropTargetProtocol.sendDropDone(ctxt, success,
126 dropAction)) {
127 break;
128 }
129 }
130 } finally {
131 unsafe.freeMemory(ctxt);
132 }
133 }
134 }
135
136 protected Object getNativeData(long format)
137 throws IOException {
138 /* The native context is the pointer to the XClientMessageEvent
139 structure. */
140 long ctxt = getNativeDragContext();
141
142 if (ctxt != 0) {
143 Iterator<XDropTargetProtocol> dropTargetProtocols =
144 XDragAndDropProtocols.getDropTargetProtocols();
145
146 while (dropTargetProtocols.hasNext()) {
147 XDropTargetProtocol dropTargetProtocol =
148 dropTargetProtocols.next();
149 // getData throws IAE if ctxt is not for this protocol.
150 try {
151 return dropTargetProtocol.getData(ctxt, format);
152 } catch (IllegalArgumentException iae) {
153 }
154 }
155 }
156
157 return null;
158 }
159
160 private void cleanup() {
161 }
162
163 protected void processEnterMessage(SunDropTargetEvent event) {
164 if (!processSunDropTargetEvent(event)) {
165 super.processEnterMessage(event);
166 }
167 }
168
204 " consumed=" + event.isConsumed());
205 }
206 /* If the event is not consumed, pass it to the
207 XEmbedCanvasPeer for processing. */
208 if (!event.isConsumed()) {
209 // NOTE: ctxt can be zero at this point.
210 if (xEmbedCanvasPeer.processXEmbedDnDEvent(ctxt,
211 event.getID())) {
212 event.consume();
213 return true;
214 }
215 }
216 }
217 }
218
219 return false;
220 }
221
222 public void forwardEventToEmbedded(long embedded, long ctxt,
223 int eventID) {
224 Iterator<XDropTargetProtocol> dropTargetProtocols =
225 XDragAndDropProtocols.getDropTargetProtocols();
226
227 while (dropTargetProtocols.hasNext()) {
228 XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
229 if (dropTargetProtocol.forwardEventToEmbedded(embedded, ctxt,
230 eventID)) {
231 break;
232 }
233 }
234 }
235
236 static final class XDropTargetProtocolListenerImpl
237 implements XDropTargetProtocolListener {
238
239 private final static XDropTargetProtocolListener theInstance =
240 new XDropTargetProtocolListenerImpl();
241
242 private XDropTargetProtocolListenerImpl() {}
243
244 static XDropTargetProtocolListener getInstance() {
245 return theInstance;
246 }
247
248 public void handleDropTargetNotification(XWindow xwindow, int x, int y,
|