comparison src/frame-x.c @ 183:e121b013d1f0 r20-3b18

Import from CVS: tag r20-3b18
author cvs
date Mon, 13 Aug 2007 09:54:23 +0200
parents 9ad43877534d
children 3d6bfa290dbd
comparison
equal deleted inserted replaced
182:f07455f06202 183:e121b013d1f0
1181 Lisp_Object dnd_data = Qnil; 1181 Lisp_Object dnd_data = Qnil;
1182 Lisp_Object dnd_type = Qnil; 1182 Lisp_Object dnd_type = Qnil;
1183 1183
1184 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1184 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1185 1185
1186 if (!DndIsDropMessage(event)) /* the better way */
1187 {
1188 stderr_out("DndDropHandler: pseudo drop received (ignore me!)\n");
1189 return;
1190 }
1191
1186 Type = DndDataType (event); 1192 Type = DndDataType (event);
1187 if (Type < 0) /* pseudo event produces -1 as type */
1188 {
1189 stderr_out("DndDropHandler: pseudo drop received\n");
1190 return;
1191 }
1192
1193 DndGetData (&Data, &Size); 1193 DndGetData (&Data, &Size);
1194 1194
1195 GCPRO4 (path, frame, dnd_data, dnd_type); 1195 GCPRO4 (path, frame, dnd_data, dnd_type);
1196 1196
1197 frame = make_frame ((struct frame *) data); 1197 frame = make_frame ((struct frame *) data);
1198 1198
1199 stderr_out("DndDropHandler: real drop received (T%d Sl%d)\n",Type,Size); 1199 stderr_out("DndDropHandler: valid drop received (T%d S%u)\n",Type,Size);
1200 1200
1201 switch (Type) 1201 switch (Type)
1202 { 1202 {
1203 case DndFiles: 1203 case DndFiles:
1204 while (*Data) 1204 while (*Data)
1236 } 1236 }
1237 1237
1238 UNGCPRO; 1238 UNGCPRO;
1239 return; 1239 return;
1240 } 1240 }
1241
1242 DEFUN ("offix-start-drag-internal", Foffix_start_drag_internal, 2, 3, 0, /*
1243 First arg is the event that started the drag,
1244 second arg should be some string.
1245 Start a OffiX drag from a buffer.
1246 For now this will only drag as DndText.
1247 This fun is heavily stolen from the CDE Dnd stuff.
1248 */
1249 (event, data, dtyp))
1250 {
1251 if (EVENTP(event) && STRINGP (data))
1252 {
1253 struct frame *f = decode_x_frame (Fselected_frame (Qnil));
1254 XEvent x_event;
1255 Widget wid = FRAME_X_TEXT_WIDGET (f);
1256 Display *display = XtDisplayOfObject (wid);
1257 Window root_window, child_window;
1258 int root_x, root_y, win_x, win_y;
1259 unsigned int keys_and_buttons;
1260 char *dnd_data;
1261 unsigned long dnd_len;
1262 int dnd_typ;
1263 struct Lisp_Event *lisp_event = XEVENT(event);
1264
1265 /* only drag if this is really a press */
1266 if (EVENT_TYPE(lisp_event) != button_press_event)
1267 return Qnil;
1268
1269 /* and whats with MULE data ??? */
1270 dnd_data = XSTRING_DATA (data);
1271 dnd_len = XSTRING_LENGTH (data) + 1; /* the f*cking zero */
1272
1273 /* set the type */
1274 if (!NILP (dtyp) && INTP (dtyp))
1275 dnd_typ = XINT (dtyp);
1276 else
1277 dnd_typ = DndText; /* the default */
1278
1279 /*
1280 * Eek - XEmacs doesn't keep the old X event around so we have to
1281 * build a dummy event. This is a truly gross hack. (from CDE)
1282 *
1283 * Perhaps there is some way to hand back the lisp event object?
1284 * Best way: hand through x-event in all Lisp_Events
1285 */
1286
1287 x_event.xbutton.type = ButtonPress;
1288 x_event.xbutton.send_event = False;
1289 x_event.xbutton.display = XtDisplayOfObject(wid);
1290 x_event.xbutton.window = XtWindowOfObject(wid);
1291 x_event.xbutton.root = XRootWindow(x_event.xkey.display, 0);
1292 x_event.xbutton.subwindow = 0;
1293 x_event.xbutton.time = lisp_event->timestamp;
1294 x_event.xbutton.x = lisp_event->event.button.x;
1295 x_event.xbutton.y = lisp_event->event.button.y;
1296 x_event.xbutton.x_root = lisp_event->event.button.x; /* this is wrong */
1297 x_event.xbutton.y_root = lisp_event->event.button.y;
1298 x_event.xbutton.state = 0; /* calc state from modifier */
1299 x_event.xbutton.button = lisp_event->event.button.button;
1300 x_event.xkey.same_screen = True;
1301
1302 DndSetData(dnd_typ, dnd_data, dnd_len);
1303
1304 if (DndHandleDragging(wid, &x_event))
1305 return Qt;
1306 }
1307 return Qnil;
1308 }
1309
1241 #endif /* HAVE_OFFIX_DND */ 1310 #endif /* HAVE_OFFIX_DND */
1242 1311
1243 1312
1244 /************************************************************************/ 1313 /************************************************************************/
1245 /* widget creation */ 1314 /* widget creation */
2534 defsymbol (&Qx_resource_name, "x-resource-name"); 2603 defsymbol (&Qx_resource_name, "x-resource-name");
2535 2604
2536 DEFSUBR (Fx_window_id); 2605 DEFSUBR (Fx_window_id);
2537 #ifdef HAVE_CDE 2606 #ifdef HAVE_CDE
2538 DEFSUBR (Fcde_start_drag_internal); 2607 DEFSUBR (Fcde_start_drag_internal);
2608 #endif
2609 #ifdef HAVE_OFFIX_DND
2610 DEFSUBR (Foffix_start_drag_internal);
2539 #endif 2611 #endif
2540 } 2612 }
2541 2613
2542 void 2614 void
2543 console_type_create_frame_x (void) 2615 console_type_create_frame_x (void)