Mercurial > emacs
comparison src/xfns.c @ 5671:5c597b8fbabe
Find lwlib.h in ../lwlib.
(store_class_hints): Function deleted.
(Fx_create_frame): Bind x-resource-name to explicit title.
(Qx_resource_name): Declared.
(syms_of_xfns): Set up Qx_resource_name.
(x_window): Fix error message.
(x_any_window_to_frame): New function.
(x_window_to_frame, x_window): Handle USE_X_TOOLKIT.
(x_set_icon_type, x_set_menu_bar_lines, x_set_name): Likewise.
(store_class_hints, hack_wm_protocols): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 26 Jan 1994 05:19:51 +0000 |
parents | 42ec75481b8b |
children | 60dec959cbc2 |
comparison
equal
deleted
inserted
replaced
5670:1c506424bb84 | 5671:5c597b8fbabe |
---|---|
45 #include <X11/bitmaps/gray> | 45 #include <X11/bitmaps/gray> |
46 #endif | 46 #endif |
47 #else | 47 #else |
48 #include "[.bitmaps]gray.xbm" | 48 #include "[.bitmaps]gray.xbm" |
49 #endif | 49 #endif |
50 | |
51 #ifdef USE_X_TOOLKIT | |
52 #include <X11/Shell.h> | |
53 | |
54 #include <X11/Xaw/Paned.h> | |
55 #include <X11/Xaw/Label.h> | |
56 | |
57 #ifdef USG | |
58 #undef USG /* ####KLUDGE for Solaris 2.2 and up */ | |
59 #include <X11/Xos.h> | |
60 #define USG | |
61 #else | |
62 #include <X11/Xos.h> | |
63 #endif | |
64 | |
65 #include "widget.h" | |
66 | |
67 #include "../lwlib/lwlib.h" | |
68 | |
69 /* The one and only application context associated with the connection | |
70 to the one and only X display that Emacs uses. */ | |
71 XtAppContext Xt_app_con; | |
72 | |
73 /* The one and only application shell. Emacs screens are popup shells of this | |
74 application. */ | |
75 Widget Xt_app_shell; | |
76 | |
77 #endif /* USE_X_TOOLKIT */ | |
50 | 78 |
51 #define min(a,b) ((a) < (b) ? (a) : (b)) | 79 #define min(a,b) ((a) < (b) ? (a) : (b)) |
52 #define max(a,b) ((a) > (b) ? (a) : (b)) | 80 #define max(a,b) ((a) > (b) ? (a) : (b)) |
53 | 81 |
54 #ifdef HAVE_X11 | 82 #ifdef HAVE_X11 |
193 Lisp_Object Qundefined_color; | 221 Lisp_Object Qundefined_color; |
194 Lisp_Object Qvertical_scroll_bars; | 222 Lisp_Object Qvertical_scroll_bars; |
195 Lisp_Object Qvisibility; | 223 Lisp_Object Qvisibility; |
196 Lisp_Object Qwindow_id; | 224 Lisp_Object Qwindow_id; |
197 Lisp_Object Qx_frame_parameter; | 225 Lisp_Object Qx_frame_parameter; |
226 Lisp_Object Qx_resource_name; | |
198 | 227 |
199 /* The below are defined in frame.c. */ | 228 /* The below are defined in frame.c. */ |
200 extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth; | 229 extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth; |
201 extern Lisp_Object Qunsplittable, Qmenu_bar_lines; | 230 extern Lisp_Object Qunsplittable, Qmenu_bar_lines; |
202 | 231 |
228 { | 257 { |
229 frame = XCONS (tail)->car; | 258 frame = XCONS (tail)->car; |
230 if (XGCTYPE (frame) != Lisp_Frame) | 259 if (XGCTYPE (frame) != Lisp_Frame) |
231 continue; | 260 continue; |
232 f = XFRAME (frame); | 261 f = XFRAME (frame); |
262 #ifdef USE_X_TOOLKIT | |
263 if (f->display.nothing == 1) | |
264 return 0; | |
265 if (f->display.x->edit_widget | |
266 && XtWindow (f->display.x->edit_widget) == wdesc | |
267 || f->display.x->icon_desc == wdesc) | |
268 return f; | |
269 #else /* not USE_X_TOOLKIT */ | |
233 if (FRAME_X_WINDOW (f) == wdesc | 270 if (FRAME_X_WINDOW (f) == wdesc |
234 || f->display.x->icon_desc == wdesc) | 271 || f->display.x->icon_desc == wdesc) |
235 return f; | 272 return f; |
273 #endif /* not USE_X_TOOLKIT */ | |
236 } | 274 } |
237 return 0; | 275 return 0; |
238 } | 276 } |
277 | |
278 #ifdef USE_X_TOOLKIT | |
279 /* Like x_window_to_frame but also compares the window with the widget's | |
280 windows. */ | |
281 | |
282 struct frame * | |
283 x_any_window_to_frame (wdesc) | |
284 int wdesc; | |
285 { | |
286 Lisp_Object tail, frame; | |
287 struct frame *f; | |
288 struct x_display *x; | |
289 | |
290 for (tail = Vframe_list; XGCTYPE (tail) == Lisp_Cons; | |
291 tail = XCONS (tail)->cdr) | |
292 { | |
293 frame = XCONS (tail)->car; | |
294 if (XGCTYPE (frame) != Lisp_Frame) | |
295 continue; | |
296 f = XFRAME (frame); | |
297 if (f->display.nothing == 1) | |
298 return 0; | |
299 x = f->display.x; | |
300 /* This frame matches if the window is any of its widgets. */ | |
301 if (wdesc == XtWindow (x->widget) | |
302 || wdesc == XtWindow (x->column_widget) | |
303 || wdesc == XtWindow (x->edit_widget)) | |
304 return f; | |
305 /* Match if the window is this frame's menubar. */ | |
306 if (x->menubar_widget | |
307 && wdesc == XtWindow (x->menubar_widget)) | |
308 return f; | |
309 } | |
310 return 0; | |
311 } | |
312 #endif /* USE_X_TOOLKIT */ | |
239 | 313 |
240 | 314 |
241 /* Connect the frame-parameter names for X frames | 315 /* Connect the frame-parameter names for X frames |
242 to the ways of passing the parameter values to the window system. | 316 to the ways of passing the parameter values to the window system. |
243 | 317 |
854 } | 928 } |
855 | 929 |
856 /* If the window was unmapped (and its icon was mapped), | 930 /* If the window was unmapped (and its icon was mapped), |
857 the new icon is not mapped, so map the window in its stead. */ | 931 the new icon is not mapped, so map the window in its stead. */ |
858 if (FRAME_VISIBLE_P (f)) | 932 if (FRAME_VISIBLE_P (f)) |
933 #ifdef USE_X_TOOLKIT | |
934 XtPopup (f->display.x->widget, XtGrabNone); | |
935 #endif | |
859 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); | 936 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); |
860 | 937 |
861 XFlushQueue (); | 938 XFlushQueue (); |
862 UNBLOCK_INPUT; | 939 UNBLOCK_INPUT; |
863 } | 940 } |
991 if (XTYPE (value) == Lisp_Int) | 1068 if (XTYPE (value) == Lisp_Int) |
992 nlines = XINT (value); | 1069 nlines = XINT (value); |
993 else | 1070 else |
994 nlines = 0; | 1071 nlines = 0; |
995 | 1072 |
1073 #ifdef USE_X_TOOLKIT | |
1074 FRAME_MENU_BAR_LINES (f) = 0; | |
1075 if (nlines) | |
1076 FRAME_EXTERNAL_MENU_BAR (f) = 1; | |
1077 else | |
1078 { | |
1079 if (FRAME_EXTERNAL_MENU_BAR (f) == 1) | |
1080 XtDestroyWidget (f->display.x->menubar_widget); | |
1081 FRAME_EXTERNAL_MENU_BAR (f) = 0; | |
1082 f->display.x->menubar_widget = 0; | |
1083 } | |
1084 #else /* not USE_X_TOOLKIT */ | |
996 FRAME_MENU_BAR_LINES (f) = nlines; | 1085 FRAME_MENU_BAR_LINES (f) = nlines; |
997 x_set_menu_bar_lines_1 (f->root_window, nlines - olines); | 1086 x_set_menu_bar_lines_1 (f->root_window, nlines - olines); |
1087 #endif /* not USE_X_TOOLKIT */ | |
998 } | 1088 } |
999 | 1089 |
1000 /* Change the name of frame F to NAME. If NAME is nil, set F's name to | 1090 /* Change the name of frame F to NAME. If NAME is nil, set F's name to |
1001 x_id_name. | 1091 x_id_name. |
1002 | 1092 |
1039 return; | 1129 return; |
1040 | 1130 |
1041 if (FRAME_X_WINDOW (f)) | 1131 if (FRAME_X_WINDOW (f)) |
1042 { | 1132 { |
1043 BLOCK_INPUT; | 1133 BLOCK_INPUT; |
1044 | |
1045 #ifdef HAVE_X11R4 | 1134 #ifdef HAVE_X11R4 |
1046 { | 1135 { |
1047 XTextProperty text; | 1136 XTextProperty text; |
1048 text.value = XSTRING (name)->data; | 1137 text.value = XSTRING (name)->data; |
1049 text.encoding = XA_STRING; | 1138 text.encoding = XA_STRING; |
1050 text.format = 8; | 1139 text.format = 8; |
1051 text.nitems = XSTRING (name)->size; | 1140 text.nitems = XSTRING (name)->size; |
1141 #ifdef USE_X_TOOLKIT | |
1142 XSetWMName (x_current_display, XtWindow (f->display.x->widget), &text); | |
1143 XSetWMIconName (x_current_display, XtWindow (f->display.x->widget), | |
1144 &text); | |
1145 #else /* not USE_X_TOOLKIT */ | |
1052 XSetWMName (x_current_display, FRAME_X_WINDOW (f), &text); | 1146 XSetWMName (x_current_display, FRAME_X_WINDOW (f), &text); |
1053 XSetWMIconName (x_current_display, FRAME_X_WINDOW (f), &text); | 1147 XSetWMIconName (x_current_display, FRAME_X_WINDOW (f), &text); |
1148 #endif /* not USE_X_TOOLKIT */ | |
1054 } | 1149 } |
1055 #else | 1150 #else /* not HAVE_X11R4 */ |
1056 XSetIconName (XDISPLAY FRAME_X_WINDOW (f), | 1151 XSetIconName (XDISPLAY FRAME_X_WINDOW (f), |
1057 XSTRING (name)->data); | 1152 XSTRING (name)->data); |
1058 XStoreName (XDISPLAY FRAME_X_WINDOW (f), | 1153 XStoreName (XDISPLAY FRAME_X_WINDOW (f), |
1059 XSTRING (name)->data); | 1154 XSTRING (name)->data); |
1060 #endif | 1155 #endif /* not HAVE_X11R4 */ |
1061 | |
1062 UNBLOCK_INPUT; | 1156 UNBLOCK_INPUT; |
1063 } | 1157 } |
1064 | 1158 |
1065 f->name = name; | 1159 f->name = name; |
1066 } | 1160 } |
1151 Lisp_Object attribute, class, component, subclass; | 1245 Lisp_Object attribute, class, component, subclass; |
1152 { | 1246 { |
1153 register char *value; | 1247 register char *value; |
1154 char *name_key; | 1248 char *name_key; |
1155 char *class_key; | 1249 char *class_key; |
1250 Lisp_Object resname; | |
1156 | 1251 |
1157 check_x (); | 1252 check_x (); |
1158 | 1253 |
1159 CHECK_STRING (attribute, 0); | 1254 CHECK_STRING (attribute, 0); |
1160 CHECK_STRING (class, 0); | 1255 CHECK_STRING (class, 0); |
1165 CHECK_STRING (subclass, 2); | 1260 CHECK_STRING (subclass, 2); |
1166 if (NILP (component) != NILP (subclass)) | 1261 if (NILP (component) != NILP (subclass)) |
1167 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither"); | 1262 error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither"); |
1168 | 1263 |
1169 validate_x_resource_name (); | 1264 validate_x_resource_name (); |
1265 resname = Vx_resource_name; | |
1170 | 1266 |
1171 if (NILP (component)) | 1267 if (NILP (component)) |
1172 { | 1268 { |
1173 /* Allocate space for the components, the dots which separate them, | 1269 /* Allocate space for the components, the dots which separate them, |
1174 and the final '\0'. */ | 1270 and the final '\0'. */ |
1175 name_key = (char *) alloca (XSTRING (Vx_resource_name)->size | 1271 name_key = (char *) alloca (XSTRING (resname)->size |
1176 + XSTRING (attribute)->size | 1272 + XSTRING (attribute)->size |
1177 + 2); | 1273 + 2); |
1178 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | 1274 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) |
1179 + XSTRING (class)->size | 1275 + XSTRING (class)->size |
1180 + 2); | 1276 + 2); |
1181 | 1277 |
1182 sprintf (name_key, "%s.%s", | 1278 sprintf (name_key, "%s.%s", |
1183 XSTRING (Vx_resource_name)->data, | 1279 XSTRING (resname)->data, |
1184 XSTRING (attribute)->data); | 1280 XSTRING (attribute)->data); |
1185 sprintf (class_key, "%s.%s", | 1281 sprintf (class_key, "%s.%s", |
1186 EMACS_CLASS, | 1282 EMACS_CLASS, |
1187 XSTRING (class)->data); | 1283 XSTRING (class)->data); |
1188 } | 1284 } |
1189 else | 1285 else |
1190 { | 1286 { |
1191 name_key = (char *) alloca (XSTRING (Vx_resource_name)->size | 1287 name_key = (char *) alloca (XSTRING (resname)->size |
1192 + XSTRING (component)->size | 1288 + XSTRING (component)->size |
1193 + XSTRING (attribute)->size | 1289 + XSTRING (attribute)->size |
1194 + 3); | 1290 + 3); |
1195 | 1291 |
1196 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) | 1292 class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) |
1197 + XSTRING (class)->size | 1293 + XSTRING (class)->size |
1198 + XSTRING (subclass)->size | 1294 + XSTRING (subclass)->size |
1199 + 3); | 1295 + 3); |
1200 | 1296 |
1201 sprintf (name_key, "%s.%s.%s", | 1297 sprintf (name_key, "%s.%s.%s", |
1202 XSTRING (Vx_resource_name)->data, | 1298 XSTRING (resname)->data, |
1203 XSTRING (component)->data, | 1299 XSTRING (component)->data, |
1204 XSTRING (attribute)->data); | 1300 XSTRING (attribute)->data); |
1205 sprintf (class_key, "%s.%s.%s", | 1301 sprintf (class_key, "%s.%s.%s", |
1206 EMACS_CLASS, | 1302 EMACS_CLASS, |
1207 XSTRING (class)->data, | 1303 XSTRING (class)->data, |
1267 else | 1363 else |
1268 return (Qnil); | 1364 return (Qnil); |
1269 } | 1365 } |
1270 | 1366 |
1271 #define Fx_get_resource(attribute, class, component, subclass) \ | 1367 #define Fx_get_resource(attribute, class, component, subclass) \ |
1272 Fx_get_default(attribute) | 1368 Fx_get_default (attribute) |
1273 | 1369 |
1274 #endif /* X10 */ | 1370 #endif /* X10 */ |
1275 | 1371 |
1276 /* Types we might convert a resource string into. */ | 1372 /* Types we might convert a resource string into. */ |
1277 enum resource_types | 1373 enum resource_types |
1543 if (prop == None) return False; | 1639 if (prop == None) return False; |
1544 XChangeProperty (dpy, w, prop, XA_ATOM, 32, PropModeReplace, | 1640 XChangeProperty (dpy, w, prop, XA_ATOM, 32, PropModeReplace, |
1545 (unsigned char *) protocols, count); | 1641 (unsigned char *) protocols, count); |
1546 return True; | 1642 return True; |
1547 } | 1643 } |
1548 #endif /* !HAVE_X11R4 && !HAVE_XSETWMPROTOCOLS */ | 1644 #endif /* not HAVE_X11R4 && not HAVE_XSETWMPROTOCOLS */ |
1645 | |
1646 #ifdef USE_X_TOOLKIT | |
1647 | |
1648 /* If the WM_PROTOCOLS property does not already contain WM_TAKE_FOCUS | |
1649 and WM_DELETE_WINDOW, then add them. (They may already be present | |
1650 because of the toolkit (Motif adds them, for example, but Xt doesn't). */ | |
1651 | |
1652 static void | |
1653 hack_wm_protocols (widget) | |
1654 Widget widget; | |
1655 { | |
1656 Display *dpy = XtDisplay (widget); | |
1657 Window w = XtWindow (widget); | |
1658 int need_delete = 1; | |
1659 int need_focus = 1; | |
1660 | |
1661 BLOCK_INPUT; | |
1662 { | |
1663 Atom type, *atoms = 0; | |
1664 int format = 0; | |
1665 unsigned long nitems = 0; | |
1666 unsigned long bytes_after; | |
1667 | |
1668 if (Success == XGetWindowProperty (dpy, w, Xatom_wm_protocols, | |
1669 0, 100, False, XA_ATOM, | |
1670 &type, &format, &nitems, &bytes_after, | |
1671 (unsigned char **) &atoms) | |
1672 && format == 32 && type == XA_ATOM) | |
1673 while (nitems > 0) | |
1674 { | |
1675 nitems--; | |
1676 if (atoms [nitems] == Xatom_wm_delete_window) need_delete = 0; | |
1677 else if (atoms [nitems] == Xatom_wm_take_focus) need_focus = 0; | |
1678 } | |
1679 if (atoms) XFree ((char *) atoms); | |
1680 } | |
1681 { | |
1682 Atom props [10]; | |
1683 int count = 0; | |
1684 if (need_delete) props [count++] = Xatom_wm_delete_window; | |
1685 if (need_focus) props [count++] = Xatom_wm_take_focus; | |
1686 if (count) | |
1687 XChangeProperty (dpy, w, Xatom_wm_protocols, XA_ATOM, 32, PropModeAppend, | |
1688 (unsigned char *) props, count); | |
1689 } | |
1690 UNBLOCK_INPUT; | |
1691 } | |
1692 #endif | |
1693 | |
1694 /* Create and set up the X window or widget for frame F. */ | |
1549 | 1695 |
1550 static void | 1696 static void |
1551 x_window (f) | 1697 x_window (f) |
1552 struct frame *f; | 1698 struct frame *f; |
1553 { | 1699 { |
1700 XClassHint class_hints; | |
1701 | |
1702 #ifdef USE_X_TOOLKIT | |
1703 Widget shell_widget; | |
1704 Widget pane_widget; | |
1705 Widget screen_widget; | |
1706 char* name; | |
1707 Arg al [25]; | |
1708 int ac; | |
1709 | |
1710 BLOCK_INPUT; | |
1711 | |
1712 if (STRINGP (f->name)) | |
1713 name = (char*) XSTRING (f->name)->data; | |
1714 else | |
1715 name = "emacs"; | |
1716 | |
1717 ac = 0; | |
1718 XtSetArg (al[ac], XtNallowShellResize, 1); ac++; | |
1719 XtSetArg (al[ac], XtNinput, 1); ac++; | |
1720 XtSetArg (al[ac], XtNx, f->display.x->left_pos); ac++; | |
1721 XtSetArg (al[ac], XtNy, f->display.x->top_pos); ac++; | |
1722 shell_widget = XtCreatePopupShell ("shell", | |
1723 topLevelShellWidgetClass, | |
1724 Xt_app_shell, al, ac); | |
1725 | |
1726 /* maybe_set_screen_title_format (shell_widget); */ | |
1727 | |
1728 | |
1729 ac = 0; | |
1730 XtSetArg (al[ac], XtNborderWidth, 0); ac++; | |
1731 pane_widget = XtCreateWidget ("pane", | |
1732 panedWidgetClass, | |
1733 shell_widget, al, ac); | |
1734 | |
1735 /* mappedWhenManaged to false tells to the paned window to not map/unmap | |
1736 * the emacs screen when changing menubar. This reduces flickering a lot. | |
1737 */ | |
1738 | |
1739 ac = 0; | |
1740 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++; | |
1741 XtSetArg (al[ac], XtNshowGrip, 0); ac++; | |
1742 XtSetArg (al[ac], XtNallowResize, 1); ac++; | |
1743 XtSetArg (al[ac], XtNresizeToPreferred, 1); ac++; | |
1744 XtSetArg (al[ac], XtNemacsFrame, f); ac++; | |
1745 screen_widget = XtCreateWidget (name, | |
1746 emacsFrameClass, | |
1747 pane_widget, al, ac); | |
1748 | |
1749 f->display.x->edit_widget = screen_widget; | |
1750 f->display.x->widget = shell_widget; | |
1751 f->display.x->column_widget = pane_widget; | |
1752 | |
1753 XtManageChild (screen_widget); | |
1754 XtManageChild (pane_widget); | |
1755 XtRealizeWidget (shell_widget); | |
1756 | |
1757 FRAME_X_WINDOW (f) = XtWindow (screen_widget); | |
1758 | |
1759 validate_x_resource_name (); | |
1760 class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; | |
1761 class_hints.res_class = EMACS_CLASS; | |
1762 XSetClassHint (x_current_display, XtWindow (shell_widget), &class_hints); | |
1763 | |
1764 hack_wm_protocols (shell_widget); | |
1765 | |
1766 /* Do a stupid property change to force the server to generate a | |
1767 propertyNotify event so that the event_stream server timestamp will | |
1768 be initialized to something relevant to the time we created the window. | |
1769 */ | |
1770 XChangeProperty (XtDisplay (screen_widget), XtWindow (screen_widget), | |
1771 Xatom_wm_protocols, XA_ATOM, 32, PropModeAppend, | |
1772 (unsigned char*) NULL, 0); | |
1773 | |
1774 XtMapWidget (screen_widget); | |
1775 | |
1776 #else /* not USE_X_TOOLKIT */ | |
1777 | |
1554 XSetWindowAttributes attributes; | 1778 XSetWindowAttributes attributes; |
1555 unsigned long attribute_mask; | 1779 unsigned long attribute_mask; |
1556 XClassHint class_hints; | 1780 |
1557 | 1781 |
1558 attributes.background_pixel = f->display.x->background_pixel; | 1782 attributes.background_pixel = f->display.x->background_pixel; |
1559 attributes.border_pixel = f->display.x->border_pixel; | 1783 attributes.border_pixel = f->display.x->border_pixel; |
1560 attributes.bit_gravity = StaticGravity; | 1784 attributes.bit_gravity = StaticGravity; |
1561 attributes.backing_store = NotUseful; | 1785 attributes.backing_store = NotUseful; |
1593 f->display.x->wm_hints.flags |= InputHint; | 1817 f->display.x->wm_hints.flags |= InputHint; |
1594 XSetWMHints (x_current_display, FRAME_X_WINDOW (f), &f->display.x->wm_hints); | 1818 XSetWMHints (x_current_display, FRAME_X_WINDOW (f), &f->display.x->wm_hints); |
1595 XSetWMProtocols (x_current_display, FRAME_X_WINDOW (f), | 1819 XSetWMProtocols (x_current_display, FRAME_X_WINDOW (f), |
1596 &Xatom_wm_delete_window, 1); | 1820 &Xatom_wm_delete_window, 1); |
1597 | 1821 |
1822 #endif /* not USE_X_TOOLKIT */ | |
1823 | |
1598 /* x_set_name normally ignores requests to set the name if the | 1824 /* x_set_name normally ignores requests to set the name if the |
1599 requested name is the same as the current name. This is the one | 1825 requested name is the same as the current name. This is the one |
1600 place where that assumption isn't correct; f->name is set, but | 1826 place where that assumption isn't correct; f->name is set, but |
1601 the X server hasn't been told. */ | 1827 the X server hasn't been told. */ |
1602 { | 1828 { |
1608 x_set_name (f, name, explicit); | 1834 x_set_name (f, name, explicit); |
1609 } | 1835 } |
1610 | 1836 |
1611 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), | 1837 XDefineCursor (XDISPLAY FRAME_X_WINDOW (f), |
1612 f->display.x->text_cursor); | 1838 f->display.x->text_cursor); |
1839 | |
1613 UNBLOCK_INPUT; | 1840 UNBLOCK_INPUT; |
1614 | 1841 |
1615 if (FRAME_X_WINDOW (f) == 0) | 1842 if (FRAME_X_WINDOW (f) == 0) |
1616 error ("Unable to create window."); | 1843 error ("Unable to create window"); |
1617 } | 1844 } |
1618 | 1845 |
1619 /* Handle the icon stuff for this window. Perhaps later we might | 1846 /* Handle the icon stuff for this window. Perhaps later we might |
1620 want an x_set_icon_position which can be called interactively as | 1847 want an x_set_icon_position which can be called interactively as |
1621 well. */ | 1848 well. */ |
1674 XImage tileimage; | 1901 XImage tileimage; |
1675 | 1902 |
1676 BLOCK_INPUT; | 1903 BLOCK_INPUT; |
1677 | 1904 |
1678 /* Create the GC's of this frame. | 1905 /* Create the GC's of this frame. |
1679 Note that many default values are used. */ | 1906 Note that many default values are used. */ |
1680 | 1907 |
1681 /* Normal video */ | 1908 /* Normal video */ |
1682 gc_values.font = f->display.x->font->fid; | 1909 gc_values.font = f->display.x->font->fid; |
1683 gc_values.foreground = f->display.x->foreground_pixel; | 1910 gc_values.foreground = f->display.x->foreground_pixel; |
1684 gc_values.background = f->display.x->background_pixel; | 1911 gc_values.background = f->display.x->background_pixel; |
1685 gc_values.line_width = 0; /* Means 1 using fast algorithm. */ | 1912 gc_values.line_width = 0; /* Means 1 using fast algorithm. */ |
1686 f->display.x->normal_gc = XCreateGC (x_current_display, | 1913 f->display.x->normal_gc = XCreateGC (x_current_display, |
1687 FRAME_X_WINDOW (f), | 1914 FRAME_X_WINDOW (f), |
1688 GCLineWidth | GCFont | 1915 GCLineWidth | GCFont |
1689 | GCForeground | GCBackground, | 1916 | GCForeground | GCBackground, |
1690 &gc_values); | 1917 &gc_values); |
1696 FRAME_X_WINDOW (f), | 1923 FRAME_X_WINDOW (f), |
1697 GCFont | GCForeground | GCBackground | 1924 GCFont | GCForeground | GCBackground |
1698 | GCLineWidth, | 1925 | GCLineWidth, |
1699 &gc_values); | 1926 &gc_values); |
1700 | 1927 |
1701 /* Cursor has cursor-color background, background-color foreground. */ | 1928 /* Cursor has cursor-color background, background-color foreground. */ |
1702 gc_values.foreground = f->display.x->background_pixel; | 1929 gc_values.foreground = f->display.x->background_pixel; |
1703 gc_values.background = f->display.x->cursor_pixel; | 1930 gc_values.background = f->display.x->cursor_pixel; |
1704 gc_values.fill_style = FillOpaqueStippled; | 1931 gc_values.fill_style = FillOpaqueStippled; |
1705 gc_values.stipple | 1932 gc_values.stipple |
1706 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW, | 1933 = XCreateBitmapFromData (x_current_display, ROOT_WINDOW, |
1711 | GCFillStyle | GCStipple | GCLineWidth), | 1938 | GCFillStyle | GCStipple | GCLineWidth), |
1712 &gc_values); | 1939 &gc_values); |
1713 | 1940 |
1714 /* Create the gray border tile used when the pointer is not in | 1941 /* Create the gray border tile used when the pointer is not in |
1715 the frame. Since this depends on the frame's pixel values, | 1942 the frame. Since this depends on the frame's pixel values, |
1716 this must be done on a per-frame basis. */ | 1943 this must be done on a per-frame basis. */ |
1717 f->display.x->border_tile | 1944 f->display.x->border_tile |
1718 = (XCreatePixmapFromBitmapData | 1945 = (XCreatePixmapFromBitmapData |
1719 (x_current_display, ROOT_WINDOW, | 1946 (x_current_display, ROOT_WINDOW, |
1720 gray_bits, gray_width, gray_height, | 1947 gray_bits, gray_width, gray_height, |
1721 f->display.x->foreground_pixel, | 1948 f->display.x->foreground_pixel, |
1743 Lisp_Object frame, tem, tem0, tem1; | 1970 Lisp_Object frame, tem, tem0, tem1; |
1744 Lisp_Object name; | 1971 Lisp_Object name; |
1745 int minibuffer_only = 0; | 1972 int minibuffer_only = 0; |
1746 long window_prompting = 0; | 1973 long window_prompting = 0; |
1747 int width, height; | 1974 int width, height; |
1975 int count = specpdl_ptr - specpdl; | |
1748 | 1976 |
1749 check_x (); | 1977 check_x (); |
1750 | 1978 |
1751 name = x_get_arg (parms, Qname, "title", "Title", string); | 1979 name = x_get_arg (parms, Qname, "title", "Title", string); |
1752 if (XTYPE (name) != Lisp_String | 1980 if (XTYPE (name) != Lisp_String |
1779 } | 2007 } |
1780 else | 2008 else |
1781 { | 2009 { |
1782 f->name = name; | 2010 f->name = name; |
1783 f->explicit_name = 1; | 2011 f->explicit_name = 1; |
2012 /* use the frame's title when getting resources for this frame. */ | |
2013 specbind (Qx_resource_name, name); | |
1784 } | 2014 } |
1785 | 2015 |
1786 XSET (frame, Lisp_Frame, f); | 2016 XSET (frame, Lisp_Frame, f); |
1787 f->output_method = output_x_window; | 2017 f->output_method = output_x_window; |
1788 f->display.x = (struct x_display *) xmalloc (sizeof (struct x_display)); | 2018 f->display.x = (struct x_display *) xmalloc (sizeof (struct x_display)); |
1818 font = build_string ("fixed"); | 2048 font = build_string ("fixed"); |
1819 | 2049 |
1820 x_default_parameter (f, parms, Qfont, font, | 2050 x_default_parameter (f, parms, Qfont, font, |
1821 "font", "Font", string); | 2051 "font", "Font", string); |
1822 } | 2052 } |
2053 | |
1823 x_default_parameter (f, parms, Qborder_width, make_number (2), | 2054 x_default_parameter (f, parms, Qborder_width, make_number (2), |
1824 "borderwidth", "BorderWidth", number); | 2055 "borderwidth", "BorderWidth", number); |
1825 /* This defaults to 2 in order to match xterm. We recognize either | 2056 /* This defaults to 2 in order to match xterm. We recognize either |
1826 internalBorderWidth or internalBorder (which is what xterm calls | 2057 internalBorderWidth or internalBorder (which is what xterm calls |
1827 it). */ | 2058 it). */ |
1913 else | 2144 else |
1914 /* Must have been Qnil. */ | 2145 /* Must have been Qnil. */ |
1915 ; | 2146 ; |
1916 } | 2147 } |
1917 | 2148 |
1918 return frame; | 2149 return unbind_to (count, frame); |
1919 #else /* X10 */ | 2150 #else /* X10 */ |
1920 struct frame *f; | 2151 struct frame *f; |
1921 Lisp_Object frame, tem; | 2152 Lisp_Object frame, tem; |
1922 Lisp_Object name; | 2153 Lisp_Object name; |
1923 int pixelwidth, pixelheight; | 2154 int pixelwidth, pixelheight; |
2753 register int ibw = f->display.x->internal_border_width; | 2984 register int ibw = f->display.x->internal_border_width; |
2754 register int font_w = FONT_WIDTH (f->display.x->font); | 2985 register int font_w = FONT_WIDTH (f->display.x->font); |
2755 register int font_h = FONT_HEIGHT (f->display.x->font); | 2986 register int font_h = FONT_HEIGHT (f->display.x->font); |
2756 int y = top_y; | 2987 int y = top_y; |
2757 int x = line_len (y); | 2988 int x = line_len (y); |
2758 XPoint *pixel_points = (XPoint *) | 2989 XPoint *pixel_points |
2759 alloca (((bottom_y - top_y + 2) * 4) * sizeof (XPoint)); | 2990 = (XPoint *) alloca (((bottom_y - top_y + 2) * 4) * sizeof (XPoint)); |
2760 register XPoint *this_point = pixel_points; | 2991 register XPoint *this_point = pixel_points; |
2761 | 2992 |
2762 /* Do the horizontal top line/lines */ | 2993 /* Do the horizontal top line/lines */ |
2763 if (top_x == 0) | 2994 if (top_x == 0) |
2764 { | 2995 { |
3795 staticpro (&Qvisibility); | 4026 staticpro (&Qvisibility); |
3796 Qwindow_id = intern ("window-id"); | 4027 Qwindow_id = intern ("window-id"); |
3797 staticpro (&Qwindow_id); | 4028 staticpro (&Qwindow_id); |
3798 Qx_frame_parameter = intern ("x-frame-parameter"); | 4029 Qx_frame_parameter = intern ("x-frame-parameter"); |
3799 staticpro (&Qx_frame_parameter); | 4030 staticpro (&Qx_frame_parameter); |
4031 Qx_resource_name = intern ("x-resource-name"); | |
4032 staticpro (&Qx_resource_name); | |
3800 /* This is the end of symbol initialization. */ | 4033 /* This is the end of symbol initialization. */ |
3801 | 4034 |
3802 Fput (Qundefined_color, Qerror_conditions, | 4035 Fput (Qundefined_color, Qerror_conditions, |
3803 Fcons (Qundefined_color, Fcons (Qerror, Qnil))); | 4036 Fcons (Qundefined_color, Fcons (Qerror, Qnil))); |
3804 Fput (Qundefined_color, Qerror_message, | 4037 Fput (Qundefined_color, Qerror_message, |