Mercurial > hg > xemacs-beta
comparison src/frame-x.c @ 290:c9fe270a4101 r21-0b43
Import from CVS: tag r21-0b43
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:36:47 +0200 |
parents | e11d67e05968 |
children | 341dac730539 |
comparison
equal
deleted
inserted
replaced
289:6e6992ccc4b6 | 290:c9fe270a4101 |
---|---|
974 #ifdef HAVE_CDE | 974 #ifdef HAVE_CDE |
975 #include <Dt/Dt.h> | 975 #include <Dt/Dt.h> |
976 #include <Dt/Dnd.h> | 976 #include <Dt/Dnd.h> |
977 | 977 |
978 static Widget CurrentDragWidget = NULL; | 978 static Widget CurrentDragWidget = NULL; |
979 static XtCallbackRec dnd_convert_cb_rec[2]; | |
980 static XtCallbackRec dnd_destroy_cb_rec[2]; | |
981 static int drag_not_done = 0; | |
979 | 982 |
980 static void | 983 static void |
981 x_cde_destroy_callback (Widget widget, XtPointer clientData, | 984 x_cde_destroy_callback (Widget widget, XtPointer clientData, |
982 XtPointer callData) | 985 XtPointer callData) |
983 { | 986 { |
987 DtDndDragFinishCallbackStruct *dragFinishInfo = | |
988 (DtDndDragFinishCallbackStruct *)callData; | |
989 DtDndContext *dragData = dragFinishInfo->dragData; | |
990 int i; | |
991 | |
992 /* free the items */ | |
993 if (callData != NULL && dragData != NULL) | |
994 { | |
995 if (dragData->protocol == DtDND_BUFFER_TRANSFER) | |
996 { | |
997 for (i = 0; i < dragData->numItems; i++) | |
998 { | |
999 XtFree(dragData->data.buffers[i].bp); | |
1000 if (dragData->data.buffers[i].name) | |
1001 XtFree(dragData->data.buffers[i].name); | |
1002 } | |
1003 } | |
1004 else | |
1005 { | |
1006 for (i = 0; i < dragData->numItems; i++) | |
1007 XtFree(dragData->data.files[i]); | |
1008 } | |
1009 } | |
1010 | |
1011 /* free the data string */ | |
984 xfree (clientData); | 1012 xfree (clientData); |
1013 | |
985 CurrentDragWidget = NULL; | 1014 CurrentDragWidget = NULL; |
986 } | 1015 } |
987 | 1016 |
988 static void | 1017 static void |
989 x_cde_convert_callback (Widget widget, XtPointer clientData, | 1018 x_cde_convert_callback (Widget widget, XtPointer clientData, |
993 (DtDndConvertCallbackStruct *) callData; | 1022 (DtDndConvertCallbackStruct *) callData; |
994 char *textdata = (char *) clientData; | 1023 char *textdata = (char *) clientData; |
995 char *textptr = NULL; | 1024 char *textptr = NULL; |
996 int i; | 1025 int i; |
997 | 1026 |
998 if(convertInfo == NULL) | 1027 if (convertInfo == NULL) |
999 { | 1028 { |
1000 return; | 1029 return; |
1001 } | 1030 } |
1002 | 1031 |
1003 if((convertInfo->dragData->protocol != DtDND_BUFFER_TRANSFER | 1032 if ((convertInfo->dragData->protocol != DtDND_BUFFER_TRANSFER |
1004 && convertInfo->dragData->protocol != DtDND_FILENAME_TRANSFER) || | 1033 && convertInfo->dragData->protocol != DtDND_FILENAME_TRANSFER) || |
1005 (convertInfo->reason != DtCR_DND_CONVERT_DATA)) | 1034 (convertInfo->reason != DtCR_DND_CONVERT_DATA)) |
1006 { | 1035 { |
1007 return; | 1036 return; |
1008 } | 1037 } |
1024 } | 1053 } |
1025 | 1054 |
1026 convertInfo->status = DtDND_SUCCESS; | 1055 convertInfo->status = DtDND_SUCCESS; |
1027 } | 1056 } |
1028 | 1057 |
1029 | |
1030 static XtCallbackRec dnd_convert_cb_rec[2]; | |
1031 static XtCallbackRec dnd_destroy_cb_rec[2]; | |
1032 static int drag_not_done = 0; | |
1033 | |
1034 static Lisp_Object | 1058 static Lisp_Object |
1035 abort_current_drag(Lisp_Object arg) | 1059 abort_current_drag(Lisp_Object arg) |
1036 { | 1060 { |
1037 if(CurrentDragWidget && drag_not_done) | 1061 if (CurrentDragWidget && drag_not_done) |
1038 { | 1062 { |
1039 XmDragCancel(CurrentDragWidget); | 1063 XmDragCancel(CurrentDragWidget); |
1040 CurrentDragWidget = NULL; | 1064 CurrentDragWidget = NULL; |
1041 } | 1065 } |
1042 return arg; | 1066 return arg; |
1059 XEvent x_event; | 1083 XEvent x_event; |
1060 Widget wid = FRAME_X_TEXT_WIDGET (f); | 1084 Widget wid = FRAME_X_TEXT_WIDGET (f); |
1061 Display *display = XtDisplayOfObject (wid); | 1085 Display *display = XtDisplayOfObject (wid); |
1062 struct device *d = get_device_from_display (display); | 1086 struct device *d = get_device_from_display (display); |
1063 struct x_device *xd = DEVICE_X_DATA (d); | 1087 struct x_device *xd = DEVICE_X_DATA (d); |
1088 XWindowAttributes win_attrib; | |
1064 unsigned int modifier = 0, state = 0; | 1089 unsigned int modifier = 0, state = 0; |
1065 char *Ctext; | 1090 char *Ctext; |
1066 int numItems = 0, textlen = 0, pos = 0; | 1091 int numItems = 0, textlen = 0, pos = 0; |
1067 struct Lisp_Event *lisp_event = XEVENT(event); | 1092 struct Lisp_Event *lisp_event = XEVENT(event); |
1068 Lisp_Object item = Qnil; | 1093 Lisp_Object item = Qnil; |
1081 | 1106 |
1082 x_event.xbutton.type = ButtonPress; | 1107 x_event.xbutton.type = ButtonPress; |
1083 x_event.xbutton.send_event = False; | 1108 x_event.xbutton.send_event = False; |
1084 x_event.xbutton.display = XtDisplayOfObject(wid); | 1109 x_event.xbutton.display = XtDisplayOfObject(wid); |
1085 x_event.xbutton.window = XtWindowOfObject(wid); | 1110 x_event.xbutton.window = XtWindowOfObject(wid); |
1086 x_event.xbutton.root = XRootWindow(x_event.xkey.display, 0); | 1111 x_event.xbutton.root = XRootWindow(x_event.xbutton.display, 0); |
1087 x_event.xbutton.subwindow = 0; | 1112 x_event.xbutton.subwindow = 0; |
1088 x_event.xbutton.time = lisp_event->timestamp; | 1113 x_event.xbutton.time = lisp_event->timestamp; |
1089 x_event.xbutton.x = lisp_event->event.button.x; | 1114 x_event.xbutton.x = lisp_event->event.button.x; |
1090 x_event.xbutton.y = lisp_event->event.button.y; | 1115 x_event.xbutton.y = lisp_event->event.button.y; |
1091 x_event.xbutton.x_root = lisp_event->event.button.x; /* this is wrong */ | 1116 if (Success == XGetWindowAttributes (x_event.xbutton.display, |
1092 x_event.xbutton.y_root = lisp_event->event.button.y; | 1117 x_event.xbutton.window, |
1093 | 1118 &win_attrib)) |
1119 { | |
1120 x_event.xbutton.x_root = win_attrib.x + lisp_event->event.button.x; | |
1121 x_event.xbutton.y_root = win_attrib.y + lisp_event->event.button.y; | |
1122 } | |
1123 else | |
1124 { | |
1125 x_event.xbutton.x_root = lisp_event->event.button.x; /* this is wrong */ | |
1126 x_event.xbutton.y_root = lisp_event->event.button.y; | |
1127 } | |
1094 modifier = lisp_event->event.button.modifiers; | 1128 modifier = lisp_event->event.button.modifiers; |
1095 if (modifier & MOD_SHIFT) state |= ShiftMask; | 1129 if (modifier & MOD_SHIFT) state |= ShiftMask; |
1096 if (modifier & MOD_CONTROL) state |= ControlMask; | 1130 if (modifier & MOD_CONTROL) state |= ControlMask; |
1097 if (modifier & MOD_META) state |= xd->MetaMask; | 1131 if (modifier & MOD_META) state |= xd->MetaMask; |
1098 if (modifier & MOD_SUPER) state |= xd->SuperMask; | 1132 if (modifier & MOD_SUPER) state |= xd->SuperMask; |
1275 XEvent x_event; | 1309 XEvent x_event; |
1276 Widget wid = FRAME_X_TEXT_WIDGET (f); | 1310 Widget wid = FRAME_X_TEXT_WIDGET (f); |
1277 Display *display = XtDisplayOfObject (wid); | 1311 Display *display = XtDisplayOfObject (wid); |
1278 struct device *d = get_device_from_display (display); | 1312 struct device *d = get_device_from_display (display); |
1279 struct x_device *xd = DEVICE_X_DATA (d); | 1313 struct x_device *xd = DEVICE_X_DATA (d); |
1314 XWindowAttributes win_attrib; | |
1280 unsigned int modifier = 0, state = 0; | 1315 unsigned int modifier = 0, state = 0; |
1281 char *dnd_data = NULL; | 1316 char *dnd_data = NULL; |
1282 unsigned long dnd_len = 0; | 1317 unsigned long dnd_len = 0; |
1283 int dnd_typ = DndText, dnd_dealloc = 0; | 1318 int dnd_typ = DndText, dnd_dealloc = 0; |
1284 struct Lisp_Event *lisp_event = XEVENT(event); | 1319 struct Lisp_Event *lisp_event = XEVENT(event); |
1343 x_event.xbutton.root = XRootWindow(x_event.xkey.display, 0); | 1378 x_event.xbutton.root = XRootWindow(x_event.xkey.display, 0); |
1344 x_event.xbutton.subwindow = 0; | 1379 x_event.xbutton.subwindow = 0; |
1345 x_event.xbutton.time = lisp_event->timestamp; | 1380 x_event.xbutton.time = lisp_event->timestamp; |
1346 x_event.xbutton.x = lisp_event->event.button.x; | 1381 x_event.xbutton.x = lisp_event->event.button.x; |
1347 x_event.xbutton.y = lisp_event->event.button.y; | 1382 x_event.xbutton.y = lisp_event->event.button.y; |
1348 x_event.xbutton.x_root = lisp_event->event.button.x; /* this is wrong */ | 1383 if (Success == XGetWindowAttributes (x_event.xbutton.display, |
1349 x_event.xbutton.y_root = lisp_event->event.button.y; | 1384 x_event.xbutton.window, |
1385 &win_attrib)) | |
1386 { | |
1387 x_event.xbutton.x_root = win_attrib.x + lisp_event->event.button.x; | |
1388 x_event.xbutton.y_root = win_attrib.y + lisp_event->event.button.y; | |
1389 } | |
1390 else | |
1391 { | |
1392 x_event.xbutton.x_root = lisp_event->event.button.x; /* this is wrong */ | |
1393 x_event.xbutton.y_root = lisp_event->event.button.y; | |
1394 } | |
1350 | 1395 |
1351 modifier = lisp_event->event.button.modifiers; | 1396 modifier = lisp_event->event.button.modifiers; |
1352 if (modifier & MOD_SHIFT) state |= ShiftMask; | 1397 if (modifier & MOD_SHIFT) state |= ShiftMask; |
1353 if (modifier & MOD_CONTROL) state |= ControlMask; | 1398 if (modifier & MOD_CONTROL) state |= ControlMask; |
1354 if (modifier & MOD_META) state |= xd->MetaMask; | 1399 if (modifier & MOD_META) state |= xd->MetaMask; |
1363 | 1408 |
1364 DndSetData(dnd_typ, (unsigned char *)dnd_data, dnd_len); | 1409 DndSetData(dnd_typ, (unsigned char *)dnd_data, dnd_len); |
1365 if (dnd_dealloc) | 1410 if (dnd_dealloc) |
1366 xfree (dnd_data); | 1411 xfree (dnd_data); |
1367 | 1412 |
1413 /* the next thing blocks everything... */ | |
1368 if (DndHandleDragging(wid, &x_event)) | 1414 if (DndHandleDragging(wid, &x_event)) |
1369 return Qt; | 1415 return Qt; |
1370 } | 1416 } |
1371 return Qnil; | 1417 return Qnil; |
1372 } | 1418 } |