comparison src/frame-x.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents bc4f2511bbea
children d1247f3cc363
comparison
equal deleted inserted replaced
5117:3742ea8250b5 5118:e0db3c197671
46 #include <X11/CoreP.h> /* Numerous places access the fields of 46 #include <X11/CoreP.h> /* Numerous places access the fields of
47 a core widget directly. We could 47 a core widget directly. We could
48 use XtGetValues(), but ... */ 48 use XtGetValues(), but ... */
49 #include <X11/Shell.h> 49 #include <X11/Shell.h>
50 #include <X11/ShellP.h> 50 #include <X11/ShellP.h>
51 #include "xmu.h" 51 #include <X11/Xmu/Editres.h>
52 #include "EmacsManager.h" 52 #include "EmacsManager.h"
53 #include "EmacsFrameP.h" 53 #include "EmacsFrameP.h"
54 #include "EmacsShell.h" 54 #include "EmacsShell.h"
55 #ifdef EXTERNAL_WIDGET 55 #ifdef EXTERNAL_WIDGET
56 #include "ExternalShell.h" 56 #include "ExternalShell.h"
58 58
59 #ifdef HAVE_DRAGNDROP 59 #ifdef HAVE_DRAGNDROP
60 #include "dragdrop.h" 60 #include "dragdrop.h"
61 #endif 61 #endif
62 62
63 #ifdef HAVE_OFFIX_DND
64 #include "offix.h"
65 #endif
66
67 /* Default properties to use when creating frames. */ 63 /* Default properties to use when creating frames. */
68 Lisp_Object Vdefault_x_frame_plist; 64 Lisp_Object Vdefault_x_frame_plist;
69 65
70 Lisp_Object Qoverride_redirect; 66 Lisp_Object Qoverride_redirect;
71 Lisp_Object Qx_resource_name; 67 Lisp_Object Qx_resource_name;
75 { XD_LISP_OBJECT, offsetof (struct x_frame, icon_pixmap) }, 71 { XD_LISP_OBJECT, offsetof (struct x_frame, icon_pixmap) },
76 { XD_LISP_OBJECT, offsetof (struct x_frame, icon_pixmap_mask) }, 72 { XD_LISP_OBJECT, offsetof (struct x_frame, icon_pixmap_mask) },
77 { XD_END } 73 { XD_END }
78 }; 74 };
79 75
76 #ifdef NEW_GC
77 DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("x-frame", x_frame,
78 0, x_frame_data_description_1,
79 Lisp_X_Frame);
80 #else /* not NEW_GC */
80 extern const struct sized_memory_description x_frame_data_description; 81 extern const struct sized_memory_description x_frame_data_description;
81 82
82 const struct sized_memory_description x_frame_data_description = { 83 const struct sized_memory_description x_frame_data_description = {
83 sizeof (struct x_frame), x_frame_data_description_1 84 sizeof (struct x_frame), x_frame_data_description_1
84 }; 85 };
86 #endif /* not NEW_GC */
85 87
86 EXFUN (Fx_window_id, 1); 88 EXFUN (Fx_window_id, 1);
87 89
88 90
89 /************************************************************************/ 91 /************************************************************************/
270 if (!XtIsWMShell (wmshell)) 272 if (!XtIsWMShell (wmshell))
271 ABORT (); 273 ABORT ();
272 if (cw <= 0 || ch <= 0) 274 if (cw <= 0 || ch <= 0)
273 ABORT (); 275 ABORT ();
274 276
275 XtSetArg (al[0], XtNwidthInc, cw); 277 Xt_SET_ARG (al[0], XtNwidthInc, cw);
276 XtSetArg (al[1], XtNheightInc, ch); 278 Xt_SET_ARG (al[1], XtNheightInc, ch);
277 XtSetValues (wmshell, al, 2); 279 XtSetValues (wmshell, al, 2);
278 } 280 }
279 281
280 void 282 void
281 x_wm_set_variable_size (Widget wmshell, int width, int height) 283 x_wm_set_variable_size (Widget wmshell, int width, int height)
288 /* See comment in EmacsShell.c */ 290 /* See comment in EmacsShell.c */
289 printf ("x_wm_set_variable_size: %d %d\n", width, height); 291 printf ("x_wm_set_variable_size: %d %d\n", width, height);
290 fflush (stdout); 292 fflush (stdout);
291 #endif 293 #endif
292 294
293 XtSetArg (al[0], XtNwidthCells, width); 295 Xt_SET_ARG (al[0], XtNwidthCells, width);
294 XtSetArg (al[1], XtNheightCells, height); 296 Xt_SET_ARG (al[1], XtNheightCells, height);
295 XtSetValues (wmshell, al, 2); 297 XtSetValues (wmshell, al, 2);
296 } 298 }
297 299
298 /* If the WM_PROTOCOLS property does not already contain WM_TAKE_FOCUS 300 /* If the WM_PROTOCOLS property does not already contain WM_TAKE_FOCUS
299 and WM_DELETE_WINDOW, then add them. (They may already be present 301 and WM_DELETE_WINDOW, then add them. (They may already be present
497 defi(Qheight, XtNheight); 499 defi(Qheight, XtNheight);
498 defi(Qleft, XtNx); 500 defi(Qleft, XtNx);
499 defi(Qtop, XtNy); 501 defi(Qtop, XtNy);
500 502
501 #undef def 503 #undef def
504 #undef defi
502 } 505 }
503 506
504 static Lisp_Object 507 static Lisp_Object
505 color_to_string (Widget w, unsigned long pixel) 508 color_to_string (Widget w, unsigned long pixel)
506 { 509 {
657 /* #### Caching is device-independent - belongs in update_frame_title. */ 660 /* #### Caching is device-independent - belongs in update_frame_title. */
658 Xt_GET_VALUE (FRAME_X_SHELL_WIDGET (f), Xt_resource_name, &old_XtValue); 661 Xt_GET_VALUE (FRAME_X_SHELL_WIDGET (f), Xt_resource_name, &old_XtValue);
659 if (!old_XtValue || strcmp (new_XtValue, old_XtValue)) 662 if (!old_XtValue || strcmp (new_XtValue, old_XtValue))
660 { 663 {
661 Arg al[2]; 664 Arg al[2];
662 XtSetArg (al[0], Xt_resource_name, new_XtValue); 665 Xt_SET_ARG (al[0], Xt_resource_name, new_XtValue);
663 XtSetArg (al[1], Xt_resource_encoding_name, encoding); 666 Xt_SET_ARG (al[1], Xt_resource_encoding_name, encoding);
664 XtSetValues (FRAME_X_SHELL_WIDGET (f), al, 2); 667 XtSetValues (FRAME_X_SHELL_WIDGET (f), al, 2);
665 } 668 }
666 } 669 }
667 670
668 static void 671 static void
734 Bool height_specified_p = False; 737 Bool height_specified_p = False;
735 Bool x_position_specified_p = False; 738 Bool x_position_specified_p = False;
736 Bool y_position_specified_p = False; 739 Bool y_position_specified_p = False;
737 Bool internal_border_width_specified = False; 740 Bool internal_border_width_specified = False;
738 Lisp_Object tail; 741 Lisp_Object tail;
739 Widget w = FRAME_X_TEXT_WIDGET (f); 742 Widget w;
743
744 /* We can be called after the X IO error handler has seen a broken pipe on
745 the relevant display. Don't do anything in that case. */
746 if (!FRAME_LIVE_P (f) || DEVICE_X_BEING_DELETED (XDEVICE (FRAME_DEVICE (f))))
747 return;
748
749 w = FRAME_X_TEXT_WIDGET (f);
740 750
741 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail))) 751 for (tail = plist; !NILP (tail); tail = Fcdr (Fcdr (tail)))
742 { 752 {
743 Lisp_Object prop = Fcar (tail); 753 Lisp_Object prop = Fcar (tail);
744 Lisp_Object val = Fcar (Fcdr (tail)); 754 Lisp_Object val = Fcar (Fcdr (tail));
765 Qxt_widget_arg_encoding); 775 Qxt_widget_arg_encoding);
766 XtVaSetValues (w, XtVaTypedArg, extprop, 776 XtVaSetValues (w, XtVaTypedArg, extprop,
767 /* !!#### Verify this + 1 and document 777 /* !!#### Verify this + 1 and document
768 as zero-termination */ 778 as zero-termination */
769 XtRString, extval, extvallen + 1, 779 XtRString, extval, extvallen + 1,
770 (XtArgVal) NULL); 780 NULL);
771 } 781 }
772 else 782 else
773 XtVaSetValues (w, XtVaTypedArg, extprop, XtRInt, 783 XtVaSetValues (w, XtVaTypedArg, extprop, XtRInt,
774 XINT (val), sizeof (int), 784 XINT (val), sizeof (int),
775 (XtArgVal) NULL); 785 NULL);
776 } 786 }
777 else if (SYMBOLP (prop)) 787 else if (SYMBOLP (prop))
778 { 788 {
779 Lisp_Object str = Fget (prop, Qx_resource_name, Qnil); 789 Lisp_Object str = Fget (prop, Qx_resource_name, Qnil);
780 int int_p = !NILP (Fget (prop, Qintegerp, Qnil)); 790 int int_p = !NILP (Fget (prop, Qintegerp, Qnil));
869 /* XtN... */ 879 /* XtN... */
870 strext, 880 strext,
871 /* !!#### Verify this + 1 and document 881 /* !!#### Verify this + 1 and document
872 as zero-termination */ 882 as zero-termination */
873 XtRString, extval, extvallen + 1, 883 XtRString, extval, extvallen + 1,
874 (XtArgVal) NULL); 884 NULL);
875 } 885 }
876 886
877 #ifdef HAVE_SCROLLBARS 887 #ifdef HAVE_SCROLLBARS
878 if (!qxestrcmp_ascii (XSTRING_DATA (str), "scrollBarWidth") 888 if (!qxestrcmp_ascii (XSTRING_DATA (str), "scrollBarWidth")
879 || !qxestrcmp_ascii (XSTRING_DATA (str), "scrollBarHeight")) 889 || !qxestrcmp_ascii (XSTRING_DATA (str), "scrollBarHeight"))
984 } 994 }
985 995
986 frame_title_format_already_set = 1; 996 frame_title_format_already_set = 1;
987 } 997 }
988 998
989 #if defined (HAVE_CDE) || defined (HAVE_OFFIX_DND) 999 #if defined (HAVE_CDE)
990 1000
991 static Extbyte * 1001 static Extbyte *
992 start_drag_internal_1 (Lisp_Object event, Lisp_Object data, 1002 start_drag_internal_1 (Lisp_Object event, Lisp_Object data,
993 Lisp_Object encoding, XEvent *x_event, int listp, 1003 Lisp_Object encoding, XEvent *x_event, int listp,
994 Widget *wid_out, Bytecount *len_out, 1004 Widget *wid_out, Bytecount *len_out,
1077 1087
1078 *wid_out = wid; 1088 *wid_out = wid;
1079 return dnd_data; 1089 return dnd_data;
1080 } 1090 }
1081 1091
1082 #endif /* defined (HAVE_CDE) || defined (HAVE_OFFIX_DND) */ 1092 #endif /* defined (HAVE_CDE) */
1083 1093
1084 #ifdef HAVE_CDE 1094 #ifdef HAVE_CDE
1085 #include <Dt/Dt.h> 1095 #include <Dt/Dt.h>
1086 #include <Dt/Dnd.h> 1096 #include <Dt/Dnd.h>
1087 1097
1315 UNGCPRO; 1325 UNGCPRO;
1316 return; 1326 return;
1317 } 1327 }
1318 #endif /* HAVE_CDE */ 1328 #endif /* HAVE_CDE */
1319 1329
1320 #ifdef HAVE_OFFIX_DND
1321
1322 DEFUN ("offix-start-drag-internal", Foffix_start_drag_internal, 2, 3, 0, /*
1323 Start a OffiX drag from a buffer.
1324 First arg is the event that started the drag,
1325 second arg should be some string, and the third
1326 is the type of the data (this should be an int).
1327 The type defaults to DndText (4).
1328 */
1329 (event, data, dtyp))
1330 {
1331 Extbyte *dnd_data;
1332 XEvent x_event;
1333 Bytecount dnd_len;
1334 Widget wid;
1335 int num_items;
1336 int dnd_type = DndText;
1337
1338 if (!NILP (dtyp))
1339 {
1340 CHECK_INT (dtyp);
1341 dnd_type = XINT (dtyp);
1342 }
1343
1344 dnd_data = start_drag_internal_1 (event, data, Qoffix_dnd_encoding,
1345 &x_event, dnd_type == DndFiles,
1346 &wid, &dnd_len, &num_items);
1347
1348 DndSetData (dnd_type, (UExtbyte *) dnd_data, dnd_len);
1349 xfree (dnd_data, Extbyte *);
1350
1351 /* the next thing blocks everything... */
1352 if (DndHandleDragging (wid, &x_event))
1353 return Qt;
1354
1355 return Qnil;
1356 }
1357
1358 #endif /* HAVE_OFFIX_DND */
1359
1360 1330
1361 /************************************************************************/ 1331 /************************************************************************/
1362 /* widget creation */ 1332 /* widget creation */
1363 /************************************************************************/ 1333 /************************************************************************/
1364 1334
1521 &frame_x, &frame_y, 1491 &frame_x, &frame_y,
1522 &frame_w, &frame_h); 1492 &frame_w, &frame_h);
1523 if (! (frame_flags & (WidthValue | HeightValue))) 1493 if (! (frame_flags & (WidthValue | HeightValue)))
1524 { 1494 {
1525 Arg al[2]; 1495 Arg al[2];
1526 XtSetArg (al [0], XtNwidth, &frame_w); 1496 Xt_SET_ARG (al [0], XtNwidth, &frame_w);
1527 XtSetArg (al [1], XtNheight, &frame_h); 1497 Xt_SET_ARG (al [1], XtNheight, &frame_h);
1528 XtGetValues (ew, al, 2); 1498 XtGetValues (ew, al, 2);
1529 if (!frame_w && !frame_h) 1499 if (!frame_w && !frame_h)
1530 { 1500 {
1531 frame_w = 64; 1501 frame_w = 64;
1532 frame_h = 12; 1502 frame_h = 12;
1536 if (frame_flags & (WidthValue | HeightValue)) 1506 if (frame_flags & (WidthValue | HeightValue))
1537 EmacsFrameSetCharSize (ew, frame_w, frame_h); 1507 EmacsFrameSetCharSize (ew, frame_w, frame_h);
1538 if (frame_flags & (XValue | YValue)) 1508 if (frame_flags & (XValue | YValue))
1539 { 1509 {
1540 Arg al[2]; 1510 Arg al[2];
1541 XtSetArg (al [0], XtNwidth, &frame_w); 1511 Xt_SET_ARG (al [0], XtNwidth, &frame_w);
1542 XtSetArg (al [1], XtNheight, &frame_h); 1512 Xt_SET_ARG (al [1], XtNheight, &frame_h);
1543 XtGetValues (ew, al, 2); 1513 XtGetValues (ew, al, 2);
1544 1514
1545 if (frame_flags & XNegative) 1515 if (frame_flags & XNegative)
1546 frame_x += frame_w; 1516 frame_x += frame_w;
1547 if (frame_flags & YNegative) 1517 if (frame_flags & YNegative)
1548 frame_y += frame_h; 1518 frame_y += frame_h;
1549 1519
1550 XtSetArg (al [0], XtNx, frame_x); 1520 Xt_SET_ARG (al [0], XtNx, frame_x);
1551 XtSetArg (al [1], XtNy, frame_y); 1521 Xt_SET_ARG (al [1], XtNy, frame_y);
1552 XtSetValues (ew, al, 2); 1522 XtSetValues (ew, al, 2);
1553 } 1523 }
1554 return; 1524 return;
1555 } 1525 }
1556 #endif 1526 #endif
1851 } else 1821 } else
1852 #endif /* EXTERNAL_WIDGET */ 1822 #endif /* EXTERNAL_WIDGET */
1853 FRAME_X_TOP_LEVEL_FRAME_P (f) = 1; 1823 FRAME_X_TOP_LEVEL_FRAME_P (f) = 1;
1854 1824
1855 ac = 0; 1825 ac = 0;
1856 XtSetArg (al[ac], XtNallowShellResize, True); ac++; 1826 Xt_SET_ARG (al[ac], XtNallowShellResize, True); ac++;
1857 #ifdef LWLIB_USES_MOTIF 1827 #ifdef LWLIB_USES_MOTIF
1858 /* Motif sucks beans. Without this in here, it will delete the window 1828 /* Motif sucks beans. Without this in here, it will delete the window
1859 out from under us when it receives a WM_DESTROY_WINDOW message 1829 out from under us when it receives a WM_DESTROY_WINDOW message
1860 from the WM. */ 1830 from the WM. */
1861 XtSetArg (al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++; 1831 Xt_SET_ARG (al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
1862 #endif 1832 #endif
1863 1833
1864 #ifdef EXTERNAL_WIDGET 1834 #ifdef EXTERNAL_WIDGET
1865 if (window_id) 1835 if (window_id)
1866 { 1836 {
1867 XtSetArg (al[ac], XtNwindow, window_id); ac++; 1837 Xt_SET_ARG (al[ac], XtNwindow, window_id); ac++;
1868 } 1838 }
1869 else 1839 else
1870 #endif /* EXTERNAL_WIDGET */ 1840 #endif /* EXTERNAL_WIDGET */
1871 { 1841 {
1872 XtSetArg (al[ac], XtNinput, True); ac++; 1842 Xt_SET_ARG (al[ac], XtNinput, True); ac++;
1873 XtSetArg (al[ac], XtNminWidthCells, 10); ac++; 1843 Xt_SET_ARG (al[ac], XtNminWidthCells, 10); ac++;
1874 XtSetArg (al[ac], XtNminHeightCells, 1); ac++; 1844 Xt_SET_ARG (al[ac], XtNminHeightCells, 1); ac++;
1875 XtSetArg (al[ac], XtNvisual, visual); ac++; 1845 Xt_SET_ARG (al[ac], XtNvisual, visual); ac++;
1876 XtSetArg (al[ac], XtNdepth, depth); ac++; 1846 Xt_SET_ARG (al[ac], XtNdepth, depth); ac++;
1877 XtSetArg (al[ac], XtNcolormap, cmap); ac++; 1847 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++;
1878 } 1848 }
1879 1849
1880 if (!NILP (overridep)) 1850 if (!NILP (overridep))
1881 { 1851 {
1882 XtSetArg (al[ac], XtNoverrideRedirect, True); ac++; 1852 Xt_SET_ARG (al[ac], XtNoverrideRedirect, True); ac++;
1883 } 1853 }
1884 1854
1885 /* #### maybe we should check for FRAMEP instead? */ 1855 /* #### maybe we should check for FRAMEP instead? */
1886 if (!NILP (parent)) 1856 if (!NILP (parent))
1887 { 1857 {
1888 parentwid = FRAME_X_SHELL_WIDGET (XFRAME (parent)); 1858 parentwid = FRAME_X_SHELL_WIDGET (XFRAME (parent));
1889 XtSetArg (al[ac], XtNtransientFor, parentwid); ac++; 1859 Xt_SET_ARG (al[ac], XtNtransientFor, parentwid); ac++;
1890 } 1860 }
1891 1861
1892 shell = XtCreatePopupShell ("shell", 1862 shell = XtCreatePopupShell ("shell",
1893 ( 1863 (
1894 #ifdef EXTERNAL_WIDGET 1864 #ifdef EXTERNAL_WIDGET
1903 FRAME_X_SHELL_WIDGET (f) = shell; 1873 FRAME_X_SHELL_WIDGET (f) = shell;
1904 maybe_set_frame_title_format (shell); 1874 maybe_set_frame_title_format (shell);
1905 1875
1906 /* Create the manager widget */ 1876 /* Create the manager widget */
1907 ac = 0; 1877 ac = 0;
1908 XtSetArg (al[ac], XtNvisual, visual); ac++; 1878 Xt_SET_ARG (al[ac], XtNvisual, visual); ac++;
1909 XtSetArg (al[ac], XtNdepth, depth); ac++; 1879 Xt_SET_ARG (al[ac], XtNdepth, depth); ac++;
1910 XtSetArg (al[ac], XtNcolormap, cmap); ac++; 1880 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++;
1911 1881
1912 container = XtCreateWidget ("container", 1882 container = XtCreateWidget ("container",
1913 emacsManagerWidgetClass, shell, al, ac); 1883 emacsManagerWidgetClass, shell, al, ac);
1914 FRAME_X_CONTAINER_WIDGET (f) = container; 1884 FRAME_X_CONTAINER_WIDGET (f) = container;
1915 XtAddCallback (container, XtNresizeCallback, x_layout_widgets, 1885 XtAddCallback (container, XtNresizeCallback, x_layout_widgets,
1917 XtAddCallback (container, XtNqueryGeometryCallback, x_do_query_geometry, 1887 XtAddCallback (container, XtNqueryGeometryCallback, x_do_query_geometry,
1918 (XtPointer) f); 1888 (XtPointer) f);
1919 1889
1920 /* Create the text area */ 1890 /* Create the text area */
1921 ac = 0; 1891 ac = 0;
1922 XtSetArg (al[ac], XtNvisual, visual); ac++; 1892 Xt_SET_ARG (al[ac], XtNvisual, visual); ac++;
1923 XtSetArg (al[ac], XtNdepth, depth); ac++; 1893 Xt_SET_ARG (al[ac], XtNdepth, depth); ac++;
1924 XtSetArg (al[ac], XtNcolormap, cmap); ac++; 1894 Xt_SET_ARG (al[ac], XtNcolormap, cmap); ac++;
1925 XtSetArg (al[ac], XtNborderWidth, 0); ac++; /* should this be settable? */ 1895 Xt_SET_ARG (al[ac], XtNborderWidth, 0); ac++; /* should this be settable? */
1926 XtSetArg (al[ac], XtNemacsFrame, f); ac++; 1896 Xt_SET_ARG (al[ac], XtNemacsFrame, f); ac++;
1927 text = XtCreateWidget (name, emacsFrameClass, container, al, ac); 1897 text = XtCreateWidget (name, emacsFrameClass, container, al, ac);
1928 FRAME_X_TEXT_WIDGET (f) = text; 1898 FRAME_X_TEXT_WIDGET (f) = text;
1929 1899
1930 #ifdef HAVE_MENUBARS 1900 #ifdef HAVE_MENUBARS
1931 /* Create the initial menubar widget. */ 1901 /* Create the initial menubar widget. */
2026 1996
2027 #ifdef HAVE_XIM 1997 #ifdef HAVE_XIM
2028 XIM_init_frame (f); 1998 XIM_init_frame (f);
2029 #endif /* HAVE_XIM */ 1999 #endif /* HAVE_XIM */
2030 2000
2031 #ifdef HACK_EDITRES
2032 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */ 2001 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */
2033 /* Intrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */ 2002 /* Intrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */
2034 /* pp. 483-493. */ 2003 /* pp. 483-493. */
2035 XtAddEventHandler (shell_widget, /* the shell widget in question */ 2004 XtAddEventHandler (shell_widget, /* the shell widget in question */
2036 (EventMask) NoEventMask,/* OR with existing mask */ 2005 (EventMask) NoEventMask,/* OR with existing mask */
2037 True, /* called on non-maskable events? */ 2006 True, /* called on non-maskable events? */
2038 (XtEventHandler) _XEditResCheckMessages, /* the handler */ 2007 (XtEventHandler) _XEditResCheckMessages, /* the handler */
2039 NULL); 2008 NULL);
2040 #endif /* HACK_EDITRES */
2041 2009
2042 #ifdef HAVE_CDE 2010 #ifdef HAVE_CDE
2043 { 2011 {
2044 XtCallbackRec dnd_transfer_cb_rec[2]; 2012 XtCallbackRec dnd_transfer_cb_rec[2];
2045 2013
2071 2039
2072 static void 2040 static void
2073 allocate_x_frame_struct (struct frame *f) 2041 allocate_x_frame_struct (struct frame *f)
2074 { 2042 {
2075 /* zero out all slots. */ 2043 /* zero out all slots. */
2044 #ifdef NEW_GC
2045 f->frame_data = alloc_lrecord_type (struct x_frame, &lrecord_x_frame);
2046 #else /* not NEW_GC */
2076 f->frame_data = xnew_and_zero (struct x_frame); 2047 f->frame_data = xnew_and_zero (struct x_frame);
2048 #endif /* not NEW_GC */
2077 2049
2078 /* yeah, except the lisp ones */ 2050 /* yeah, except the lisp ones */
2079 FRAME_X_LAST_MENUBAR_BUFFER (f) = Qnil; 2051 FRAME_X_LAST_MENUBAR_BUFFER (f) = Qnil;
2080 FRAME_X_ICON_PIXMAP (f) = Qnil; 2052 FRAME_X_ICON_PIXMAP (f) = Qnil;
2081 FRAME_X_ICON_PIXMAP_MASK (f) = Qnil; 2053 FRAME_X_ICON_PIXMAP_MASK (f) = Qnil;
2138 * JV: 2110 * JV:
2139 * It turns out it gives problems with FVWMs name based mapping. 2111 * It turns out it gives problems with FVWMs name based mapping.
2140 * We'll just need to be careful in the modeline specs. 2112 * We'll just need to be careful in the modeline specs.
2141 */ 2113 */
2142 update_frame_title (f); 2114 update_frame_title (f);
2115 /* Henry S. Thompson:
2116 * Must set icon resource before mapping frame, or some WMs may
2117 * lose the icon (openbox). See <f5bhc3efb17@hildegard.inf.ed.ac.uk>.
2118 * SJT:
2119 * This probably means that the frame-icon library won't work with
2120 * that WM. Late breaking news: it *does* work, so possibly the
2121 * problem at initialization is due to a race condition.
2122 */
2123 update_frame_icon (f);
2143 } 2124 }
2144 2125
2145 static void 2126 static void
2146 x_init_frame_3 (struct frame *f) 2127 x_init_frame_3 (struct frame *f)
2147 { 2128 {
2176 } 2157 }
2177 2158
2178 /* Store the X data into the widget. */ 2159 /* Store the X data into the widget. */
2179 { 2160 {
2180 Arg al[2]; 2161 Arg al[2];
2181 XtSetArg (al[0], XtNiconPixmap, x_pixmap); 2162 Xt_SET_ARG (al[0], XtNiconPixmap, x_pixmap);
2182 XtSetArg (al[1], XtNiconMask, x_mask); 2163 Xt_SET_ARG (al[1], XtNiconMask, x_mask);
2183 XtSetValues (FRAME_X_SHELL_WIDGET (f), al, 2); 2164 XtSetValues (FRAME_X_SHELL_WIDGET (f), al, 2);
2184 } 2165 }
2185 } 2166 }
2186 2167
2187 static void 2168 static void
2242 Dimension frame_h = DisplayHeight (dpy, DefaultScreen (dpy)); 2223 Dimension frame_h = DisplayHeight (dpy, DefaultScreen (dpy));
2243 Dimension shell_w, shell_h, shell_bord; 2224 Dimension shell_w, shell_h, shell_bord;
2244 int win_gravity; 2225 int win_gravity;
2245 Arg al[3]; 2226 Arg al[3];
2246 2227
2247 XtSetArg (al[0], XtNwidth, &shell_w); 2228 Xt_SET_ARG (al[0], XtNwidth, &shell_w);
2248 XtSetArg (al[1], XtNheight, &shell_h); 2229 Xt_SET_ARG (al[1], XtNheight, &shell_h);
2249 XtSetArg (al[2], XtNborderWidth, &shell_bord); 2230 Xt_SET_ARG (al[2], XtNborderWidth, &shell_bord);
2250 XtGetValues (w, al, 3); 2231 XtGetValues (w, al, 3);
2251 2232
2252 win_gravity = 2233 win_gravity =
2253 xoff >= 0 && yoff >= 0 ? NorthWestGravity : 2234 xoff >= 0 && yoff >= 0 ? NorthWestGravity :
2254 xoff >= 0 ? SouthWestGravity : 2235 xoff >= 0 ? SouthWestGravity :
2261 2242
2262 /* Update the hints so that, if this window is currently iconified, it will 2243 /* Update the hints so that, if this window is currently iconified, it will
2263 come back at the right place. We can't look at s->visible to determine 2244 come back at the right place. We can't look at s->visible to determine
2264 whether it is iconified because it might not be up-to-date yet (the queue 2245 whether it is iconified because it might not be up-to-date yet (the queue
2265 might not be processed). */ 2246 might not be processed). */
2266 XtSetArg (al[0], XtNwinGravity, win_gravity); 2247 Xt_SET_ARG (al[0], XtNwinGravity, win_gravity);
2267 XtSetArg (al[1], XtNx, xoff); 2248 Xt_SET_ARG (al[1], XtNx, xoff);
2268 XtSetArg (al[2], XtNy, yoff); 2249 Xt_SET_ARG (al[2], XtNy, yoff);
2269 XtSetValues (w, al, 3); 2250 XtSetValues (w, al, 3);
2270 2251
2271 /* Sometimes you will find that 2252 /* Sometimes you will find that
2272 2253
2273 (set-frame-position (selected-frame) -50 -50) 2254 (set-frame-position (selected-frame) -50 -50)
2293 2274
2294 static void 2275 static void
2295 x_set_frame_size (struct frame *f, int cols, int rows) 2276 x_set_frame_size (struct frame *f, int cols, int rows)
2296 { 2277 {
2297 EmacsFrameSetCharSize (FRAME_X_TEXT_WIDGET (f), cols, rows); 2278 EmacsFrameSetCharSize (FRAME_X_TEXT_WIDGET (f), cols, rows);
2279
2280 if (!wedge_metacity) /* cf. EmacsFrameResize */
2281 {
2282 /* Kick the manager so that it knows we've changed size. */
2283 XtWidgetGeometry req, repl;
2284 req.request_mode = 0;
2285 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
2286 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f),
2287 repl.width, repl.height);
2288 }
2289
2298 #if 0 2290 #if 0
2299 /* this is not correct. x_set_frame_size() is called from 2291 /* this is not correct. x_set_frame_size() is called from
2300 Fset_frame_size(), which may or may not have been called 2292 Fset_frame_size(), which may or may not have been called
2301 by the user (e.g. update_EmacsFrame() calls it when the font 2293 by the user (e.g. update_EmacsFrame() calls it when the font
2302 changes). For now, don't bother with getting this right. */ 2294 changes). For now, don't bother with getting this right. */
2587 if (focus != PointerRoot) 2579 if (focus != PointerRoot)
2588 { 2580 {
2589 XSetInputFocus (XtDisplay (shell_widget), 2581 XSetInputFocus (XtDisplay (shell_widget),
2590 XtWindow (shell_widget), 2582 XtWindow (shell_widget),
2591 RevertToParent, 2583 RevertToParent,
2592 DEVICE_X_MOUSE_TIMESTAMP 2584 CurrentTime);
2593 (XDEVICE (FRAME_DEVICE (f))));
2594 XFlush (XtDisplay (shell_widget)); 2585 XFlush (XtDisplay (shell_widget));
2595 } 2586 }
2596 } 2587 }
2597 XUngrabServer (XtDisplay (shell_widget)); 2588 XUngrabServer (XtDisplay (shell_widget));
2598 XFlush (XtDisplay (shell_widget)); /* hey, I'd like to DEBUG this... */ 2589 XFlush (XtDisplay (shell_widget)); /* hey, I'd like to DEBUG this... */
2610 #endif /* HAVE_WMCOMMAND */ 2601 #endif /* HAVE_WMCOMMAND */
2611 2602
2612 #ifdef HAVE_CDE 2603 #ifdef HAVE_CDE
2613 DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f)); 2604 DtDndDropUnregister (FRAME_X_TEXT_WIDGET (f));
2614 #endif /* HAVE_CDE */ 2605 #endif /* HAVE_CDE */
2606
2607 #ifdef USE_XFT
2608 /* If we have an XftDraw structure, we need to free it here.
2609 We can't ever have an XftDraw without a Display, so we are safe
2610 to free it in here, and we avoid too much playing around with the
2611 malloc checking hooks this way. */
2612 if (FRAME_X_XFTDRAW (f))
2613 {
2614 XftDrawDestroy (FRAME_X_XFTDRAW (f));
2615 FRAME_X_XFTDRAW (f) = NULL;
2616 }
2617 #endif
2618
2615 2619
2616 assert (FRAME_X_SHELL_WIDGET (f) != 0); 2620 assert (FRAME_X_SHELL_WIDGET (f) != 0);
2617 dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f)); 2621 dpy = XtDisplay (FRAME_X_SHELL_WIDGET (f));
2618 2622
2619 #ifdef EXTERNAL_WIDGET 2623 #ifdef EXTERNAL_WIDGET
2640 FRAME_X_GEOM_FREE_ME_PLEASE (f) = 0; 2644 FRAME_X_GEOM_FREE_ME_PLEASE (f) = 0;
2641 } 2645 }
2642 2646
2643 if (f->frame_data) 2647 if (f->frame_data)
2644 { 2648 {
2649 #ifndef NEW_GC
2645 xfree (f->frame_data, void *); 2650 xfree (f->frame_data, void *);
2651 #endif /* not NEW_GC */
2646 f->frame_data = 0; 2652 f->frame_data = 0;
2647 } 2653 }
2648 } 2654 }
2649 2655
2650 static void 2656 static void
2661 XColor fgc; 2667 XColor fgc;
2662 2668
2663 if (!EQ (color, Vthe_null_color_instance)) 2669 if (!EQ (color, Vthe_null_color_instance))
2664 { 2670 {
2665 fgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)); 2671 fgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color));
2666 XtSetArg (al[ac], XtNforeground, (void *) fgc.pixel); ac++; 2672 Xt_SET_ARG (al[ac], XtNforeground, (void *) fgc.pixel); ac++;
2667 } 2673 }
2668 } 2674 }
2669 else if (EQ (name, Qbackground)) 2675 else if (EQ (name, Qbackground))
2670 { 2676 {
2671 Lisp_Object color = FACE_BACKGROUND (Vdefault_face, frame); 2677 Lisp_Object color = FACE_BACKGROUND (Vdefault_face, frame);
2672 XColor bgc; 2678 XColor bgc;
2673 2679
2674 if (!EQ (color, Vthe_null_color_instance)) 2680 if (!EQ (color, Vthe_null_color_instance))
2675 { 2681 {
2676 bgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color)); 2682 bgc = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (color));
2677 XtSetArg (al[ac], XtNbackground, (void *) bgc.pixel); ac++; 2683 Xt_SET_ARG (al[ac], XtNbackground, (void *) bgc.pixel); ac++;
2678 } 2684 }
2679 2685
2680 /* Really crappy way to force the modeline shadows to be 2686 /* Really crappy way to force the modeline shadows to be
2681 redrawn. But effective. */ 2687 redrawn. But effective. */
2682 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (frm); 2688 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (frm);
2684 } 2690 }
2685 else if (EQ (name, Qfont)) 2691 else if (EQ (name, Qfont))
2686 { 2692 {
2687 Lisp_Object font = FACE_FONT (Vdefault_face, frame, Vcharset_ascii); 2693 Lisp_Object font = FACE_FONT (Vdefault_face, frame, Vcharset_ascii);
2688 2694
2695 /* It may be that instantiating the font has deleted the frame (will
2696 happen if the user has specified a charset registry for ASCII that
2697 isn't available on the server, and our fallback of iso8859-1 isn't
2698 available; something vanishingly rare.) In that case, return from
2699 this function without further manipulation of the dead frame. */
2700
2701 if (!FRAME_LIVE_P(frm))
2702 {
2703 return;
2704 }
2705
2706 /* #### what to do about Xft? I don't think the font is actually used
2707 to compute cell size for computing frame pixel dimensions (see call
2708 to EmacsFrameRecomputeCellSize() below); where is it used? -- sjt
2709 What does XtSetValues() do if that resource isn't present? */
2689 if (!EQ (font, Vthe_null_font_instance)) 2710 if (!EQ (font, Vthe_null_font_instance))
2690 { 2711 {
2691 XtSetArg (al[ac], XtNfont, 2712 if (0)
2692 (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font))); 2713 ;
2693 ac++; 2714 #ifdef USE_XFT
2715 else if (FONT_INSTANCE_X_XFTFONT (XFONT_INSTANCE (font)))
2716 {
2717 Xt_SET_ARG (al[ac], XtNxftFont,
2718 (void *) FONT_INSTANCE_X_XFTFONT (XFONT_INSTANCE (font)));
2719 ac++;
2720 }
2721 #endif
2722 else if (FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)))
2723 {
2724 Xt_SET_ARG (al[ac], XtNfont,
2725 (void *) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)));
2726 ac++;
2727 }
2694 } 2728 }
2695 } 2729 }
2696 else 2730 else
2697 ABORT (); 2731 ABORT ();
2698 2732
2718 /************************************************************************/ 2752 /************************************************************************/
2719 2753
2720 void 2754 void
2721 syms_of_frame_x (void) 2755 syms_of_frame_x (void)
2722 { 2756 {
2757 #ifdef NEW_GC
2758 INIT_LISP_OBJECT (x_frame);
2759 #endif /* NEW_GC */
2760
2723 DEFSYMBOL (Qoverride_redirect); 2761 DEFSYMBOL (Qoverride_redirect);
2724 DEFSYMBOL (Qx_resource_name); 2762 DEFSYMBOL (Qx_resource_name);
2725 2763
2726 DEFSUBR (Fx_window_id); 2764 DEFSUBR (Fx_window_id);
2727 #ifdef HAVE_CDE 2765 #ifdef HAVE_CDE
2728 DEFSUBR (Fcde_start_drag_internal); 2766 DEFSUBR (Fcde_start_drag_internal);
2729 #endif
2730 #ifdef HAVE_OFFIX_DND
2731 DEFSUBR (Foffix_start_drag_internal);
2732 #endif 2767 #endif
2733 } 2768 }
2734 2769
2735 void 2770 void
2736 console_type_create_frame_x (void) 2771 console_type_create_frame_x (void)