comparison src/frame-x.c @ 282:c42ec1d1cded r21-0b39

Import from CVS: tag r21-0b39
author cvs
date Mon, 13 Aug 2007 10:33:18 +0200
parents 90d73dddcdc4
children 558f606b08ae
comparison
equal deleted inserted replaced
281:090b52736db2 282:c42ec1d1cded
48 #include "events.h" 48 #include "events.h"
49 #include "extents.h" 49 #include "extents.h"
50 #include "faces.h" 50 #include "faces.h"
51 #include "frame.h" 51 #include "frame.h"
52 #include "window.h" 52 #include "window.h"
53
54 #ifdef HAVE_DRAGNDROP
55 #include "dragdrop.h"
56 #endif
53 57
54 #ifdef HAVE_OFFIX_DND 58 #ifdef HAVE_OFFIX_DND
55 #include "offix.h" 59 #include "offix.h"
56 #include "events-mod.h" 60 #include "events-mod.h"
57 #endif 61 #endif
1086 1090
1087 static void 1091 static void
1088 x_cde_transfer_callback (Widget widget, XtPointer clientData, 1092 x_cde_transfer_callback (Widget widget, XtPointer clientData,
1089 XtPointer callData) 1093 XtPointer callData)
1090 { 1094 {
1091 char *filePath, *buf; 1095 char *filePath, *hurl;
1092 int ii; 1096 int ii;
1093 Lisp_Object path = Qnil;
1094 Lisp_Object frame = Qnil; 1097 Lisp_Object frame = Qnil;
1095 Lisp_Object data = Qnil; 1098 Lisp_Object l_type = Qnil;
1099 Lisp_Object l_data = Qnil;
1096 struct gcpro gcpro1, gcpro2, gcpro3; 1100 struct gcpro gcpro1, gcpro2, gcpro3;
1101
1102 /*
1103 this needs to be changed to the new protocol:
1104 - we need the button, modifier and pointer states to create a
1105 correct misc_user_event
1106 - the data must be converted to the new format (URL/MIME)
1107 */
1108 return;
1097 1109
1098 DtDndTransferCallbackStruct *transferInfo = 1110 DtDndTransferCallbackStruct *transferInfo =
1099 (DtDndTransferCallbackStruct *) callData; 1111 (DtDndTransferCallbackStruct *) callData;
1100 1112
1101 if (transferInfo == NULL) 1113 if (transferInfo == NULL)
1102 return; 1114 return;
1103 1115
1104 GCPRO3 (path, frame, data); 1116 GCPRO3 (frame, l_type, l_data);
1105 1117
1106 frame = make_frame ((struct frame *) clientData); 1118 frame = make_frame ((struct frame *) clientData);
1107 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER) 1119 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER)
1108 { 1120 {
1121 l_type = Qdragdrop_URL;
1122
1109 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) 1123 for (ii = 0; ii < transferInfo->dropData->numItems; ii++)
1110 { 1124 {
1111 filePath = transferInfo->dropData->data.files[ii]; 1125 filePath = transferInfo->dropData->data.files[ii];
1126 hurl = dnd_url_hexify_string ((char *)filePath, "file:");
1112 /* ### Mule-izing required */ 1127 /* ### Mule-izing required */
1113 path = make_string ((Bufbyte *)filePath, strlen (filePath)); 1128 l_data = Fcons ( make_string (hurl, strlen (hurl)), l_data );
1114 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); 1129 xfree (hurl);
1115 } 1130 }
1116 } 1131 }
1117 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER) 1132 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER)
1118 { 1133 {
1119 int speccount = specpdl_depth(); 1134 int speccount = specpdl_depth();
1120 1135
1136 l_type = Qdragdrop_MIME;
1137 /* the meaning of this is not clear to me... */
1121 record_unwind_protect(abort_current_drag, Qnil); 1138 record_unwind_protect(abort_current_drag, Qnil);
1122 drag_not_done = 1; 1139 drag_not_done = 1;
1123 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) 1140 for (ii = 0; ii < transferInfo->dropData->numItems; ii++)
1124 { 1141 {
1125 filePath = transferInfo->dropData->data.buffers[ii].name; 1142 /* let us forget this name thing for now... */
1126 /* ### Mule-izing required */ 1143 /* filePath = transferInfo->dropData->data.buffers[ii].name;
1127 path = (filePath == NULL) ? Qnil 1144 path = (filePath == NULL) ? Qnil
1128 : make_string ((Bufbyte *)filePath, strlen (filePath)); 1145 : make_string ((Bufbyte *)filePath, strlen (filePath)); */
1129 buf = transferInfo->dropData->data.buffers[ii].bp; 1146 /* what, if the data is no text, and how can I tell it? */
1130 data = make_string((Bufbyte *)buf, 1147 l_data = Fcons ( list3 ( make_string ("text/plain", 10),
1131 transferInfo->dropData->data.buffers[ii].size); 1148 make_string ("8bit", 4),
1132 va_run_hook_with_args(Qdrag_and_drop_functions, 3, frame, path, 1149 make_ext_string (transferInfo->dropData->data.buffers[ii].bp,
1133 data); 1150 transferInfo->dropData->data.buffers[ii].size,
1151 FORMAT_CTEXT) ),
1152 l_data );
1134 } 1153 }
1135 drag_not_done = 0; 1154 drag_not_done = 0;
1155 /* and what is this */
1136 unbind_to(speccount, Qnil); 1156 unbind_to(speccount, Qnil);
1137 } 1157 }
1158
1159 /* where are button, mod and pos? -- query the pointer... */
1160 enqueue_misc_user_event ( frame, Qdragdrop_drop_dispatch,
1161 Fcons (l_type, l_data) );
1138 1162
1139 UNGCPRO; 1163 UNGCPRO;
1140 return; 1164 return;
1141 } 1165 }
1142 #endif /* HAVE_CDE */ 1166 #endif /* HAVE_CDE */
1624 text_y += wid->core.height + 2*bord; 1648 text_y += wid->core.height + 2*bord;
1625 } 1649 }
1626 } 1650 }
1627 1651
1628 #ifdef HAVE_SCROLLBARS 1652 #ifdef HAVE_SCROLLBARS
1629 { 1653 f->scrollbar_y_offset = topbreadth + textbord;
1630 /* The scrollbar positioning is completely handled by redisplay. We 1654 #endif
1631 just need to know which sides they are supposed to go on. */
1632 unsigned char scrollbar_placement;
1633
1634 Xt_GET_VALUE (text, XtNscrollBarPlacement, &scrollbar_placement);
1635 switch (scrollbar_placement)
1636 {
1637 case XtTOP_LEFT:
1638 f->scrollbar_on_left = 1, f->scrollbar_on_top = 1; break;
1639 case XtBOTTOM_LEFT:
1640 f->scrollbar_on_left = 1, f->scrollbar_on_top = 0; break;
1641 case XtTOP_RIGHT:
1642 f->scrollbar_on_left = 0, f->scrollbar_on_top = 1; break;
1643 case XtBOTTOM_RIGHT:
1644 f->scrollbar_on_left = 0, f->scrollbar_on_top = 0; break;
1645 }
1646 f->scrollbar_y_offset = topbreadth + textbord;
1647 }
1648 #endif /* HAVE_SCROLLBARS */
1649 1655
1650 /* finally the text area */ 1656 /* finally the text area */
1651 XtConfigureWidget (text, text_x, text_y, 1657 XtConfigureWidget (text, text_x, text_y,
1652 width - 2*textbord, 1658 width - 2*textbord,
1653 height - text_y - 2*textbord, 1659 height - text_y - 2*textbord,
2030 /* Set up the values of the widget/frame. A case could be made for putting 2036 /* Set up the values of the widget/frame. A case could be made for putting
2031 this inside of the widget's initialize method. */ 2037 this inside of the widget's initialize method. */
2032 2038
2033 update_frame_face_values (f); 2039 update_frame_face_values (f);
2034 x_initialize_frame_size (f); 2040 x_initialize_frame_size (f);
2035 /* 2041 /* Kyle:
2036 * update_frame_title() can't be done here, because some of the 2042 * update_frame_title() can't be done here, because some of the
2037 * modeline specs depend on the frame's device having a selected 2043 * modeline specs depend on the frame's device having a selected
2038 * frame, and that may not have been set up yet. The redisplay 2044 * frame, and that may not have been set up yet. The redisplay
2039 * will update the frame title anyway, so nothing is lost. 2045 * will update the frame title anyway, so nothing is lost.
2046 * JV:
2047 * It turns out it gives problems with FVWMs name based mapping.
2048 * We'll just need to be carefull in the modeline specs.
2040 */ 2049 */
2041 /* update_frame_title (f); */ 2050 update_frame_title (f);
2042 } 2051 }
2043 2052
2044 static void 2053 static void
2045 x_init_frame_3 (struct frame *f) 2054 x_init_frame_3 (struct frame *f)
2046 { 2055 {
2568 it. */ 2577 it. */
2569 if (EQ (name, Qbackground)) 2578 if (EQ (name, Qbackground))
2570 MAYBE_DEVMETH (XDEVICE (frm->device), redraw_frame_toolbars, (frm)); 2579 MAYBE_DEVMETH (XDEVICE (frm->device), redraw_frame_toolbars, (frm));
2571 #endif /* HAVE_TOOLBARS */ 2580 #endif /* HAVE_TOOLBARS */
2572 2581
2573 /* The intent of this code is to cause the frame size in 2582 /* Set window manager resize increment hints according to
2574 characters to remain the same when the font changes, at the 2583 the new character size */
2575 expense of changing the frame size in pixels. It's not
2576 totally clear that this is the right thing to do, but it's
2577 not clearly wrong either. */
2578 if (EQ (name, Qfont)) 2584 if (EQ (name, Qfont))
2579 { 2585 EmacsFrameRecomputeCellSize (FRAME_X_TEXT_WIDGET (frm));
2580 EmacsFrameRecomputeCellSize (FRAME_X_TEXT_WIDGET (frm));
2581 Fset_frame_size (frame,
2582 make_int (frm->width),
2583 make_int (frm->height),
2584 Qnil);
2585 }
2586 } 2586 }
2587 2587
2588 2588
2589 /************************************************************************/ 2589 /************************************************************************/
2590 /* initialization */ 2590 /* initialization */