Mercurial > hg > xemacs-beta
comparison src/event-Xt.c @ 282:c42ec1d1cded r21-0b39
Import from CVS: tag r21-0b39
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:33:18 +0200 |
parents | c5d627a313b1 |
children | 558f606b08ae |
comparison
equal
deleted
inserted
replaced
281:090b52736db2 | 282:c42ec1d1cded |
---|---|
56 #endif | 56 #endif |
57 #include "lstream.h" | 57 #include "lstream.h" |
58 #include "file-coding.h" | 58 #include "file-coding.h" |
59 #endif | 59 #endif |
60 | 60 |
61 #ifdef HAVE_OFFIX_DND | 61 #ifdef HAVE_DRAGNDROP |
62 #include "dragdrop.h" | |
63 #endif | |
64 | |
65 #if defined (HAVE_OFFIX_DND) | |
62 #include "offix.h" | 66 #include "offix.h" |
63 #endif | 67 #endif |
64 | 68 |
65 #ifdef WINDOWSNT | 69 #ifdef WINDOWSNT |
66 /* Hmm, under unix we want X modifiers, under NT we want X modifiers if | 70 /* Hmm, under unix we want X modifiers, under NT we want X modifiers if |
1121 | 1125 |
1122 if (! frame) | 1126 if (! frame) |
1123 return 0; /* not for us */ | 1127 return 0; /* not for us */ |
1124 XSETFRAME (emacs_event->channel, frame); | 1128 XSETFRAME (emacs_event->channel, frame); |
1125 | 1129 |
1126 emacs_event->event_type = dnd_drop_event; | 1130 emacs_event->event_type = misc_user_event; |
1127 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d); | 1131 emacs_event->timestamp = DEVICE_X_LAST_SERVER_TIMESTAMP (d); |
1128 | 1132 |
1129 state=DndDragButtons(x_event); | 1133 state=DndDragButtons(x_event); |
1130 | 1134 |
1131 if (state & ShiftMask) modifiers |= MOD_SHIFT; | 1135 if (state & ShiftMask) modifiers |= MOD_SHIFT; |
1132 if (state & ControlMask) modifiers |= MOD_CONTROL; | 1136 if (state & ControlMask) modifiers |= MOD_CONTROL; |
1133 if (state & xd->MetaMask) modifiers |= MOD_META; | 1137 if (state & xd->MetaMask) modifiers |= MOD_META; |
1134 if (state & xd->SuperMask) modifiers |= MOD_SUPER; | 1138 if (state & xd->SuperMask) modifiers |= MOD_SUPER; |
1135 if (state & xd->HyperMask) modifiers |= MOD_HYPER; | 1139 if (state & xd->HyperMask) modifiers |= MOD_HYPER; |
1139 if (state & Button4Mask) button = Button4; | 1143 if (state & Button4Mask) button = Button4; |
1140 if (state & Button3Mask) button = Button3; | 1144 if (state & Button3Mask) button = Button3; |
1141 if (state & Button2Mask) button = Button2; | 1145 if (state & Button2Mask) button = Button2; |
1142 if (state & Button1Mask) button = Button1; | 1146 if (state & Button1Mask) button = Button1; |
1143 | 1147 |
1144 emacs_event->event.dnd_drop.modifiers = modifiers; | 1148 emacs_event->event.misc.modifiers = modifiers; |
1145 emacs_event->event.dnd_drop.button = button; | 1149 emacs_event->event.misc.button = button; |
1146 | 1150 |
1147 DndDropCoordinates(FRAME_X_TEXT_WIDGET(frame), x_event, | 1151 DndDropCoordinates(FRAME_X_TEXT_WIDGET(frame), x_event, |
1148 &(emacs_event->event.dnd_drop.x), | 1152 &(emacs_event->event.misc.x), |
1149 &(emacs_event->event.dnd_drop.y) ); | 1153 &(emacs_event->event.misc.y) ); |
1150 | 1154 |
1151 DndGetData(x_event,&data,&size); | 1155 DndGetData(x_event,&data,&size); |
1152 | 1156 |
1153 dtype=DndDataType(x_event); | 1157 dtype=DndDataType(x_event); |
1154 switch (dtype) | 1158 switch (dtype) |
1155 { | 1159 { |
1156 case DndFiles: /* null terminated strings, end null */ | 1160 case DndFiles: /* null terminated strings, end null */ |
1157 { | 1161 { |
1158 int len; | 1162 int len; |
1163 char *hurl = NULL; | |
1164 | |
1159 while (*data) | 1165 while (*data) |
1160 { | 1166 { |
1161 len = strlen ((char*) data); | 1167 len = strlen ((char*)data); |
1162 l_item = make_ext_string (data, len, | 1168 hurl = dnd_url_hexify_string ((char *)data, "file:"); |
1163 FORMAT_FILENAME); | 1169 l_item = make_string (hurl, strlen (hurl)); |
1164 /* order is irrelevant */ | |
1165 l_dndlist = Fcons (l_item, l_dndlist); | 1170 l_dndlist = Fcons (l_item, l_dndlist); |
1166 data += len+1; | 1171 data += len + 1; |
1172 xfree (hurl); | |
1167 } | 1173 } |
1174 l_type = Qdragdrop_URL; | |
1168 } | 1175 } |
1169 break; | 1176 break; |
1170 case DndText: | 1177 case DndText: |
1178 l_type = Qdragdrop_MIME; | |
1179 l_dndlist = list1 ( list3 ( make_string ("text/plain", 10), | |
1180 make_string ("8bit", 4), | |
1181 make_ext_string (data, | |
1182 strlen((char *)data), | |
1183 FORMAT_CTEXT) ) ); | |
1184 break; | |
1171 case DndMIME: | 1185 case DndMIME: |
1172 /* is there a better way to format this ? */ | 1186 /* we have to parse this in some way to extract |
1173 l_dndlist = make_ext_string (data, strlen((char *)data), | 1187 content-type and params (in the tm way) and |
1174 FORMAT_BINARY); | 1188 content encoding. |
1189 OR: if data is string, let tm do the job | |
1190 if data is list[2], give the first two | |
1191 to tm... | |
1192 */ | |
1193 l_type = Qdragdrop_MIME; | |
1194 l_dndlist = list1 ( make_ext_string (data, strlen((char *)data), | |
1195 FORMAT_BINARY) ); | |
1175 break; | 1196 break; |
1176 case DndFile: | 1197 case DndFile: |
1177 case DndDir: | 1198 case DndDir: |
1178 case DndLink: | 1199 case DndLink: |
1179 case DndExe: | 1200 case DndExe: |
1180 case DndURL: /* this could also break with FORMAT_FILENAME */ | 1201 { |
1181 l_dndlist = make_ext_string (data, strlen((char *)data), | 1202 char *hurl = dnd_url_hexify_string (data, "file:"); |
1182 FORMAT_FILENAME); | 1203 |
1204 l_dndlist = list1 ( make_string (hurl, strlen (hurl)) ); | |
1205 l_type = Qdragdrop_URL; | |
1206 | |
1207 xfree (hurl); | |
1208 } | |
1209 break; | |
1210 case DndURL: | |
1211 /* as it is a real URL it should already be escaped | |
1212 and escaping again will break them (cause % is unsave) */ | |
1213 l_dndlist = list1 ( make_ext_string ((char *)data, | |
1214 strlen ((char *)data), | |
1215 FORMAT_FILENAME) ); | |
1216 l_type = Qdragdrop_URL; | |
1183 break; | 1217 break; |
1184 default: /* Unknown, RawData and any other type */ | 1218 default: /* Unknown, RawData and any other type */ |
1185 l_dndlist = make_ext_string (data, size, | 1219 l_dndlist = list1 ( list3 ( make_string ("application/octet-stream", 24), |
1186 FORMAT_BINARY); | 1220 make_string ("8bit", 4), |
1221 make_ext_string ((char *)data, size, | |
1222 FORMAT_BINARY) ) ); | |
1223 l_type = Qdragdrop_MIME; | |
1187 break; | 1224 break; |
1188 } | 1225 } |
1189 | 1226 |
1190 l_type=make_int(dtype); | 1227 emacs_event->event.misc.function = Qdragdrop_drop_dispatch; |
1191 | 1228 emacs_event->event.misc.object = Fcons (l_type, l_dndlist); |
1192 emacs_event->event.dnd_drop.data = Fcons (l_type, Fcons (l_dndlist, Qnil)); | |
1193 | 1229 |
1194 UNGCPRO; | 1230 UNGCPRO; |
1195 | 1231 |
1196 break; | 1232 break; |
1197 } | 1233 } |