comparison src/frame-x.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents a300bb07d72d
children bbff43aa5eb7
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
276 struct device *d = get_device_from_display (dpy); 276 struct device *d = get_device_from_display (dpy);
277 Window w = XtWindow (widget); 277 Window w = XtWindow (widget);
278 int need_delete = 1; 278 int need_delete = 1;
279 int need_focus = 1; 279 int need_focus = 1;
280 280
281 if (!XtIsWMShell (widget)) 281 assert (XtIsWMShell (widget));
282 abort ();
283 282
284 { 283 {
285 Atom type, *atoms = 0; 284 Atom type, *atoms = 0;
286 int format = 0; 285 int format = 0;
287 unsigned long nitems = 0; 286 unsigned long nitems = 0;
994 { 993 {
995 if (dragData->protocol == DtDND_BUFFER_TRANSFER) 994 if (dragData->protocol == DtDND_BUFFER_TRANSFER)
996 { 995 {
997 for (i = 0; i < dragData->numItems; i++) 996 for (i = 0; i < dragData->numItems; i++)
998 { 997 {
999 XtFree(dragData->data.buffers[i].bp); 998 XtFree((char *) dragData->data.buffers[i].bp);
1000 if (dragData->data.buffers[i].name) 999 if (dragData->data.buffers[i].name)
1001 XtFree(dragData->data.buffers[i].name); 1000 XtFree(dragData->data.buffers[i].name);
1002 } 1001 }
1003 } 1002 }
1004 else 1003 else
1149 } 1148 }
1150 textlen += XSTRING_LENGTH (XCAR (item)) + 1; 1149 textlen += XSTRING_LENGTH (XCAR (item)) + 1;
1151 numItems++; 1150 numItems++;
1152 item = XCDR (item); 1151 item = XCDR (item);
1153 } 1152 }
1154 1153
1155 if (numItems) 1154 if (numItems)
1156 { 1155 {
1157 /* 1156 /*
1158 * concatenate all strings given to one large string, with 1157 * concatenate all strings given to one large string, with
1159 * \0 as separator. List is ended by \0. 1158 * \0 as separator. List is ended by \0.
1160 */ 1159 */
1161 Ctext = (char *)xmalloc (textlen+1); 1160 Ctext = (char *)xmalloc (textlen+1);
1162 Ctext[0] = 0; 1161 Ctext[0] = 0;
1163 1162
1164 item = dragdata; 1163 item = dragdata;
1165 while (!NILP (item)) 1164 while (!NILP (item))
1166 { 1165 {
1167 if (!STRINGP (XCAR (item))) 1166 if (!STRINGP (XCAR (item)))
1168 { 1167 {
1174 strcpy (Ctext+pos, (CONST char *)XSTRING_DATA (XCAR (item))); 1173 strcpy (Ctext+pos, (CONST char *)XSTRING_DATA (XCAR (item)));
1175 pos += XSTRING_LENGTH (XCAR (item)) + 1; 1174 pos += XSTRING_LENGTH (XCAR (item)) + 1;
1176 item = XCDR (item); 1175 item = XCDR (item);
1177 } 1176 }
1178 Ctext[pos] = 0; 1177 Ctext[pos] = 0;
1179 1178
1180 dnd_convert_cb_rec[0].callback = x_cde_convert_callback; 1179 dnd_convert_cb_rec[0].callback = x_cde_convert_callback;
1181 dnd_convert_cb_rec[0].closure = (XtPointer) Ctext; 1180 dnd_convert_cb_rec[0].closure = (XtPointer) Ctext;
1182 dnd_convert_cb_rec[1].callback = NULL; 1181 dnd_convert_cb_rec[1].callback = NULL;
1183 dnd_convert_cb_rec[1].closure = NULL; 1182 dnd_convert_cb_rec[1].closure = NULL;
1184 1183
1185 dnd_destroy_cb_rec[0].callback = x_cde_destroy_callback; 1184 dnd_destroy_cb_rec[0].callback = x_cde_destroy_callback;
1186 dnd_destroy_cb_rec[0].closure = (XtPointer) Ctext; 1185 dnd_destroy_cb_rec[0].closure = (XtPointer) Ctext;
1187 dnd_destroy_cb_rec[1].callback = NULL; 1186 dnd_destroy_cb_rec[1].callback = NULL;
1188 dnd_destroy_cb_rec[1].closure = NULL; 1187 dnd_destroy_cb_rec[1].closure = NULL;
1189 1188
1196 dnd_destroy_cb_rec, 1195 dnd_destroy_cb_rec,
1197 NULL, 0); 1196 NULL, 0);
1198 } 1197 }
1199 1198
1200 UNGCPRO; 1199 UNGCPRO;
1201 1200
1202 return numItems?Qt:Qnil; 1201 return numItems?Qt:Qnil;
1203 } 1202 }
1204 1203
1205 return Qnil; 1204 return Qnil;
1206 } 1205 }
1266 path = (filePath == NULL) ? Qnil 1265 path = (filePath == NULL) ? Qnil
1267 : make_string ((Bufbyte *)filePath, strlen (filePath)); */ 1266 : make_string ((Bufbyte *)filePath, strlen (filePath)); */
1268 /* what, if the data is no text, and how can I tell it? */ 1267 /* what, if the data is no text, and how can I tell it? */
1269 l_data = Fcons ( list3 ( list1 ( make_string ((Bufbyte *)"text/plain", 10) ), 1268 l_data = Fcons ( list3 ( list1 ( make_string ((Bufbyte *)"text/plain", 10) ),
1270 make_string ((Bufbyte *)"8bit", 4), 1269 make_string ((Bufbyte *)"8bit", 4),
1271 make_string ((Bufbyte *)transferInfo->dropData->data.buffers[ii].bp, 1270 make_string ((Bufbyte *)transferInfo->dropData->data.buffers[ii].bp,
1272 transferInfo->dropData->data.buffers[ii].size) ), 1271 transferInfo->dropData->data.buffers[ii].size) ),
1273 l_data ); 1272 l_data );
1274 } 1273 }
1275 drag_not_done = 0; 1274 drag_not_done = 0;
1276 unbind_to(speccount, Qnil); 1275 unbind_to(speccount, Qnil);
1277 } 1276 }
1278 else /* the other cases: NOOP_TRANSFER */ 1277 else /* the other cases: NOOP_TRANSFER */
1279 enqueue=0; 1278 enqueue=0;
1280 1279
1281 /* The Problem: no button and mods from CDE... */ 1280 /* The Problem: no button and mods from CDE... */
1282 if (enqueue) 1281 if (enqueue)
1283 enqueue_misc_user_event_pos ( frame, Qdragdrop_drop_dispatch, 1282 enqueue_misc_user_event_pos ( frame, Qdragdrop_drop_dispatch,
1284 Fcons (l_type, l_data), 1283 Fcons (l_type, l_data),
1285 0 /* this is the button */, 1284 0 /* this is the button */,
1286 0 /* these are the mods */, 1285 0 /* these are the mods */,
1287 transferInfo->x, 1286 transferInfo->x,
1359 else 1358 else
1360 { 1359 {
1361 if (!STRINGP (data)) 1360 if (!STRINGP (data))
1362 return Qnil; 1361 return Qnil;
1363 1362
1364 /* and whats with MULE data ??? */ 1363 /* and what's with MULE data ??? */
1365 dnd_data = (char *)XSTRING_DATA (data); 1364 dnd_data = (char *)XSTRING_DATA (data);
1366 dnd_len = XSTRING_LENGTH (data) + 1; /* the zero */ 1365 dnd_len = XSTRING_LENGTH (data) + 1; /* the zero */
1367 1366
1368 } 1367 }
1369 1368
1370 /* 1369 /* not so gross hack that converts an emacs event back to a XEvent */
1371 * not so cross hack that converts a emacs event back to a XEvent
1372 */
1373 1370
1374 x_event.xbutton.type = ButtonPress; 1371 x_event.xbutton.type = ButtonPress;
1375 x_event.xbutton.send_event = False; 1372 x_event.xbutton.send_event = False;
1376 x_event.xbutton.display = XtDisplayOfObject(wid); 1373 x_event.xbutton.display = XtDisplayOfObject(wid);
1377 x_event.xbutton.window = XtWindowOfObject(wid); 1374 x_event.xbutton.window = XtWindowOfObject(wid);
1921 #endif /* EXTERNAL_WIDGET */ 1918 #endif /* EXTERNAL_WIDGET */
1922 { 1919 {
1923 XtSetArg (al[ac], XtNinput, True); ac++; 1920 XtSetArg (al[ac], XtNinput, True); ac++;
1924 XtSetArg (al[ac], XtNminWidthCells, 10); ac++; 1921 XtSetArg (al[ac], XtNminWidthCells, 10); ac++;
1925 XtSetArg (al[ac], XtNminHeightCells, 1); ac++; 1922 XtSetArg (al[ac], XtNminHeightCells, 1); ac++;
1926 XtSetArg (al[ac], XtNvisual, visual); ac++; 1923 XtSetArg (al[ac], XtNvisual, visual); ac++;
1927 XtSetArg (al[ac], XtNdepth, depth); ac++; 1924 XtSetArg (al[ac], XtNdepth, depth); ac++;
1928 XtSetArg (al[ac], XtNcolormap, cmap); ac++; 1925 XtSetArg (al[ac], XtNcolormap, cmap); ac++;
1929 } 1926 }
1930 1927
1931 if (!NILP (parent)) 1928 if (!NILP (parent))
1932 { 1929 {
1933 parentwid = FRAME_X_SHELL_WIDGET (XFRAME (parent)); 1930 parentwid = FRAME_X_SHELL_WIDGET (XFRAME (parent));
1993 When we first removed it we only kept the XtRealizeWidget call in 1990 When we first removed it we only kept the XtRealizeWidget call in
1994 XtPopup. For everything except HP's that was enough. For HP's, 1991 XtPopup. For everything except HP's that was enough. For HP's,
1995 though, the failure to call the popup callbacks resulted in XEmacs 1992 though, the failure to call the popup callbacks resulted in XEmacs
1996 not accepting any input. Bizarre but true. Stupid but true. 1993 not accepting any input. Bizarre but true. Stupid but true.
1997 1994
1998 So, in case there are any other gotches floating out there along 1995 So, in case there are any other gotchas floating out there along
1999 the same lines I've duplicated the majority of XtPopup here. It 1996 the same lines I've duplicated the majority of XtPopup here. It
2000 assumes no grabs and that the widget is not already popped up, both 1997 assumes no grabs and that the widget is not already popped up, both
2001 valid assumptions for the one place this is called from. */ 1998 valid assumptions for the one place this is called from. */
2002 static void 1999 static void
2003 xemacs_XtPopup (Widget widget) 2000 xemacs_XtPopup (Widget widget)
2018 make absolutely sure... */ 2015 make absolutely sure... */
2019 Xt_SET_VALUE (widget, XtNmappedWhenManaged, False); 2016 Xt_SET_VALUE (widget, XtNmappedWhenManaged, False);
2020 XtRealizeWidget (widget); 2017 XtRealizeWidget (widget);
2021 Xt_SET_VALUE (widget, XtNmappedWhenManaged, True); 2018 Xt_SET_VALUE (widget, XtNmappedWhenManaged, True);
2022 } 2019 }
2023
2024 #ifdef HAVE_CDE
2025 /* Does this have to be non-automatic? */
2026 /* hack frame to respond to dnd messages */
2027 static XtCallbackRec dnd_transfer_cb_rec[2];
2028 #endif /* HAVE_CDE */
2029 2020
2030 /* create the windows for the specified frame and display them. 2021 /* create the windows for the specified frame and display them.
2031 Note that the widgets have already been created, and any 2022 Note that the widgets have already been created, and any
2032 necessary geometry calculations have already been done. */ 2023 necessary geometry calculations have already been done. */
2033 static void 2024 static void
2079 XIM_init_frame (f); 2070 XIM_init_frame (f);
2080 #endif /* HAVE_XIM */ 2071 #endif /* HAVE_XIM */
2081 2072
2082 #ifdef HACK_EDITRES 2073 #ifdef HACK_EDITRES
2083 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */ 2074 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */
2084 /* Instrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */ 2075 /* Intrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */
2085 /* pp. 483-493. */ 2076 /* pp. 483-493. */
2086 XtAddEventHandler (shell_widget, /* the shell widget in question */ 2077 XtAddEventHandler (shell_widget, /* the shell widget in question */
2087 (EventMask) NoEventMask,/* OR with existing mask */ 2078 (EventMask) NoEventMask,/* OR with existing mask */
2088 True, /* called on non-maskable events? */ 2079 True, /* called on non-maskable events? */
2089 (XtEventHandler) _XEditResCheckMessages, /* the handler */ 2080 (XtEventHandler) _XEditResCheckMessages, /* the handler */
2090 NULL); 2081 NULL);
2091 #endif /* HACK_EDITRES */ 2082 #endif /* HACK_EDITRES */
2092 2083
2093 #ifdef HAVE_CDE 2084 #ifdef HAVE_CDE
2094 { 2085 {
2086 XtCallbackRec dnd_transfer_cb_rec[2];
2087
2095 dnd_transfer_cb_rec[0].callback = x_cde_transfer_callback; 2088 dnd_transfer_cb_rec[0].callback = x_cde_transfer_callback;
2096 dnd_transfer_cb_rec[0].closure = (XtPointer) f; 2089 dnd_transfer_cb_rec[0].closure = (XtPointer) f;
2097 dnd_transfer_cb_rec[1].callback = NULL; 2090 dnd_transfer_cb_rec[1].callback = NULL;
2098 dnd_transfer_cb_rec[1].closure = NULL; 2091 dnd_transfer_cb_rec[1].closure = NULL;
2099 2092
2100 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f), 2093 DtDndVaDropRegister (FRAME_X_TEXT_WIDGET (f),
2101 DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER, 2094 DtDND_FILENAME_TRANSFER | DtDND_BUFFER_TRANSFER,
2102 XmDROP_COPY, dnd_transfer_cb_rec, 2095 XmDROP_COPY, dnd_transfer_cb_rec,
2103 DtNtextIsBuffer, True, 2096 DtNtextIsBuffer, True,
2104 DtNregisterChildren, True, 2097 DtNregisterChildren, True,
2105 DtNpreserveRegistration, False, 2098 DtNpreserveRegistration, False,
2106 NULL); 2099 NULL);
2107 } 2100 }
2108 #endif /* HAVE_CDE */ 2101 #endif /* HAVE_CDE */
2109 2102
2181 * modeline specs depend on the frame's device having a selected 2174 * modeline specs depend on the frame's device having a selected
2182 * frame, and that may not have been set up yet. The redisplay 2175 * frame, and that may not have been set up yet. The redisplay
2183 * will update the frame title anyway, so nothing is lost. 2176 * will update the frame title anyway, so nothing is lost.
2184 * JV: 2177 * JV:
2185 * It turns out it gives problems with FVWMs name based mapping. 2178 * It turns out it gives problems with FVWMs name based mapping.
2186 * We'll just need to be carefull in the modeline specs. 2179 * We'll just need to be careful in the modeline specs.
2187 */ 2180 */
2188 update_frame_title (f); 2181 update_frame_title (f);
2189 } 2182 }
2190 2183
2191 static void 2184 static void
2192 x_init_frame_3 (struct frame *f) 2185 x_init_frame_3 (struct frame *f)
2193 { 2186 {
2197 } 2190 }
2198 2191
2199 static void 2192 static void
2200 x_mark_frame (struct frame *f, void (*markobj) (Lisp_Object)) 2193 x_mark_frame (struct frame *f, void (*markobj) (Lisp_Object))
2201 { 2194 {
2202 ((markobj) (FRAME_X_ICON_PIXMAP (f))); 2195 markobj (FRAME_X_ICON_PIXMAP (f));
2203 ((markobj) (FRAME_X_ICON_PIXMAP_MASK (f))); 2196 markobj (FRAME_X_ICON_PIXMAP_MASK (f));
2204 } 2197 }
2205 2198
2206 static void 2199 static void
2207 x_set_frame_icon (struct frame *f) 2200 x_set_frame_icon (struct frame *f)
2208 { 2201 {
2628 2621
2629 /* Destroy the X window of frame S. */ 2622 /* Destroy the X window of frame S. */
2630 static void 2623 static void
2631 x_delete_frame (struct frame *f) 2624 x_delete_frame (struct frame *f)
2632 { 2625 {
2633 Widget w = FRAME_X_SHELL_WIDGET (f);
2634 Display *dpy = XtDisplay (w);
2635
2636 #ifndef HAVE_SESSION 2626 #ifndef HAVE_SESSION
2637 if (FRAME_X_TOP_LEVEL_FRAME_P (f)) 2627 if (FRAME_X_TOP_LEVEL_FRAME_P (f))
2638 x_wm_maybe_move_wm_command (f); 2628 x_wm_maybe_move_wm_command (f);
2639 #endif /* HAVE_SESSION */ 2629 #endif /* HAVE_SESSION */
2640 2630
2641 #ifdef EXTERNAL_WIDGET 2631 #ifdef HAVE_CDE
2642 expect_x_error (dpy); 2632 DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f));
2643 /* for obscure reasons having (I think) to do with the internal 2633 #endif /* HAVE_CDE */
2644 window-to-widget hierarchy maintained by Xt, we have to call 2634
2645 XtUnrealizeWidget() here. Xt can really suck. */ 2635 assert (FRAME_X_SHELL_WIDGET (f));
2646 if (f->being_deleted) 2636 if (FRAME_X_SHELL_WIDGET (f))
2647 XtUnrealizeWidget (w); 2637 {
2648 XtDestroyWidget (w); 2638 Display *dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f));
2649 x_error_occurred_p (dpy); 2639 expect_x_error (dpy);
2650 #else 2640 /* for obscure reasons having (I think) to do with the internal
2651 XtDestroyWidget (w); 2641 window-to-widget hierarchy maintained by Xt, we have to call
2652 XFlush (dpy); /* make sure the windows are really gone! */ 2642 XtUnrealizeWidget() here. Xt can really suck. */
2653 #endif /* EXTERNAL_WIDGET */ 2643 if (f->being_deleted)
2644 XtUnrealizeWidget (FRAME_X_SHELL_WIDGET (f));
2645 XtDestroyWidget (FRAME_X_SHELL_WIDGET (f));
2646 x_error_occurred_p (dpy);
2647
2648 /* make sure the windows are really gone! */
2649 /* ### Is this REALLY necessary? */
2650 XFlush (dpy);
2651
2652 FRAME_X_SHELL_WIDGET (f) = 0;
2653 }
2654 2654
2655 if (FRAME_X_GEOM_FREE_ME_PLEASE (f)) 2655 if (FRAME_X_GEOM_FREE_ME_PLEASE (f))
2656 xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f)); 2656 {
2657 xfree (f->frame_data); 2657 xfree (FRAME_X_GEOM_FREE_ME_PLEASE (f));
2658 f->frame_data = 0; 2658 FRAME_X_GEOM_FREE_ME_PLEASE (f) = 0;
2659 }
2660
2661 if (f->frame_data)
2662 {
2663 xfree (f->frame_data);
2664 f->frame_data = 0;
2665 }
2659 } 2666 }
2660 2667
2661 static void 2668 static void
2662 x_update_frame_external_traits (struct frame* frm, Lisp_Object name) 2669 x_update_frame_external_traits (struct frame* frm, Lisp_Object name)
2663 { 2670 {
2664 Arg av[10]; 2671 Arg al[10];
2665 int ac = 0; 2672 int ac = 0;
2666 Lisp_Object frame = Qnil; 2673 Lisp_Object frame;
2667 2674
2668 XSETFRAME(frame, frm); 2675 XSETFRAME(frame, frm);
2669 2676
2670 if (EQ (name, Qforeground)) 2677 if (EQ (name, Qforeground))
2671 { 2678 {
2673 XColor fgc; 2680 XColor fgc;
2674 2681
2675 if (!EQ (color, Vthe_null_color_instance)) 2682 if (!EQ (color, Vthe_null_color_instance))
2676 { 2683 {
2677 fgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)); 2684 fgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color));
2678 XtSetArg (av[ac], XtNforeground, (void *) fgc.pixel); ac++; 2685 XtSetArg (al[ac], XtNforeground, (void *) fgc.pixel); ac++;
2679 } 2686 }
2680 } 2687 }
2681 else if (EQ (name, Qbackground)) 2688 else if (EQ (name, Qbackground))
2682 { 2689 {
2683 Lisp_Object color = FACE_BACKGROUND (Vdefault_face, frame); 2690 Lisp_Object color = FACE_BACKGROUND (Vdefault_face, frame);
2684 XColor bgc; 2691 XColor bgc;
2685 2692
2686 if (!EQ (color, Vthe_null_color_instance)) 2693 if (!EQ (color, Vthe_null_color_instance))
2687 { 2694 {
2688 bgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)); 2695 bgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color));
2689 XtSetArg (av[ac], XtNbackground, (void *) bgc.pixel); ac++; 2696 XtSetArg (al[ac], XtNbackground, (void *) bgc.pixel); ac++;
2690 } 2697 }
2691 2698
2692 /* Really crappy way to force the modeline shadows to be 2699 /* Really crappy way to force the modeline shadows to be
2693 redrawn. But effective. */ 2700 redrawn. But effective. */
2694 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (frm); 2701 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (frm);
2697 else if (EQ (name, Qfont)) 2704 else if (EQ (name, Qfont))
2698 { 2705 {
2699 Lisp_Object font = FACE_FONT (Vdefault_face, frame, Vcharset_ascii); 2706 Lisp_Object font = FACE_FONT (Vdefault_face, frame, Vcharset_ascii);
2700 2707
2701 if (!EQ (font, Vthe_null_font_instance)) 2708 if (!EQ (font, Vthe_null_font_instance))
2702 XtSetArg (av[ac], XtNfont, 2709 XtSetArg (al[ac], XtNfont,
2703 (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))); 2710 (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)));
2704 ac++; 2711 ac++;
2705 } 2712 }
2706 else 2713 else
2707 abort (); 2714 abort ();
2708 2715
2709 XtSetValues (FRAME_X_TEXT_WIDGET (frm), av, ac); 2716 XtSetValues (FRAME_X_TEXT_WIDGET (frm), al, ac);
2710 2717
2711 #ifdef HAVE_TOOLBARS 2718 #ifdef HAVE_TOOLBARS
2712 /* Setting the background clears the entire frame area 2719 /* Setting the background clears the entire frame area
2713 including the toolbar so we force an immediate redraw of 2720 including the toolbar so we force an immediate redraw of
2714 it. */ 2721 it. */