comparison src/frame-x.c @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c42ec1d1cded
children 57709be46d1b
comparison
equal deleted inserted replaced
283:fa3d41851a08 284:558f606b08ae
1091 static void 1091 static void
1092 x_cde_transfer_callback (Widget widget, XtPointer clientData, 1092 x_cde_transfer_callback (Widget widget, XtPointer clientData,
1093 XtPointer callData) 1093 XtPointer callData)
1094 { 1094 {
1095 char *filePath, *hurl; 1095 char *filePath, *hurl;
1096 int ii; 1096 int ii, enqueue=1;
1097 Lisp_Object frame = Qnil; 1097 Lisp_Object frame = Qnil;
1098 Lisp_Object l_type = Qnil; 1098 Lisp_Object l_type = Qnil;
1099 Lisp_Object l_data = Qnil; 1099 Lisp_Object l_data = Qnil;
1100 DtDndTransferCallbackStruct *transferInfo = NULL;
1100 struct gcpro gcpro1, gcpro2, gcpro3; 1101 struct gcpro gcpro1, gcpro2, gcpro3;
1101 1102
1102 /* 1103 /*
1103 this needs to be changed to the new protocol: 1104 this needs to be changed to the new protocol:
1104 - we need the button, modifier and pointer states to create a 1105 - we need the button, modifier and pointer states to create a
1105 correct misc_user_event 1106 correct misc_user_event
1106 - the data must be converted to the new format (URL/MIME) 1107 - the data must be converted to the new format (URL/MIME)
1107 */ 1108 */
1108 return; 1109 /* return; */
1109 1110
1110 DtDndTransferCallbackStruct *transferInfo = 1111 transferInfo = (DtDndTransferCallbackStruct *) callData;
1111 (DtDndTransferCallbackStruct *) callData;
1112
1113 if (transferInfo == NULL) 1112 if (transferInfo == NULL)
1114 return; 1113 return;
1115 1114
1116 GCPRO3 (frame, l_type, l_data); 1115 GCPRO3 (frame, l_type, l_data);
1117 1116
1118 frame = make_frame ((struct frame *) clientData); 1117 frame = make_frame ((struct frame *) clientData);
1118
1119 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER) 1119 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER)
1120 { 1120 {
1121 l_type = Qdragdrop_URL; 1121 l_type = Qdragdrop_URL;
1122 1122
1123 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) 1123 for (ii = 0; ii < transferInfo->dropData->numItems; ii++)
1124 { 1124 {
1125 filePath = transferInfo->dropData->data.files[ii]; 1125 filePath = transferInfo->dropData->data.files[ii];
1126 hurl = dnd_url_hexify_string ((char *)filePath, "file:"); 1126 hurl = dnd_url_hexify_string ((char *)filePath, "file:");
1127 /* ### Mule-izing required */ 1127 /* ### Mule-izing required */
1128 l_data = Fcons ( make_string (hurl, strlen (hurl)), l_data ); 1128 l_data = Fcons (make_string ((Bufbyte* )hurl,
1129 strlen (hurl)),
1130 l_data);
1129 xfree (hurl); 1131 xfree (hurl);
1130 } 1132 }
1131 } 1133 }
1132 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER) 1134 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER)
1133 { 1135 {
1134 int speccount = specpdl_depth(); 1136 int speccount = specpdl_depth();
1135 1137
1138 /* Problem: all buffers a treated as text/plain!!!
1139 Solution: Also support DtDND_TEXT_TRANSFER
1140 perhaps implementation of the Motif protocol
1141 (which is the base of CDE) will clear this */
1136 l_type = Qdragdrop_MIME; 1142 l_type = Qdragdrop_MIME;
1137 /* the meaning of this is not clear to me... */
1138 record_unwind_protect(abort_current_drag, Qnil); 1143 record_unwind_protect(abort_current_drag, Qnil);
1139 drag_not_done = 1; 1144 drag_not_done = 1;
1140 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) 1145 for (ii = 0; ii < transferInfo->dropData->numItems; ii++)
1141 { 1146 {
1142 /* let us forget this name thing for now... */ 1147 /* let us forget this name thing for now... */
1143 /* filePath = transferInfo->dropData->data.buffers[ii].name; 1148 /* filePath = transferInfo->dropData->data.buffers[ii].name;
1144 path = (filePath == NULL) ? Qnil 1149 path = (filePath == NULL) ? Qnil
1145 : make_string ((Bufbyte *)filePath, strlen (filePath)); */ 1150 : make_string ((Bufbyte *)filePath, strlen (filePath)); */
1146 /* what, if the data is no text, and how can I tell it? */ 1151 /* what, if the data is no text, and how can I tell it? */
1147 l_data = Fcons ( list3 ( make_string ("text/plain", 10), 1152 l_data = Fcons ( list3 ( list1 ( make_string ((Bufbyte *)"text/plain", 10) ),
1148 make_string ("8bit", 4), 1153 make_string ((Bufbyte *)"8bit", 4),
1149 make_ext_string (transferInfo->dropData->data.buffers[ii].bp, 1154 make_string ((Bufbyte *)transferInfo->dropData->data.buffers[ii].bp,
1150 transferInfo->dropData->data.buffers[ii].size, 1155 transferInfo->dropData->data.buffers[ii].size) ),
1151 FORMAT_CTEXT) ),
1152 l_data ); 1156 l_data );
1153 } 1157 }
1154 drag_not_done = 0; 1158 drag_not_done = 0;
1155 /* and what is this */
1156 unbind_to(speccount, Qnil); 1159 unbind_to(speccount, Qnil);
1157 } 1160 }
1158 1161 else /* the other cases: NOOP_TRANSFER */
1159 /* where are button, mod and pos? -- query the pointer... */ 1162 enqueue=0;
1160 enqueue_misc_user_event ( frame, Qdragdrop_drop_dispatch, 1163
1161 Fcons (l_type, l_data) ); 1164 /* The Problem: no button and mods from CDE... */
1165 if (enqueue)
1166 enqueue_misc_user_event_pos ( frame, Qdragdrop_drop_dispatch,
1167 Fcons (l_type, l_data),
1168 0 /* this is the button */,
1169 0 /* these are the mods */,
1170 transferInfo->x,
1171 transferInfo->y);
1162 1172
1163 UNGCPRO; 1173 UNGCPRO;
1164 return; 1174 return;
1165 } 1175 }
1166 #endif /* HAVE_CDE */ 1176 #endif /* HAVE_CDE */
1962 1972
1963 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f), 1973 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f),
1964 DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER, 1974 DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER,
1965 XmDROP_COPY, dnd_transfer_cb_rec, 1975 XmDROP_COPY, dnd_transfer_cb_rec,
1966 DtNtextIsBuffer, True, 1976 DtNtextIsBuffer, True,
1977 DtNregisterChildren, True,
1967 DtNpreserveRegistration, False, 1978 DtNpreserveRegistration, False,
1968 NULL); 1979 NULL);
1969 } 1980 }
1970 #endif /* HAVE_CDE */ 1981 #endif /* HAVE_CDE */
1971 1982