src/solaris/classes/sun/awt/X11/XDnDDropTargetProtocol.java

Print this page




 976         sourceX = 0;
 977         sourceY = 0;
 978         targetXWindow = null;
 979     }
 980 
 981     public boolean isDragOverComponent() {
 982         return targetXWindow != null;
 983     }
 984 
 985     public void adjustEventForForwarding(XClientMessageEvent xclient,
 986                                          EmbedderRegistryEntry entry) {
 987         /* Adjust the event to match the XDnD protocol version. */
 988         int version = entry.getVersion();
 989         if (xclient.get_message_type() == XDnDConstants.XA_XdndEnter.getAtom()) {
 990             int min_version = sourceProtocolVersion < version ?
 991                 sourceProtocolVersion : version;
 992             long data1 = min_version << XDnDConstants.XDND_PROTOCOL_SHIFT;
 993             if (sourceFormats != null && sourceFormats.length > 3) {
 994                 data1 |= XDnDConstants.XDND_DATA_TYPES_BIT;
 995             }
 996             if (logger.isLoggable(PlatformLogger.FINEST)) {
 997                 logger.finest("         "
 998                               + " entryVersion=" + version
 999                               + " sourceProtocolVersion=" +
1000                               sourceProtocolVersion
1001                               + " sourceFormats.length=" +
1002                               (sourceFormats != null ? sourceFormats.length : 0));
1003             }
1004             xclient.set_data(1, data1);
1005         }
1006     }
1007 
1008     private void notifyProtocolListener(XWindow xwindow, int x, int y,
1009                                         int dropAction,
1010                                         XClientMessageEvent xclient,
1011                                         int eventID) {
1012         long nativeCtxt = 0;
1013 
1014         // Make a copy of the passed XClientMessageEvent structure, since
1015         // the original structure can be freed before this
1016         // SunDropTargetEvent is dispatched.


1035                            sourceFormats.length > 2 ? sourceFormats[2] : 0);
1036         }
1037 
1038         getProtocolListener().handleDropTargetNotification(xwindow, x, y,
1039                                                            dropAction,
1040                                                            sourceActions,
1041                                                            sourceFormats,
1042                                                            nativeCtxt,
1043                                                            eventID);
1044     }
1045 
1046     /*
1047      * The methods/fields defined below are executed/accessed only on
1048      * the toolkit thread.
1049      * The methods/fields defined below are executed/accessed only on the event
1050      * dispatch thread.
1051      */
1052 
1053     public boolean forwardEventToEmbedded(long embedded, long ctxt,
1054                                           int eventID) {
1055         if (logger.isLoggable(PlatformLogger.FINEST)) {
1056             logger.finest("        ctxt=" + ctxt +
1057                           " type=" + (ctxt != 0 ?
1058                                       getMessageType(new
1059                                           XClientMessageEvent(ctxt)) : 0) +
1060                           " prevCtxt=" + prevCtxt +
1061                           " prevType=" + (prevCtxt != 0 ?
1062                                       getMessageType(new
1063                                           XClientMessageEvent(prevCtxt)) : 0));
1064         }
1065         if ((ctxt == 0 ||
1066              getMessageType(new XClientMessageEvent(ctxt)) == UNKNOWN_MESSAGE) &&
1067             (prevCtxt == 0 ||
1068              getMessageType(new XClientMessageEvent(prevCtxt)) == UNKNOWN_MESSAGE)) {
1069             return false;
1070         }
1071 
1072         // The size of XClientMessageEvent structure.
1073         int size = XClientMessageEvent.getSize();
1074 
1075         if (ctxt != 0) {
1076             XClientMessageEvent xclient = new XClientMessageEvent(ctxt);
1077             if (!overXEmbedClient) {
1078                 long data1 = Native.getLong(ctxt + size);
1079                 long data2 = Native.getLong(ctxt + size + Native.getLongSize());
1080                 long data3 = Native.getLong(ctxt + size + 2 * Native.getLongSize());
1081                 long data4 = Native.getLong(ctxt + size + 3 * Native.getLongSize());
1082 
1083                 if (logger.isLoggable(PlatformLogger.FINEST)) {
1084                     logger.finest("         1 "
1085                                   + " embedded=" + embedded
1086                                   + " source=" + xclient.get_data(0)
1087                                   + " data1=" + data1
1088                                   + " data2=" + data2
1089                                   + " data3=" + data3
1090                                   + " data4=" + data4);
1091                 }
1092 
1093                 // Copy XdndTypeList from source to proxy.
1094                 if ((data1 & XDnDConstants.XDND_DATA_TYPES_BIT) != 0) {
1095                     WindowPropertyGetter wpg =
1096                         new WindowPropertyGetter(xclient.get_data(0),
1097                                                  XDnDConstants.XA_XdndTypeList,
1098                                                  0, 0xFFFF, false,
1099                                                  XAtom.XA_ATOM);
1100                     try {
1101                         wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
1102 
1103                         if (wpg.getActualType() == XAtom.XA_ATOM &&
1104                             wpg.getActualFormat() == 32) {
1105 
1106                             XToolkit.awtLock();
1107                             try {
1108                                 XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
1109                                 XDnDConstants.XA_XdndTypeList.setAtomData(xclient.get_window(),
1110                                                                           XAtom.XA_ATOM,
1111                                                                           wpg.getData(),
1112                                                                           wpg.getNumberOfItems());
1113                                 XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
1114 
1115                                 if ((XErrorHandlerUtil.saved_error != null) &&
1116                                     (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success)) {
1117                                     if (logger.isLoggable(PlatformLogger.WARNING)) {
1118                                         logger.warning("Cannot set XdndTypeList on the proxy window");
1119                                     }
1120                                 }
1121                             } finally {
1122                                 XToolkit.awtUnlock();
1123                             }
1124                         } else {
1125                             if (logger.isLoggable(PlatformLogger.WARNING)) {
1126                                 logger.warning("Cannot read XdndTypeList from the source window");
1127                             }
1128                         }
1129                     } finally {
1130                         wpg.dispose();
1131                     }
1132                 }
1133                 XDragSourceContextPeer.setProxyModeSourceWindow(xclient.get_data(0));
1134 
1135                 sendEnterMessageToToplevelImpl(embedded, xclient.get_window(),
1136                                                data1, data2, data3, data4);
1137                 overXEmbedClient = true;
1138             }
1139 
1140             if (logger.isLoggable(PlatformLogger.FINEST)) {
1141                 logger.finest("         2 "
1142                               + " embedded=" + embedded
1143                               + " xclient=" + xclient);
1144             }
1145 
1146             /* Make a copy of the original event, since we are going to modify the
1147                event while it still can be referenced from other Java events. */
1148             {
1149                 XClientMessageEvent copy = new XClientMessageEvent();
1150                 unsafe.copyMemory(xclient.pData, copy.pData, copy.getSize());
1151 
1152                 copy.set_data(0, xclient.get_window());
1153 
1154                 forwardClientMessageToToplevel(embedded, copy);
1155             }
1156         }
1157 
1158         if (eventID == MouseEvent.MOUSE_EXITED) {
1159             if (overXEmbedClient) {
1160                 if (ctxt != 0 || prevCtxt != 0) {




 976         sourceX = 0;
 977         sourceY = 0;
 978         targetXWindow = null;
 979     }
 980 
 981     public boolean isDragOverComponent() {
 982         return targetXWindow != null;
 983     }
 984 
 985     public void adjustEventForForwarding(XClientMessageEvent xclient,
 986                                          EmbedderRegistryEntry entry) {
 987         /* Adjust the event to match the XDnD protocol version. */
 988         int version = entry.getVersion();
 989         if (xclient.get_message_type() == XDnDConstants.XA_XdndEnter.getAtom()) {
 990             int min_version = sourceProtocolVersion < version ?
 991                 sourceProtocolVersion : version;
 992             long data1 = min_version << XDnDConstants.XDND_PROTOCOL_SHIFT;
 993             if (sourceFormats != null && sourceFormats.length > 3) {
 994                 data1 |= XDnDConstants.XDND_DATA_TYPES_BIT;
 995             }
 996             if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
 997                 logger.finest("         "
 998                               + " entryVersion=" + version
 999                               + " sourceProtocolVersion=" +
1000                               sourceProtocolVersion
1001                               + " sourceFormats.length=" +
1002                               (sourceFormats != null ? sourceFormats.length : 0));
1003             }
1004             xclient.set_data(1, data1);
1005         }
1006     }
1007 
1008     private void notifyProtocolListener(XWindow xwindow, int x, int y,
1009                                         int dropAction,
1010                                         XClientMessageEvent xclient,
1011                                         int eventID) {
1012         long nativeCtxt = 0;
1013 
1014         // Make a copy of the passed XClientMessageEvent structure, since
1015         // the original structure can be freed before this
1016         // SunDropTargetEvent is dispatched.


1035                            sourceFormats.length > 2 ? sourceFormats[2] : 0);
1036         }
1037 
1038         getProtocolListener().handleDropTargetNotification(xwindow, x, y,
1039                                                            dropAction,
1040                                                            sourceActions,
1041                                                            sourceFormats,
1042                                                            nativeCtxt,
1043                                                            eventID);
1044     }
1045 
1046     /*
1047      * The methods/fields defined below are executed/accessed only on
1048      * the toolkit thread.
1049      * The methods/fields defined below are executed/accessed only on the event
1050      * dispatch thread.
1051      */
1052 
1053     public boolean forwardEventToEmbedded(long embedded, long ctxt,
1054                                           int eventID) {
1055         if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
1056             logger.finest("        ctxt=" + ctxt +
1057                           " type=" + (ctxt != 0 ?
1058                                       getMessageType(new
1059                                           XClientMessageEvent(ctxt)) : 0) +
1060                           " prevCtxt=" + prevCtxt +
1061                           " prevType=" + (prevCtxt != 0 ?
1062                                       getMessageType(new
1063                                           XClientMessageEvent(prevCtxt)) : 0));
1064         }
1065         if ((ctxt == 0 ||
1066              getMessageType(new XClientMessageEvent(ctxt)) == UNKNOWN_MESSAGE) &&
1067             (prevCtxt == 0 ||
1068              getMessageType(new XClientMessageEvent(prevCtxt)) == UNKNOWN_MESSAGE)) {
1069             return false;
1070         }
1071 
1072         // The size of XClientMessageEvent structure.
1073         int size = XClientMessageEvent.getSize();
1074 
1075         if (ctxt != 0) {
1076             XClientMessageEvent xclient = new XClientMessageEvent(ctxt);
1077             if (!overXEmbedClient) {
1078                 long data1 = Native.getLong(ctxt + size);
1079                 long data2 = Native.getLong(ctxt + size + Native.getLongSize());
1080                 long data3 = Native.getLong(ctxt + size + 2 * Native.getLongSize());
1081                 long data4 = Native.getLong(ctxt + size + 3 * Native.getLongSize());
1082 
1083                 if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
1084                     logger.finest("         1 "
1085                                   + " embedded=" + embedded
1086                                   + " source=" + xclient.get_data(0)
1087                                   + " data1=" + data1
1088                                   + " data2=" + data2
1089                                   + " data3=" + data3
1090                                   + " data4=" + data4);
1091                 }
1092 
1093                 // Copy XdndTypeList from source to proxy.
1094                 if ((data1 & XDnDConstants.XDND_DATA_TYPES_BIT) != 0) {
1095                     WindowPropertyGetter wpg =
1096                         new WindowPropertyGetter(xclient.get_data(0),
1097                                                  XDnDConstants.XA_XdndTypeList,
1098                                                  0, 0xFFFF, false,
1099                                                  XAtom.XA_ATOM);
1100                     try {
1101                         wpg.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
1102 
1103                         if (wpg.getActualType() == XAtom.XA_ATOM &&
1104                             wpg.getActualFormat() == 32) {
1105 
1106                             XToolkit.awtLock();
1107                             try {
1108                                 XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
1109                                 XDnDConstants.XA_XdndTypeList.setAtomData(xclient.get_window(),
1110                                                                           XAtom.XA_ATOM,
1111                                                                           wpg.getData(),
1112                                                                           wpg.getNumberOfItems());
1113                                 XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
1114 
1115                                 if ((XErrorHandlerUtil.saved_error != null) &&
1116                                     (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success)) {
1117                                     if (logger.isLoggable(PlatformLogger.Level.WARNING)) {
1118                                         logger.warning("Cannot set XdndTypeList on the proxy window");
1119                                     }
1120                                 }
1121                             } finally {
1122                                 XToolkit.awtUnlock();
1123                             }
1124                         } else {
1125                             if (logger.isLoggable(PlatformLogger.Level.WARNING)) {
1126                                 logger.warning("Cannot read XdndTypeList from the source window");
1127                             }
1128                         }
1129                     } finally {
1130                         wpg.dispose();
1131                     }
1132                 }
1133                 XDragSourceContextPeer.setProxyModeSourceWindow(xclient.get_data(0));
1134 
1135                 sendEnterMessageToToplevelImpl(embedded, xclient.get_window(),
1136                                                data1, data2, data3, data4);
1137                 overXEmbedClient = true;
1138             }
1139 
1140             if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
1141                 logger.finest("         2 "
1142                               + " embedded=" + embedded
1143                               + " xclient=" + xclient);
1144             }
1145 
1146             /* Make a copy of the original event, since we are going to modify the
1147                event while it still can be referenced from other Java events. */
1148             {
1149                 XClientMessageEvent copy = new XClientMessageEvent();
1150                 unsafe.copyMemory(xclient.pData, copy.pData, copy.getSize());
1151 
1152                 copy.set_data(0, xclient.get_window());
1153 
1154                 forwardClientMessageToToplevel(embedded, copy);
1155             }
1156         }
1157 
1158         if (eventID == MouseEvent.MOUSE_EXITED) {
1159             if (overXEmbedClient) {
1160                 if (ctxt != 0 || prevCtxt != 0) {