1 /*
2 * Copyright (c) 2003, 2008, 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
521 xmotion.get_time());
522 }
523 }
524
525 private void processDrop(XButtonEvent xbutton) {
526 try {
527 dragProtocol.initiateDrop(xbutton.get_x_root(),
528 xbutton.get_y_root(),
529 sourceAction, sourceActions,
530 xbutton.get_time());
531 } catch (XException e) {
532 cleanup(xbutton.get_time());
533 }
534 }
535
536 private boolean processProxyModeEvent(XEvent ev) {
537 if (getProxyModeSourceWindow() == 0) {
538 return false;
539 }
540
541 if (ev.get_type() != (int)XConstants.ClientMessage) {
542 return false;
543 }
544
545 if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
546 logger.finest(" proxyModeSourceWindow=" +
547 getProxyModeSourceWindow() +
548 " ev=" + ev);
549 }
550
551 XClientMessageEvent xclient = ev.get_xclient();
552
553 Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
554 while (dragProtocols.hasNext()) {
555 XDragSourceProtocol dragProtocol =
556 (XDragSourceProtocol)dragProtocols.next();
557 if (dragProtocol.processProxyModeEvent(xclient,
558 getProxyModeSourceWindow())) {
559 return true;
560 }
561 }
595 return true;
596 }
597 /* Pass along */
598 return false;
599 }
600 }
601
602 if (!dragInProgress) {
603 return false;
604 }
605
606 /* Process drag-only messages. */
607 switch (ev.get_type()) {
608 case XConstants.KeyRelease:
609 case XConstants.KeyPress: {
610 XKeyEvent xkey = ev.get_xkey();
611 long keysym = XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(),
612 xkey.get_keycode(), 0);
613 switch ((int)keysym) {
614 case (int)XKeySymConstants.XK_Escape: {
615 if (ev.get_type() == (int)XConstants.KeyRelease) {
616 cleanup(xkey.get_time());
617 }
618 break;
619 }
620 case (int)XKeySymConstants.XK_Control_R:
621 case (int)XKeySymConstants.XK_Control_L:
622 case (int)XKeySymConstants.XK_Shift_R:
623 case (int)XKeySymConstants.XK_Shift_L: {
624 XlibWrapper.XQueryPointer(XToolkit.getDisplay(),
625 xkey.get_root(),
626 XlibWrapper.larg1, // root
627 XlibWrapper.larg2, // subwindow
628 XlibWrapper.larg3, // x_root
629 XlibWrapper.larg4, // y_root
630 XlibWrapper.larg5, // x
631 XlibWrapper.larg6, // y
632 XlibWrapper.larg7); // modifiers
633 XMotionEvent xmotion = new XMotionEvent();
634 try {
635 xmotion.set_type(XConstants.MotionNotify);
|
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
521 xmotion.get_time());
522 }
523 }
524
525 private void processDrop(XButtonEvent xbutton) {
526 try {
527 dragProtocol.initiateDrop(xbutton.get_x_root(),
528 xbutton.get_y_root(),
529 sourceAction, sourceActions,
530 xbutton.get_time());
531 } catch (XException e) {
532 cleanup(xbutton.get_time());
533 }
534 }
535
536 private boolean processProxyModeEvent(XEvent ev) {
537 if (getProxyModeSourceWindow() == 0) {
538 return false;
539 }
540
541 if (ev.get_type() != XConstants.ClientMessage) {
542 return false;
543 }
544
545 if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
546 logger.finest(" proxyModeSourceWindow=" +
547 getProxyModeSourceWindow() +
548 " ev=" + ev);
549 }
550
551 XClientMessageEvent xclient = ev.get_xclient();
552
553 Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
554 while (dragProtocols.hasNext()) {
555 XDragSourceProtocol dragProtocol =
556 (XDragSourceProtocol)dragProtocols.next();
557 if (dragProtocol.processProxyModeEvent(xclient,
558 getProxyModeSourceWindow())) {
559 return true;
560 }
561 }
595 return true;
596 }
597 /* Pass along */
598 return false;
599 }
600 }
601
602 if (!dragInProgress) {
603 return false;
604 }
605
606 /* Process drag-only messages. */
607 switch (ev.get_type()) {
608 case XConstants.KeyRelease:
609 case XConstants.KeyPress: {
610 XKeyEvent xkey = ev.get_xkey();
611 long keysym = XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(),
612 xkey.get_keycode(), 0);
613 switch ((int)keysym) {
614 case (int)XKeySymConstants.XK_Escape: {
615 if (ev.get_type() == XConstants.KeyRelease) {
616 cleanup(xkey.get_time());
617 }
618 break;
619 }
620 case (int)XKeySymConstants.XK_Control_R:
621 case (int)XKeySymConstants.XK_Control_L:
622 case (int)XKeySymConstants.XK_Shift_R:
623 case (int)XKeySymConstants.XK_Shift_L: {
624 XlibWrapper.XQueryPointer(XToolkit.getDisplay(),
625 xkey.get_root(),
626 XlibWrapper.larg1, // root
627 XlibWrapper.larg2, // subwindow
628 XlibWrapper.larg3, // x_root
629 XlibWrapper.larg4, // y_root
630 XlibWrapper.larg5, // x
631 XlibWrapper.larg6, // y
632 XlibWrapper.larg7); // modifiers
633 XMotionEvent xmotion = new XMotionEvent();
634 try {
635 xmotion.set_type(XConstants.MotionNotify);
|