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
266 }
267 }
268
269 return new TargetWindowInfo(proxy, protocolVersion);
270 }
271 } else {
272 wpg1.dispose();
273 }
274
275 return null;
276 }
277
278 public void sendEnterMessage(long[] formats,
279 int sourceAction, int sourceActions, long time) {
280 assert XToolkit.isAWTLockHeldByCurrentThread();
281 assert getTargetWindow() != 0;
282 assert formats != null;
283
284 XClientMessageEvent msg = new XClientMessageEvent();
285 try {
286 msg.set_type((int)XConstants.ClientMessage);
287 msg.set_window(getTargetWindow());
288 msg.set_format(32);
289 msg.set_message_type(XDnDConstants.XA_XdndEnter.getAtom());
290 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
291 long data1 =
292 getTargetProtocolVersion() << XDnDConstants.XDND_PROTOCOL_SHIFT;
293 data1 |= formats.length > 3 ? XDnDConstants.XDND_DATA_TYPES_BIT : 0;
294 msg.set_data(1, data1);
295 msg.set_data(2, formats.length > 0 ? formats[0] : 0);
296 msg.set_data(3, formats.length > 1 ? formats[1] : 0);
297 msg.set_data(4, formats.length > 2 ? formats[2] : 0);
298 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
299 getTargetProxyWindow(),
300 false, XConstants.NoEventMask,
301 msg.pData);
302 } finally {
303 msg.dispose();
304 }
305 }
306
307 public void sendMoveMessage(int xRoot, int yRoot,
308 int sourceAction, int sourceActions, long time) {
309 assert XToolkit.isAWTLockHeldByCurrentThread();
310 assert getTargetWindow() != 0;
311
312 XClientMessageEvent msg = new XClientMessageEvent();
313 try {
314 msg.set_type((int)XConstants.ClientMessage);
315 msg.set_window(getTargetWindow());
316 msg.set_format(32);
317 msg.set_message_type(XDnDConstants.XA_XdndPosition.getAtom());
318 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
319 msg.set_data(1, 0); /* flags */
320 msg.set_data(2, xRoot << 16 | yRoot);
321 msg.set_data(3, time);
322 msg.set_data(4, XDnDConstants.getXDnDActionForJavaAction(sourceAction));
323 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
324 getTargetProxyWindow(),
325 false, XConstants.NoEventMask,
326 msg.pData);
327 } finally {
328 msg.dispose();
329 }
330 }
331
332 public void sendLeaveMessage(long time) {
333 assert XToolkit.isAWTLockHeldByCurrentThread();
334 assert getTargetWindow() != 0;
335
336 XClientMessageEvent msg = new XClientMessageEvent();
337 try {
338 msg.set_type((int)XConstants.ClientMessage);
339 msg.set_window(getTargetWindow());
340 msg.set_format(32);
341 msg.set_message_type(XDnDConstants.XA_XdndLeave.getAtom());
342 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
343 msg.set_data(1, 0);
344 msg.set_data(2, 0);
345 msg.set_data(3, 0);
346 msg.set_data(4, 0);
347 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
348 getTargetProxyWindow(),
349 false, XConstants.NoEventMask,
350 msg.pData);
351 } finally {
352 msg.dispose();
353 }
354 }
355
356 public void sendDropMessage(int xRoot, int yRoot,
357 int sourceAction, int sourceActions,
358 long time) {
359 assert XToolkit.isAWTLockHeldByCurrentThread();
360 assert getTargetWindow() != 0;
361
362 XClientMessageEvent msg = new XClientMessageEvent();
363 try {
364 msg.set_type((int)XConstants.ClientMessage);
365 msg.set_window(getTargetWindow());
366 msg.set_format(32);
367 msg.set_message_type(XDnDConstants.XA_XdndDrop.getAtom());
368 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
369 msg.set_data(1, 0); /* flags */
370 msg.set_data(2, time);
371 msg.set_data(3, 0);
372 msg.set_data(4, 0);
373 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
374 getTargetProxyWindow(),
375 false, XConstants.NoEventMask,
376 msg.pData);
377 } finally {
378 msg.dispose();
379 }
380 }
381
382 public boolean processProxyModeEvent(XClientMessageEvent xclient,
383 long sourceWindow) {
384 if (xclient.get_message_type() == XDnDConstants.XA_XdndStatus.getAtom() ||
|
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
266 }
267 }
268
269 return new TargetWindowInfo(proxy, protocolVersion);
270 }
271 } else {
272 wpg1.dispose();
273 }
274
275 return null;
276 }
277
278 public void sendEnterMessage(long[] formats,
279 int sourceAction, int sourceActions, long time) {
280 assert XToolkit.isAWTLockHeldByCurrentThread();
281 assert getTargetWindow() != 0;
282 assert formats != null;
283
284 XClientMessageEvent msg = new XClientMessageEvent();
285 try {
286 msg.set_type(XConstants.ClientMessage);
287 msg.set_window(getTargetWindow());
288 msg.set_format(32);
289 msg.set_message_type(XDnDConstants.XA_XdndEnter.getAtom());
290 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
291 long data1 =
292 getTargetProtocolVersion() << XDnDConstants.XDND_PROTOCOL_SHIFT;
293 data1 |= formats.length > 3 ? XDnDConstants.XDND_DATA_TYPES_BIT : 0;
294 msg.set_data(1, data1);
295 msg.set_data(2, formats.length > 0 ? formats[0] : 0);
296 msg.set_data(3, formats.length > 1 ? formats[1] : 0);
297 msg.set_data(4, formats.length > 2 ? formats[2] : 0);
298 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
299 getTargetProxyWindow(),
300 false, XConstants.NoEventMask,
301 msg.pData);
302 } finally {
303 msg.dispose();
304 }
305 }
306
307 public void sendMoveMessage(int xRoot, int yRoot,
308 int sourceAction, int sourceActions, long time) {
309 assert XToolkit.isAWTLockHeldByCurrentThread();
310 assert getTargetWindow() != 0;
311
312 XClientMessageEvent msg = new XClientMessageEvent();
313 try {
314 msg.set_type(XConstants.ClientMessage);
315 msg.set_window(getTargetWindow());
316 msg.set_format(32);
317 msg.set_message_type(XDnDConstants.XA_XdndPosition.getAtom());
318 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
319 msg.set_data(1, 0); /* flags */
320 msg.set_data(2, xRoot << 16 | yRoot);
321 msg.set_data(3, time);
322 msg.set_data(4, XDnDConstants.getXDnDActionForJavaAction(sourceAction));
323 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
324 getTargetProxyWindow(),
325 false, XConstants.NoEventMask,
326 msg.pData);
327 } finally {
328 msg.dispose();
329 }
330 }
331
332 public void sendLeaveMessage(long time) {
333 assert XToolkit.isAWTLockHeldByCurrentThread();
334 assert getTargetWindow() != 0;
335
336 XClientMessageEvent msg = new XClientMessageEvent();
337 try {
338 msg.set_type(XConstants.ClientMessage);
339 msg.set_window(getTargetWindow());
340 msg.set_format(32);
341 msg.set_message_type(XDnDConstants.XA_XdndLeave.getAtom());
342 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
343 msg.set_data(1, 0);
344 msg.set_data(2, 0);
345 msg.set_data(3, 0);
346 msg.set_data(4, 0);
347 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
348 getTargetProxyWindow(),
349 false, XConstants.NoEventMask,
350 msg.pData);
351 } finally {
352 msg.dispose();
353 }
354 }
355
356 public void sendDropMessage(int xRoot, int yRoot,
357 int sourceAction, int sourceActions,
358 long time) {
359 assert XToolkit.isAWTLockHeldByCurrentThread();
360 assert getTargetWindow() != 0;
361
362 XClientMessageEvent msg = new XClientMessageEvent();
363 try {
364 msg.set_type(XConstants.ClientMessage);
365 msg.set_window(getTargetWindow());
366 msg.set_format(32);
367 msg.set_message_type(XDnDConstants.XA_XdndDrop.getAtom());
368 msg.set_data(0, XDragSourceProtocol.getDragSourceWindow());
369 msg.set_data(1, 0); /* flags */
370 msg.set_data(2, time);
371 msg.set_data(3, 0);
372 msg.set_data(4, 0);
373 XlibWrapper.XSendEvent(XToolkit.getDisplay(),
374 getTargetProxyWindow(),
375 false, XConstants.NoEventMask,
376 msg.pData);
377 } finally {
378 msg.dispose();
379 }
380 }
381
382 public boolean processProxyModeEvent(XClientMessageEvent xclient,
383 long sourceWindow) {
384 if (xclient.get_message_type() == XDnDConstants.XA_XdndStatus.getAtom() ||
|