Mercurial > hg > xemacs-beta
comparison src/device-x.c @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | 00793f182d30 |
children | e38acbeb1cae |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
1 /* Device functions for X windows. | 1 /* Device functions for X windows. |
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. | 3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
4 Copyright (C) 2001 Ben Wing. | |
4 | 5 |
5 This file is part of XEmacs. | 6 This file is part of XEmacs. |
6 | 7 |
7 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software; you can redistribute it and/or modify it |
8 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
59 #ifdef HAVE_OFFIX_DND | 60 #ifdef HAVE_OFFIX_DND |
60 #include "offix.h" | 61 #include "offix.h" |
61 #endif | 62 #endif |
62 | 63 |
63 Lisp_Object Vdefault_x_device; | 64 Lisp_Object Vdefault_x_device; |
64 #if defined(MULE) && (defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET)) | 65 #ifdef MULE |
65 Lisp_Object Vx_app_defaults_directory; | 66 Lisp_Object Vx_app_defaults_directory; |
67 Lisp_Object Qget_coding_system_from_locale; | |
66 #endif | 68 #endif |
67 | 69 |
68 /* Qdisplay in general.c */ | 70 /* Qdisplay in general.c */ |
69 Lisp_Object Qx_error; | 71 Lisp_Object Qx_error; |
70 Lisp_Object Qinit_pre_x_win, Qinit_post_x_win; | 72 Lisp_Object Qinit_pre_x_win, Qinit_post_x_win; |
161 get_x_display (Lisp_Object device) | 163 get_x_display (Lisp_Object device) |
162 { | 164 { |
163 return DEVICE_X_DISPLAY (decode_x_device (device)); | 165 return DEVICE_X_DISPLAY (decode_x_device (device)); |
164 } | 166 } |
165 | 167 |
168 static Lisp_Object | |
169 coding_system_of_xrm_database (XrmDatabase db) | |
170 { | |
171 #ifdef MULE | |
172 const Extbyte *locale = XrmLocaleOfDatabase (db); | |
173 Lisp_Object localestr = build_ext_string (locale, Qbinary); | |
174 return call1 (Qget_coding_system_from_locale, localestr); | |
175 #else | |
176 return Qbinary; | |
177 #endif | |
178 } | |
179 | |
166 | 180 |
167 /************************************************************************/ | 181 /************************************************************************/ |
168 /* initializing an X connection */ | 182 /* initializing an X connection */ |
169 /************************************************************************/ | 183 /************************************************************************/ |
170 | 184 |
189 } | 203 } |
190 | 204 |
191 static void | 205 static void |
192 sanity_check_geometry_resource (Display *dpy) | 206 sanity_check_geometry_resource (Display *dpy) |
193 { | 207 { |
194 char *app_name, *app_class, *s; | 208 Extbyte *app_name, *app_class, *s; |
195 char buf1 [255], buf2 [255]; | 209 Extbyte buf1 [255], buf2 [255]; |
196 char *type; | 210 Extbyte *type; |
197 XrmValue value; | 211 XrmValue value; |
198 XtGetApplicationNameAndClass (dpy, &app_name, &app_class); | 212 XtGetApplicationNameAndClass (dpy, &app_name, &app_class); |
199 strcpy (buf1, app_name); | 213 strcpy (buf1, app_name); |
200 strcpy (buf2, app_class); | 214 strcpy (buf2, app_class); |
201 for (s = buf1; *s; s++) if (*s == '.') *s = '_'; | 215 for (s = buf1; *s; s++) if (*s == '.') *s = '_'; |
202 strcat (buf1, "._no_._such_._resource_.geometry"); | 216 strcat (buf1, "._no_._such_._resource_.geometry"); |
203 strcat (buf2, "._no_._such_._resource_.Geometry"); | 217 strcat (buf2, "._no_._such_._resource_.Geometry"); |
204 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True) | 218 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True) |
205 { | 219 { |
220 Intbyte *app_name_int, *app_class_int, *value_addr_int; | |
221 Lisp_Object codesys = coding_system_of_xrm_database (XtDatabase (dpy)); | |
222 EXTERNAL_TO_C_STRING (app_name, app_name_int, codesys); | |
223 EXTERNAL_TO_C_STRING (app_class, app_class_int, codesys); | |
224 EXTERNAL_TO_C_STRING (value.addr, value_addr_int, codesys); | |
225 | |
206 warn_when_safe (Qgeometry, Qerror, | 226 warn_when_safe (Qgeometry, Qerror, |
207 "\n" | 227 "\n" |
208 "Apparently \"%s*geometry: %s\" or \"%s*geometry: %s\" was\n" | 228 "Apparently \"%s*geometry: %s\" or \"%s*geometry: %s\" was\n" |
209 "specified in the resource database. Specifying \"*geometry\" will make\n" | 229 "specified in the resource database. Specifying \"*geometry\" will make\n" |
210 "XEmacs (and most other X programs) malfunction in obscure ways. (i.e.\n" | 230 "XEmacs (and most other X programs) malfunction in obscure ways. (i.e.\n" |
211 "the Xt or Xm libraries will probably crash, which is a very bad thing.)\n" | 231 "the Xt or Xm libraries will probably crash, which is a very bad thing.)\n" |
212 "You should always use \".geometry\" or \"*EmacsFrame.geometry\" instead.\n", | 232 "You should always use \".geometry\" or \"*EmacsFrame.geometry\" instead.\n", |
213 app_name, (char *) value.addr, | 233 app_name_int, value_addr_int, |
214 app_class, (char *) value.addr); | 234 app_class_int, value_addr_int); |
215 suppress_early_error_handler_backtrace = 1; | 235 suppress_early_error_handler_backtrace = 1; |
216 syntax_error ("Invalid geometry resource", Qunbound); | 236 syntax_error ("Invalid geometry resource", Qunbound); |
217 } | 237 } |
218 } | 238 } |
219 | 239 |
307 /* Only the characters [-_A-Za-z0-9] are allowed in the individual | 327 /* Only the characters [-_A-Za-z0-9] are allowed in the individual |
308 components of a resource. Convert invalid characters to `-' */ | 328 components of a resource. Convert invalid characters to `-' */ |
309 | 329 |
310 static char valid_resource_char_p[256]; | 330 static char valid_resource_char_p[256]; |
311 | 331 |
312 /* #### not just char * here; may be fixed in my Mule ws */ | |
313 static void | 332 static void |
314 validify_resource_component (char *str, Bytecount len) | 333 validify_resource_component (Extbyte *str, Bytecount len) |
315 { | 334 { |
316 for (; len; len--, str++) | 335 for (; len; len--, str++) |
317 if (!valid_resource_char_p[(unsigned char) (*str)]) | 336 if (!valid_resource_char_p[(unsigned char) (*str)]) |
318 *str = '-'; | 337 *str = '-'; |
319 } | 338 } |
320 | 339 |
321 static void | 340 static void |
322 Dynarr_add_validified_lisp_string (char_dynarr *cda, Lisp_Object str) | 341 Dynarr_add_validified_lisp_string (Extbyte_dynarr *cda, Lisp_Object str) |
323 { | 342 { |
324 Bytecount len = XSTRING_LENGTH (str); | 343 Bytecount len; |
325 Dynarr_add_many (cda, (char *) XSTRING_DATA (str), len); | 344 Extbyte *data; |
326 validify_resource_component (Dynarr_atp (cda, Dynarr_length (cda) - len), len); | 345 |
346 TO_EXTERNAL_FORMAT (LISP_STRING, str, ALLOCA, (data, len), Qbinary); | |
347 Dynarr_add_many (cda, data, len); | |
348 validify_resource_component (Dynarr_atp (cda, Dynarr_length (cda) - len), | |
349 len); | |
327 } | 350 } |
328 | 351 |
329 #if 0 | 352 #if 0 |
330 /* compare visual info for qsorting */ | 353 /* compare visual info for qsorting */ |
331 static int | 354 static int |
339 if ( left == NULL ) | 362 if ( left == NULL ) |
340 return -1; | 363 return -1; |
341 if ( right == NULL ) | 364 if ( right == NULL ) |
342 return 1; | 365 return 1; |
343 | 366 |
344 if ( left->depth > right->depth ) { | 367 if ( left->depth > right->depth ) |
345 return 1; | 368 return 1; |
346 } | 369 else if ( left->depth == right->depth ) |
347 else if ( left->depth == right->depth ) { | 370 { |
348 if ( left->colormap_size > right->colormap_size ) | 371 if ( left->colormap_size > right->colormap_size ) |
349 return 1; | 372 return 1; |
350 if ( left->class > right->class ) | 373 if ( left->class > right->class ) |
351 return 1; | 374 return 1; |
352 else if ( left->class < right->class ) | 375 else if ( left->class < right->class ) |
353 return -1; | 376 return -1; |
354 else | 377 else |
355 return 0; | 378 return 0; |
356 } | 379 } |
357 else { | 380 else |
358 return -1; | 381 return -1; |
359 } | |
360 | |
361 } | 382 } |
362 #endif /* if 0 */ | 383 #endif /* if 0 */ |
363 | 384 |
364 #define XXX_IMAGE_LIBRARY_IS_SOMEWHAT_BROKEN | 385 #define XXX_IMAGE_LIBRARY_IS_SOMEWHAT_BROKEN |
365 static Visual * | 386 static Visual * |
604 screen = DefaultScreen (dpy); | 625 screen = DefaultScreen (dpy); |
605 if (NILP (Vdefault_x_device)) | 626 if (NILP (Vdefault_x_device)) |
606 Vdefault_x_device = device; | 627 Vdefault_x_device = device; |
607 | 628 |
608 #ifdef MULE | 629 #ifdef MULE |
609 #if defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET) | |
610 { | 630 { |
611 /* Read in locale-specific resources from | 631 /* Read in locale-specific resources from |
612 data-directory/app-defaults/$LANG/Emacs. | 632 data-directory/app-defaults/$LANG/Emacs. |
613 This is in addition to the standard app-defaults files, and | 633 This is in addition to the standard app-defaults files, and |
614 does not override resources defined elsewhere */ | 634 does not override resources defined elsewhere */ |
615 const char *data_dir; | 635 const Extbyte *data_dir; |
616 char *path; | 636 Extbyte *path; |
617 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */ | 637 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */ |
618 const char *locale = XrmLocaleOfDatabase (db); | 638 const Extbyte *locale = XrmLocaleOfDatabase (db); |
619 | 639 |
620 if (STRINGP (Vx_app_defaults_directory) && | 640 if (STRINGP (Vx_app_defaults_directory) && |
621 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) | 641 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) |
622 { | 642 { |
623 LISP_STRING_TO_EXTERNAL (Vx_app_defaults_directory, data_dir, Qfile_name); | 643 LISP_STRING_TO_EXTERNAL (Vx_app_defaults_directory, data_dir, |
624 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7); | 644 Qfile_name); |
645 path = (Extbyte *) alloca (strlen (data_dir) + strlen (locale) + | |
646 7); | |
625 sprintf (path, "%s%s/Emacs", data_dir, locale); | 647 sprintf (path, "%s%s/Emacs", data_dir, locale); |
626 if (!access (path, R_OK)) | 648 if (!access (path, R_OK)) |
627 XrmCombineFileDatabase (path, &db, False); | 649 XrmCombineFileDatabase (path, &db, False); |
628 } | 650 } |
629 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) | 651 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) |
630 { | 652 { |
631 LISP_STRING_TO_EXTERNAL (Vdata_directory, data_dir, Qfile_name); | 653 LISP_STRING_TO_EXTERNAL (Vdata_directory, data_dir, Qfile_name); |
632 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7); | 654 path = (Extbyte *) alloca (strlen (data_dir) + 13 + strlen (locale) + |
655 7); | |
633 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale); | 656 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale); |
634 if (!access (path, R_OK)) | 657 if (!access (path, R_OK)) |
635 XrmCombineFileDatabase (path, &db, False); | 658 XrmCombineFileDatabase (path, &db, False); |
636 } | 659 } |
637 } | 660 } |
638 #endif /* LWLIB_MENUBARS_MOTIF or HAVE_XIM USE_XFONTSET */ | |
639 #endif /* MULE */ | 661 #endif /* MULE */ |
640 | 662 |
641 if (NILP (DEVICE_NAME (d))) | 663 if (NILP (DEVICE_NAME (d))) |
642 DEVICE_NAME (d) = display; | 664 DEVICE_NAME (d) = display; |
643 | 665 |
681 if (cnt) | 703 if (cnt) |
682 { | 704 { |
683 depth = atoi (str + cnt); | 705 depth = atoi (str + cnt); |
684 if (depth == 0) | 706 if (depth == 0) |
685 { | 707 { |
686 stderr_out ("Invalid Depth specification in %s... ignoring...\n", str); | 708 stderr_out ("Invalid Depth specification in %s... " |
709 "ignoring...\n", str); | |
687 } | 710 } |
688 else | 711 else |
689 { | 712 { |
690 if (XMatchVisualInfo (dpy, screen, depth, vis_class, &vinfo)) | 713 if (XMatchVisualInfo (dpy, screen, depth, vis_class, &vinfo)) |
691 { | 714 { |
692 visual = vinfo.visual; | 715 visual = vinfo.visual; |
693 } | 716 } |
694 else | 717 else |
695 { | 718 { |
696 stderr_out ("Can't match the requested visual %s... using defaults\n", str); | 719 stderr_out ("Can't match the requested visual %s... " |
720 "using defaults\n", str); | |
697 } | 721 } |
698 } | 722 } |
699 } | 723 } |
700 else | 724 else |
701 { | 725 { |
702 stderr_out( "Invalid Visual specification in %s... ignoring.\n", str); | 726 stderr_out ("Invalid Visual specification in %s... " |
727 "ignoring.\n", str); | |
703 } | 728 } |
704 } | 729 } |
705 if (visual == NULL) | 730 if (visual == NULL) |
706 { | 731 { |
707 /* | 732 /* |
718 if (visual == DefaultVisual (dpy, screen)) | 743 if (visual == DefaultVisual (dpy, screen)) |
719 { | 744 { |
720 sprintf (buf1, "%s.privateColormap", app_name); | 745 sprintf (buf1, "%s.privateColormap", app_name); |
721 sprintf (buf2, "%s.PrivateColormap", app_class); | 746 sprintf (buf2, "%s.PrivateColormap", app_class); |
722 if ((visual->class == PseudoColor) && | 747 if ((visual->class == PseudoColor) && |
723 (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)) | 748 (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) |
724 { | 749 == True)) |
725 cmap = XCopyColormapAndFree (dpy, DefaultColormap (dpy, screen)); | 750 cmap = XCopyColormapAndFree (dpy, DefaultColormap (dpy, screen)); |
726 } | |
727 else | 751 else |
728 { | 752 cmap = DefaultColormap (dpy, screen); |
729 cmap = DefaultColormap (dpy, screen); | |
730 } | |
731 } | 753 } |
732 else | 754 else |
733 { | 755 { |
734 if ( best_visual_found ) | 756 if ( best_visual_found ) |
735 { | 757 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, |
736 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, AllocNone); | 758 AllocNone); |
737 } | |
738 else | 759 else |
739 { | 760 { |
740 /* We have to create a matching colormap anyway... | 761 /* We have to create a matching colormap anyway... #### |
741 #### think about using standard colormaps (need the Xmu libs?) */ | 762 think about using standard colormaps (need the Xmu |
742 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone); | 763 libs?) */ |
743 XInstallColormap(dpy, cmap); | 764 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, |
765 AllocNone); | |
766 XInstallColormap (dpy, cmap); | |
744 } | 767 } |
745 } | 768 } |
746 } | 769 } |
747 | 770 |
748 DEVICE_X_VISUAL (d) = visual; | 771 DEVICE_X_VISUAL (d) = visual; |
792 } | 815 } |
793 #endif /* HAVE_WMCOMMAND */ | 816 #endif /* HAVE_WMCOMMAND */ |
794 | 817 |
795 | 818 |
796 #ifdef HAVE_OFFIX_DND | 819 #ifdef HAVE_OFFIX_DND |
797 DndInitialize ( app_shell ); | 820 DndInitialize (app_shell); |
798 #endif | 821 #endif |
799 | 822 |
800 Vx_initial_argv_list = make_arg_list (argc, argv); | 823 Vx_initial_argv_list = make_arg_list (argc, argv); |
801 free_argc_argv (argv); | 824 free_argc_argv (argv); |
802 | 825 |
809 | 832 |
810 DEVICE_INFD (d) = DEVICE_OUTFD (d) = ConnectionNumber (dpy); | 833 DEVICE_INFD (d) = DEVICE_OUTFD (d) = ConnectionNumber (dpy); |
811 init_baud_rate (d); | 834 init_baud_rate (d); |
812 init_one_device (d); | 835 init_one_device (d); |
813 | 836 |
814 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow(app_shell)); | 837 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow (app_shell)); |
815 DEVICE_X_GRAY_PIXMAP (d) = None; | 838 DEVICE_X_GRAY_PIXMAP (d) = None; |
816 Xatoms_of_device_x (d); | 839 Xatoms_of_device_x (d); |
817 Xatoms_of_select_x (d); | 840 Xatoms_of_select_x (d); |
818 Xatoms_of_objects_x (d); | 841 Xatoms_of_objects_x (d); |
819 x_init_device_class (d); | 842 x_init_device_class (d); |
1088 } | 1111 } |
1089 | 1112 |
1090 int | 1113 int |
1091 signal_if_x_error (Display *dpy, int resumable_p) | 1114 signal_if_x_error (Display *dpy, int resumable_p) |
1092 { | 1115 { |
1093 char buf[1024]; | 1116 Extbyte buf[1024]; |
1117 Intbyte num[100]; | |
1094 Lisp_Object data; | 1118 Lisp_Object data; |
1095 if (! x_error_occurred_p (dpy)) | 1119 if (! x_error_occurred_p (dpy)) |
1096 return 0; | 1120 return 0; |
1097 data = Qnil; | 1121 data = Qnil; |
1098 sprintf (buf, "0x%X", (unsigned int) last_error.resourceid); | 1122 qxesprintf (num, "0x%X", (unsigned int) last_error.resourceid); |
1099 data = Fcons (build_string (buf), data); | 1123 data = Fcons (build_intstring (num), data); |
1100 { | 1124 qxesprintf (num, "%d", last_error.request_code); |
1101 char num [32]; | 1125 XGetErrorDatabaseText (last_error.display, "XRequest", (char *) num, "", |
1102 sprintf (num, "%d", last_error.request_code); | 1126 buf, sizeof (buf)); |
1103 XGetErrorDatabaseText (last_error.display, "XRequest", num, "", | 1127 if (*buf) |
1104 buf, sizeof (buf)); | 1128 data = Fcons (build_ext_string (buf, Qnative), data); |
1105 if (! *buf) | 1129 else |
1106 sprintf (buf, "Request-%d", last_error.request_code); | 1130 { |
1107 data = Fcons (build_string (buf), data); | 1131 qxesprintf (num, "Request-%d", last_error.request_code); |
1108 } | 1132 data = Fcons (build_intstring (num), data); |
1133 } | |
1109 XGetErrorText (last_error.display, last_error.error_code, buf, sizeof (buf)); | 1134 XGetErrorText (last_error.display, last_error.error_code, buf, sizeof (buf)); |
1110 data = Fcons (build_string (buf), data); | 1135 data = Fcons (build_ext_string (buf, Qnative), data); |
1111 again: | 1136 again: |
1112 Fsignal (Qx_error, data); | 1137 Fsignal (Qx_error, data); |
1113 if (! resumable_p) goto again; | 1138 if (! resumable_p) goto again; |
1114 return 1; | 1139 return 1; |
1115 } | 1140 } |
1128 XSETDEVICE (dev, d); | 1153 XSETDEVICE (dev, d); |
1129 | 1154 |
1130 if (NILP (find_nonminibuffer_frame_not_on_device (dev))) | 1155 if (NILP (find_nonminibuffer_frame_not_on_device (dev))) |
1131 { | 1156 { |
1132 /* We're going down. */ | 1157 /* We're going down. */ |
1133 stderr_out | 1158 Intbyte *errmess; |
1134 ("\n%s: Fatal I/O Error %d (%s) on display connection \"%s\"\n", | 1159 GET_STRERROR (errmess, errno); |
1135 (STRINGP (Vinvocation_name) ? | 1160 stderr_out ("\n%s: Fatal I/O Error %d (%s) on display " |
1136 (char *) XSTRING_DATA (Vinvocation_name) : "xemacs"), | 1161 "connection \"%s\"\n", |
1137 errno, strerror (errno), DisplayString (disp)); | 1162 (STRINGP (Vinvocation_name) ? |
1138 stderr_out | 1163 (char *) XSTRING_DATA (Vinvocation_name) : "xemacs"), |
1139 (" after %lu requests (%lu known processed) with %d events remaining.\n", | 1164 errno, errmess, DisplayString (disp)); |
1140 NextRequest (disp) - 1, LastKnownRequestProcessed (disp), | 1165 stderr_out (" after %lu requests (%lu known processed) with %d " |
1141 QLength (disp)); | 1166 "events remaining.\n", |
1167 NextRequest (disp) - 1, LastKnownRequestProcessed (disp), | |
1168 QLength (disp)); | |
1142 /* assert (!_Xdebug); */ | 1169 /* assert (!_Xdebug); */ |
1143 } | 1170 } |
1144 else | 1171 else |
1145 { | 1172 { |
1173 Intbyte *errmess; | |
1174 GET_STRERROR (errmess, errno); | |
1146 warn_when_safe | 1175 warn_when_safe |
1147 (Qx, Qcritical, | 1176 (Qx, Qcritical, |
1148 "I/O Error %d (%s) on display connection\n" | 1177 "I/O Error %d (%s) on display connection\n" |
1149 " \"%s\" after after %lu requests (%lu known processed)\n" | 1178 " \"%s\" after after %lu requests (%lu known processed)\n" |
1150 " with %d events remaining.\n" | 1179 " with %d events remaining.\n" |
1151 " Throwing to top level.\n", | 1180 " Throwing to top level.\n", |
1152 errno, strerror (errno), DisplayString (disp), | 1181 errno, errmess, DisplayString (disp), |
1153 NextRequest (disp) - 1, LastKnownRequestProcessed (disp), | 1182 NextRequest (disp) - 1, LastKnownRequestProcessed (disp), |
1154 QLength (disp)); | 1183 QLength (disp)); |
1155 } | 1184 } |
1156 | 1185 |
1157 /* According to X specs, we should not return from this function, or | 1186 /* According to X specs, we should not return from this function, or |
1260 } | 1289 } |
1261 } | 1290 } |
1262 | 1291 |
1263 #endif /* 0 */ | 1292 #endif /* 0 */ |
1264 | 1293 |
1265 /* strcasecmp() is not sufficiently portable or standard, | 1294 static Extbyte_dynarr *name_Extbyte_dynarr; |
1266 and it's easier just to write our own. */ | 1295 static Extbyte_dynarr *class_Extbyte_dynarr; |
1267 static int | |
1268 ascii_strcasecmp (const char *s1, const char *s2) | |
1269 { | |
1270 while (1) | |
1271 { | |
1272 char c1 = *s1++; | |
1273 char c2 = *s2++; | |
1274 if (c1 >= 'A' && c1 <= 'Z') c1 += 'a' - 'A'; | |
1275 if (c2 >= 'A' && c2 <= 'Z') c2 += 'a' - 'A'; | |
1276 if (c1 != c2) return c1 - c2; | |
1277 if (c1 == '\0') return 0; | |
1278 } | |
1279 } | |
1280 | |
1281 static char_dynarr *name_char_dynarr; | |
1282 static char_dynarr *class_char_dynarr; | |
1283 | 1296 |
1284 /* Given a locale and device specification from x-get-resource or | 1297 /* Given a locale and device specification from x-get-resource or |
1285 x-get-resource-prefix, return the resource prefix and display to | 1298 x-get-resource-prefix, return the resource prefix and display to |
1286 fetch the resource on. */ | 1299 fetch the resource on. */ |
1287 | 1300 |
1288 static void | 1301 static void |
1289 x_get_resource_prefix (Lisp_Object locale, Lisp_Object device, | 1302 x_get_resource_prefix (Lisp_Object locale, Lisp_Object device, |
1290 Display **display_out, char_dynarr *name, | 1303 Display **display_out, Extbyte_dynarr *name, |
1291 char_dynarr *class) | 1304 Extbyte_dynarr *class) |
1292 { | 1305 { |
1293 if (NILP (locale)) | 1306 if (NILP (locale)) |
1294 locale = Qglobal; | 1307 locale = Qglobal; |
1295 if (NILP (Fvalid_specifier_locale_p (locale))) | 1308 if (NILP (Fvalid_specifier_locale_p (locale))) |
1296 invalid_argument ("Invalid locale", locale); | 1309 invalid_argument ("Invalid locale", locale); |
1321 } | 1334 } |
1322 | 1335 |
1323 *display_out = DEVICE_X_DISPLAY (XDEVICE (device)); | 1336 *display_out = DEVICE_X_DISPLAY (XDEVICE (device)); |
1324 | 1337 |
1325 { | 1338 { |
1326 char *appname, *appclass; | 1339 Extbyte *appname, *appclass; |
1327 int name_len, class_len; | 1340 int name_len, class_len; |
1328 XtGetApplicationNameAndClass (*display_out, &appname, &appclass); | 1341 XtGetApplicationNameAndClass (*display_out, &appname, &appclass); |
1329 name_len = strlen (appname); | 1342 name_len = strlen (appname); |
1330 class_len = strlen (appclass); | 1343 class_len = strlen (appclass); |
1331 Dynarr_add_many (name , appname, name_len); | 1344 Dynarr_add_many (name, appname, name_len); |
1332 Dynarr_add_many (class, appclass, class_len); | 1345 Dynarr_add_many (class, appclass, class_len); |
1333 validify_resource_component (Dynarr_atp (name, 0), name_len); | 1346 validify_resource_component (Dynarr_atp (name, 0), name_len); |
1334 validify_resource_component (Dynarr_atp (class, 0), class_len); | 1347 validify_resource_component (Dynarr_atp (class, 0), class_len); |
1335 } | 1348 } |
1336 | 1349 |
1443 returned value is the list (t) for true, (nil) for false, and is nil to | 1456 returned value is the list (t) for true, (nil) for false, and is nil to |
1444 mean ``unspecified''. | 1457 mean ``unspecified''. |
1445 */ | 1458 */ |
1446 (name, class, type, locale, device, noerror)) | 1459 (name, class, type, locale, device, noerror)) |
1447 { | 1460 { |
1448 char* name_string, *class_string; | 1461 Extbyte *name_string, *class_string; |
1449 char *raw_result; | 1462 Extbyte *raw_result; |
1450 XrmDatabase db; | 1463 XrmDatabase db; |
1451 Display *display; | 1464 Display *display; |
1452 Error_Behavior errb = decode_error_behavior_flag (noerror); | 1465 Error_Behavior errb = decode_error_behavior_flag (noerror); |
1466 Lisp_Object codesys; | |
1453 | 1467 |
1454 CHECK_STRING (name); | 1468 CHECK_STRING (name); |
1455 CHECK_STRING (class); | 1469 CHECK_STRING (class); |
1456 CHECK_SYMBOL (type); | 1470 CHECK_SYMBOL (type); |
1457 | 1471 |
1458 Dynarr_reset (name_char_dynarr); | 1472 Dynarr_reset (name_Extbyte_dynarr); |
1459 Dynarr_reset (class_char_dynarr); | 1473 Dynarr_reset (class_Extbyte_dynarr); |
1460 | 1474 |
1461 x_get_resource_prefix (locale, device, &display, | 1475 x_get_resource_prefix (locale, device, &display, |
1462 name_char_dynarr, class_char_dynarr); | 1476 name_Extbyte_dynarr, class_Extbyte_dynarr); |
1463 if (!display) | 1477 if (!display) |
1464 return Qnil; | 1478 return Qnil; |
1465 | 1479 |
1466 db = XtDatabase (display); | 1480 db = XtDatabase (display); |
1467 | 1481 codesys = coding_system_of_xrm_database (db); |
1468 Dynarr_add (name_char_dynarr, '.'); | 1482 Dynarr_add (name_Extbyte_dynarr, '.'); |
1469 Dynarr_add_lisp_string (name_char_dynarr, name); | 1483 Dynarr_add_lisp_string (name_Extbyte_dynarr, name, Qbinary); |
1470 Dynarr_add (class_char_dynarr, '.'); | 1484 Dynarr_add (class_Extbyte_dynarr, '.'); |
1471 Dynarr_add_lisp_string (class_char_dynarr, class); | 1485 Dynarr_add_lisp_string (class_Extbyte_dynarr, class, Qbinary); |
1472 Dynarr_add (name_char_dynarr, '\0'); | 1486 Dynarr_add (name_Extbyte_dynarr, '\0'); |
1473 Dynarr_add (class_char_dynarr, '\0'); | 1487 Dynarr_add (class_Extbyte_dynarr, '\0'); |
1474 | 1488 |
1475 name_string = Dynarr_atp (name_char_dynarr, 0); | 1489 name_string = Dynarr_atp (name_Extbyte_dynarr, 0); |
1476 class_string = Dynarr_atp (class_char_dynarr, 0); | 1490 class_string = Dynarr_atp (class_Extbyte_dynarr, 0); |
1477 | 1491 |
1478 { | 1492 { |
1479 XrmValue xrm_value; | 1493 XrmValue xrm_value; |
1480 XrmName namelist[100]; | 1494 XrmName namelist[100]; |
1481 XrmClass classlist[100]; | 1495 XrmClass classlist[100]; |
1501 } | 1515 } |
1502 result = XrmQGetResource (db, namelist, classlist, &xrm_type, &xrm_value); | 1516 result = XrmQGetResource (db, namelist, classlist, &xrm_type, &xrm_value); |
1503 | 1517 |
1504 if (result != True || xrm_type != string_quark) | 1518 if (result != True || xrm_type != string_quark) |
1505 return Qnil; | 1519 return Qnil; |
1506 raw_result = (char *) xrm_value.addr; | 1520 raw_result = (Extbyte *) xrm_value.addr; |
1507 } | 1521 } |
1508 | 1522 |
1509 if (EQ (type, Qstring)) | 1523 if (EQ (type, Qstring)) |
1510 return build_string (raw_result); | 1524 return build_ext_string (raw_result, codesys); |
1511 else if (EQ (type, Qboolean)) | 1525 else if (EQ (type, Qboolean)) |
1512 { | 1526 { |
1513 if (!ascii_strcasecmp (raw_result, "off") || | 1527 if (!strcasecmp (raw_result, "off") || |
1514 !ascii_strcasecmp (raw_result, "false") || | 1528 !strcasecmp (raw_result, "false") || |
1515 !ascii_strcasecmp (raw_result, "no")) | 1529 !strcasecmp (raw_result, "no")) |
1516 return Fcons (Qnil, Qnil); | 1530 return Fcons (Qnil, Qnil); |
1517 if (!ascii_strcasecmp (raw_result, "on") || | 1531 if (!strcasecmp (raw_result, "on") || |
1518 !ascii_strcasecmp (raw_result, "true") || | 1532 !strcasecmp (raw_result, "true") || |
1519 !ascii_strcasecmp (raw_result, "yes")) | 1533 !strcasecmp (raw_result, "yes")) |
1520 return Fcons (Qt, Qnil); | 1534 return Fcons (Qt, Qnil); |
1521 return maybe_signal_continuable_error_2 | 1535 return maybe_signal_continuable_error_2 |
1522 (Qinvalid_operation, "Can't convert to a Boolean", | 1536 (Qinvalid_operation, "Can't convert to a Boolean", |
1523 build_string (name_string), build_string (raw_result), Qresource, | 1537 build_ext_string (name_string, Qbinary), |
1538 build_ext_string (raw_result, codesys), Qresource, | |
1524 errb); | 1539 errb); |
1525 } | 1540 } |
1526 else if (EQ (type, Qinteger) || EQ (type, Qnatnum)) | 1541 else if (EQ (type, Qinteger) || EQ (type, Qnatnum)) |
1527 { | 1542 { |
1528 int i; | 1543 int i; |
1529 char c; | 1544 char c; |
1530 if (1 != sscanf (raw_result, "%d%c", &i, &c)) | 1545 if (1 != sscanf (raw_result, "%d%c", &i, &c)) |
1531 return maybe_signal_continuable_error_2 | 1546 return maybe_signal_continuable_error_2 |
1532 (Qinvalid_operation, "Can't convert to an integer", | 1547 (Qinvalid_operation, "Can't convert to an integer", |
1533 build_string (name_string), build_string (raw_result), Qresource, | 1548 build_ext_string (name_string, Qbinary), |
1549 build_ext_string (raw_result, codesys), Qresource, | |
1534 errb); | 1550 errb); |
1535 else if (EQ (type, Qnatnum) && i < 0) | 1551 else if (EQ (type, Qnatnum) && i < 0) |
1536 return maybe_signal_continuable_error_2 | 1552 return maybe_signal_continuable_error_2 |
1537 (Qinvalid_argument, "Invalid numerical value for resource", | 1553 (Qinvalid_argument, "Invalid numerical value for resource", |
1538 make_int (i), build_string (name_string), Qresource, errb); | 1554 make_int (i), build_ext_string (name_string, Qbinary), |
1555 Qresource, errb); | |
1539 else | 1556 else |
1540 return make_int (i); | 1557 return make_int (i); |
1541 } | 1558 } |
1542 else | 1559 else |
1543 { | 1560 { |
1559 */ | 1576 */ |
1560 (locale, device)) | 1577 (locale, device)) |
1561 { | 1578 { |
1562 Display *display; | 1579 Display *display; |
1563 | 1580 |
1564 Dynarr_reset (name_char_dynarr ); | 1581 Dynarr_reset (name_Extbyte_dynarr ); |
1565 Dynarr_reset (class_char_dynarr); | 1582 Dynarr_reset (class_Extbyte_dynarr); |
1566 | 1583 |
1567 x_get_resource_prefix (locale, device, &display, | 1584 x_get_resource_prefix (locale, device, &display, |
1568 name_char_dynarr, class_char_dynarr); | 1585 name_Extbyte_dynarr, class_Extbyte_dynarr); |
1569 if (!display) | 1586 if (!display) |
1570 return Qnil; | 1587 return Qnil; |
1571 | 1588 |
1572 return Fcons (make_string ((Intbyte *) Dynarr_atp (name_char_dynarr, 0), | 1589 return Fcons (make_string ((Intbyte *) Dynarr_atp (name_Extbyte_dynarr, 0), |
1573 Dynarr_length (name_char_dynarr)), | 1590 Dynarr_length (name_Extbyte_dynarr)), |
1574 make_string ((Intbyte *) Dynarr_atp (class_char_dynarr, 0), | 1591 make_string ((Intbyte *) Dynarr_atp (class_Extbyte_dynarr, 0), |
1575 Dynarr_length (class_char_dynarr))); | 1592 Dynarr_length (class_Extbyte_dynarr))); |
1576 } | 1593 } |
1577 | 1594 |
1578 DEFUN ("x-put-resource", Fx_put_resource, 1, 2, 0, /* | 1595 DEFUN ("x-put-resource", Fx_put_resource, 1, 2, 0, /* |
1579 Add a resource to the resource database for DEVICE. | 1596 Add a resource to the resource database for DEVICE. |
1580 RESOURCE-LINE specifies the resource to add and should be a | 1597 RESOURCE-LINE specifies the resource to add and should be a |
1581 standard resource specification. | 1598 standard resource specification. |
1582 */ | 1599 */ |
1583 (resource_line, device)) | 1600 (resource_line, device)) |
1584 { | 1601 { |
1585 struct device *d = decode_device (device); | 1602 struct device *d = decode_device (device); |
1586 char *str, *colon_pos; | |
1587 | |
1588 CHECK_STRING (resource_line); | |
1589 str = (char *) XSTRING_DATA (resource_line); | |
1590 if (!(colon_pos = strchr (str, ':')) || strchr (str, '\n')) | |
1591 invalid: | |
1592 syntax_error ("Invalid resource line", resource_line); | |
1593 if ((int) strspn (str, | |
1594 /* Only the following chars are allowed before the colon */ | |
1595 " \t.*?abcdefghijklmnopqrstuvwxyz" | |
1596 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-") | |
1597 != colon_pos - str) | |
1598 goto invalid; | |
1599 | 1603 |
1600 if (DEVICE_X_P (d)) | 1604 if (DEVICE_X_P (d)) |
1601 { | 1605 { |
1602 XrmDatabase db = XtDatabase (DEVICE_X_DISPLAY (d)); | 1606 XrmDatabase db = XtDatabase (DEVICE_X_DISPLAY (d)); |
1607 Extbyte *str, *colon_pos; | |
1608 | |
1609 CHECK_STRING (resource_line); | |
1610 LISP_STRING_TO_EXTERNAL (resource_line, str, | |
1611 coding_system_of_xrm_database (db)); | |
1612 if (!(colon_pos = strchr (str, ':')) || strchr (str, '\n')) | |
1613 invalid: | |
1614 syntax_error ("Invalid resource line", resource_line); | |
1615 if ((int) | |
1616 strspn (str, | |
1617 /* Only the following chars are allowed before the colon */ | |
1618 " \t.*?abcdefghijklmnopqrstuvwxyz" | |
1619 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-") | |
1620 != colon_pos - str) | |
1621 goto invalid; | |
1622 | |
1603 XrmPutLineResource (&db, str); | 1623 XrmPutLineResource (&db, str); |
1604 } | 1624 } |
1605 | 1625 |
1606 return Qnil; | 1626 return Qnil; |
1607 } | 1627 } |
1999 DEFSUBR (Fx_set_font_path); | 2019 DEFSUBR (Fx_set_font_path); |
2000 | 2020 |
2001 DEFSYMBOL (Qx_error); | 2021 DEFSYMBOL (Qx_error); |
2002 DEFSYMBOL (Qinit_pre_x_win); | 2022 DEFSYMBOL (Qinit_pre_x_win); |
2003 DEFSYMBOL (Qinit_post_x_win); | 2023 DEFSYMBOL (Qinit_post_x_win); |
2024 | |
2025 #ifdef MULE | |
2026 DEFSYMBOL (Qget_coding_system_from_locale); | |
2027 #endif | |
2004 } | 2028 } |
2005 | 2029 |
2006 void | 2030 void |
2007 reinit_console_type_create_device_x (void) | 2031 reinit_console_type_create_device_x (void) |
2008 { | 2032 { |
2009 /* Initialize variables to speed up X resource interactions */ | 2033 /* Initialize variables to speed up X resource interactions */ |
2010 const char *valid_resource_chars = | 2034 const Char_ASCII *valid_resource_chars = |
2011 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; | 2035 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; |
2012 while (*valid_resource_chars) | 2036 while (*valid_resource_chars) |
2013 valid_resource_char_p[(unsigned int) (*valid_resource_chars++)] = 1; | 2037 valid_resource_char_p[(unsigned int) (*valid_resource_chars++)] = 1; |
2014 | 2038 |
2015 name_char_dynarr = Dynarr_new (char); | 2039 name_Extbyte_dynarr = Dynarr_new (Extbyte); |
2016 class_char_dynarr = Dynarr_new (char); | 2040 class_Extbyte_dynarr = Dynarr_new (Extbyte); |
2017 } | 2041 } |
2018 | 2042 |
2019 void | 2043 void |
2020 console_type_create_device_x (void) | 2044 console_type_create_device_x (void) |
2021 { | 2045 { |
2069 `command-line-args-left'. Perhaps `command-line-args-left' should | 2093 `command-line-args-left'. Perhaps `command-line-args-left' should |
2070 just reside in C. | 2094 just reside in C. |
2071 */ ); | 2095 */ ); |
2072 Vx_initial_argv_list = Qnil; | 2096 Vx_initial_argv_list = Qnil; |
2073 | 2097 |
2074 #if defined(MULE) && (defined(LWLIB_MENUBARS_MOTIF) || defined(HAVE_XIM) || defined (USE_XFONTSET)) | 2098 #ifdef MULE |
2075 DEFVAR_LISP ("x-app-defaults-directory", &Vx_app_defaults_directory /* | 2099 DEFVAR_LISP ("x-app-defaults-directory", &Vx_app_defaults_directory /* |
2076 Used by the Lisp code to communicate to the low level X initialization | 2100 Used by the Lisp code to communicate to the low level X initialization |
2077 where the localized init files are. | 2101 where the localized init files are. |
2078 */ ); | 2102 */ ); |
2079 Vx_app_defaults_directory = Qnil; | 2103 Vx_app_defaults_directory = Qnil; |