comparison src/device-x.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents de805c49cfc1
children da8ed4261e83
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
47 #include "sysdep.h" 47 #include "sysdep.h"
48 #include "window.h" 48 #include "window.h"
49 49
50 #include "sysfile.h" 50 #include "sysfile.h"
51 #include "systime.h" 51 #include "systime.h"
52
53 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D)
54 #include "sysdll.h"
55 #endif /* HAVE_SHLIB and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */
56 52
57 #ifdef HAVE_OFFIX_DND 53 #ifdef HAVE_OFFIX_DND
58 #include "offix.h" 54 #include "offix.h"
59 #endif 55 #endif
60 56
389 */ 385 */
390 && (visual_class != PseudoColor || 386 && (visual_class != PseudoColor ||
391 vi_out [i].depth == 1 || 387 vi_out [i].depth == 1 ||
392 vi_out [i].depth == 8) 388 vi_out [i].depth == 8)
393 #endif 389 #endif
394 390
395 /* SGI has 30-bit deep visuals. Ignore them. 391 /* SGI has 30-bit deep visuals. Ignore them.
396 (We only have 24-bit data anyway.) 392 (We only have 24-bit data anyway.)
397 */ 393 */
398 && (vi_out [i].depth <= 24) 394 && (vi_out [i].depth <= 24)
399 ) 395 )
400 best = i; 396 best = i;
458 Lisp_Object device; 454 Lisp_Object device;
459 Display *dpy; 455 Display *dpy;
460 Widget app_shell; 456 Widget app_shell;
461 int argc; 457 int argc;
462 char **argv; 458 char **argv;
463 const char *app_class; 459 CONST char *app_class;
464 const char *app_name; 460 CONST char *app_name;
465 const char *disp_name; 461 CONST char *disp_name;
466 Visual *visual = NULL; 462 Visual *visual = NULL;
467 int depth = 8; /* shut up the compiler */ 463 int depth = 8; /* shut up the compiler */
468 Colormap cmap; 464 Colormap cmap;
469 int screen; 465 int screen;
470 /* */ 466 /* */
471 int best_visual_found = 0; 467 int best_visual_found = 0;
472 468
473 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D)
474 /*
475 * In order to avoid the lossage with flat Athena widgets dynamically
476 * linking to one of the ThreeD variants, using the dynamic symbol helpers
477 * to look for symbols that shouldn't be there and refusing to run if they
478 * are seems a less toxic idea than having XEmacs crash when we try and
479 * use a subclass of a widget that has changed size.
480 *
481 * It's ugly, I know, and not going to work everywhere. It seems better to
482 * do our damnedest to try and tell the user what to expect rather than
483 * simply blow up though.
484 *
485 * All the ThreeD variants I have access to define the following function
486 * symbols in the shared library. The flat Xaw library does not define them:
487 *
488 * Xaw3dComputeBottomShadowRGB
489 * Xaw3dComputeTopShadowRGB
490 *
491 * So far only Linux has shown this problem. This seems to be portable to
492 * all the distributions (certainly all the ones I checked - Debian and
493 * Redhat)
494 *
495 * This will only work, sadly, with dlopen() -- the other dynamic linkers
496 * are simply not capable of doing what is needed. :/
497 */
498
499 {
500 /* Get a dll handle to the main process. */
501 dll_handle xaw_dll_handle = dll_open (NULL);
502
503 /* Did that fail? If so, continue without error.
504 * We could die here but, well, that's unfriendly and all -- plus I feel
505 * better about some crashing somewhere rather than preventing a perfectly
506 * good configuration working just because dll_open failed.
507 */
508 if (xaw_dll_handle != NULL)
509 {
510 /* Look for the Xaw3d function */
511 dll_func xaw_function_handle =
512 dll_function (xaw_dll_handle, "Xaw3dComputeTopShadowRGB");
513
514 /* If we found it, warn the user in big, nasty, unfriendly letters */
515 if (xaw_function_handle != NULL)
516 {
517 warn_when_safe (Qdevice, Qerror, "\n"
518 "It seems that XEmacs is built dynamically linked to the flat Athena widget\n"
519 "library but it finds a 3D Athena variant with the same name at runtime.\n"
520 "\n"
521 "This WILL cause your XEmacs process to dump core at some point.\n"
522 "You should not continue to use this binary without resolving this issue.\n"
523 "\n"
524 "This can be solved with the xaw-wrappers package under Debian\n"
525 "(register XEmacs as incompatible with all 3d widget sets, see\n"
526 "update-xaw-wrappers(8) and .../doc/xaw-wrappers/README.packagers). It\n"
527 "can be verified by checking the runtime path in /etc/ld.so.conf and by\n"
528 "using `ldd /path/to/xemacs' under other Linux distributions. One\n"
529 "solution is to use LD_PRELOAD or LD_LIBRARY_PATH to force ld.so to\n"
530 "load the flat Athena widget library instead of the aliased 3D widget\n"
531 "library (see ld.so(8) for use of these environment variables).\n\n"
532 );
533
534 }
535
536 /* Otherwise release the handle to the library
537 * No error catch here; I can't think of a way to recover anyhow.
538 */
539 dll_close (xaw_dll_handle);
540 }
541 }
542 #endif /* HAVE_SHLIB and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */
543
544
545 XSETDEVICE (device, d); 469 XSETDEVICE (device, d);
546 display = DEVICE_CONNECTION (d); 470 display = DEVICE_CONNECTION (d);
547 471
548 allocate_x_device_struct (d); 472 allocate_x_device_struct (d);
549 473
550 make_argc_argv (Vx_initial_argv_list, &argc, &argv); 474 make_argc_argv (Vx_initial_argv_list, &argc, &argv);
551 475
552 TO_EXTERNAL_FORMAT (LISP_STRING, display, 476 GET_C_STRING_CTEXT_DATA_ALLOCA (display, disp_name);
553 C_STRING_ALLOCA, disp_name,
554 Qctext);
555 477
556 /* 478 /*
557 * Break apart the old XtOpenDisplay call into XOpenDisplay and 479 * Break apart the old XtOpenDisplay call into XOpenDisplay and
558 * XtDisplayInitialize so we can figure out whether there 480 * XtDisplayInitialize so we can figure out whether there
559 * are any XEmacs resources in the resource database before 481 * are any XEmacs resources in the resource database before
571 signal_simple_error ("X server not responding\n", display); 493 signal_simple_error ("X server not responding\n", display);
572 } 494 }
573 495
574 if (STRINGP (Vx_emacs_application_class) && 496 if (STRINGP (Vx_emacs_application_class) &&
575 XSTRING_LENGTH (Vx_emacs_application_class) > 0) 497 XSTRING_LENGTH (Vx_emacs_application_class) > 0)
576 TO_EXTERNAL_FORMAT (LISP_STRING, Vx_emacs_application_class, 498 GET_C_STRING_CTEXT_DATA_ALLOCA (Vx_emacs_application_class, app_class);
577 C_STRING_ALLOCA, app_class,
578 Qctext);
579 else 499 else
580 { 500 {
581 app_class = (NILP (Vx_emacs_application_class) && 501 app_class = (NILP (Vx_emacs_application_class) &&
582 have_xemacs_resources_in_xrdb (dpy)) 502 have_xemacs_resources_in_xrdb (dpy))
583 #ifdef INFODOCK 503 #ifdef INFODOCK
607 { 527 {
608 /* Read in locale-specific resources from 528 /* Read in locale-specific resources from
609 data-directory/app-defaults/$LANG/Emacs. 529 data-directory/app-defaults/$LANG/Emacs.
610 This is in addition to the standard app-defaults files, and 530 This is in addition to the standard app-defaults files, and
611 does not override resources defined elsewhere */ 531 does not override resources defined elsewhere */
612 const char *data_dir; 532 CONST char *data_dir;
613 char *path; 533 char *path;
614 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */ 534 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */
615 const char *locale = XrmLocaleOfDatabase (db); 535 CONST char *locale = XrmLocaleOfDatabase (db);
616 536
617 if (STRINGP (Vx_app_defaults_directory) && 537 if (STRINGP (Vx_app_defaults_directory) &&
618 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) 538 XSTRING_LENGTH (Vx_app_defaults_directory) > 0)
619 { 539 {
620 TO_EXTERNAL_FORMAT (LISP_STRING, Vx_app_defaults_directory, 540 GET_C_STRING_FILENAME_DATA_ALLOCA(Vx_app_defaults_directory, data_dir);
621 C_STRING_ALLOCA, data_dir,
622 Qfile_name);
623 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7); 541 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7);
624 sprintf (path, "%s%s/Emacs", data_dir, locale); 542 sprintf (path, "%s%s/Emacs", data_dir, locale);
625 if (!access (path, R_OK)) 543 if (!access (path, R_OK))
626 XrmCombineFileDatabase (path, &db, False); 544 XrmCombineFileDatabase (path, &db, False);
627 } 545 }
628 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) 546 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0)
629 { 547 {
630 TO_EXTERNAL_FORMAT (LISP_STRING, Vdata_directory, 548 GET_C_STRING_FILENAME_DATA_ALLOCA (Vdata_directory, data_dir);
631 C_STRING_ALLOCA, data_dir,
632 Qfile_name);
633 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7); 549 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7);
634 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale); 550 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale);
635 if (!access (path, R_OK)) 551 if (!access (path, R_OK))
636 XrmCombineFileDatabase (path, &db, False); 552 XrmCombineFileDatabase (path, &db, False);
637 } 553 }
648 strings */ 564 strings */
649 565
650 XtGetApplicationNameAndClass (dpy, (char **) &app_name, (char **) &app_class); 566 XtGetApplicationNameAndClass (dpy, (char **) &app_name, (char **) &app_class);
651 /* search for a matching visual if requested by the user, or setup the display default */ 567 /* search for a matching visual if requested by the user, or setup the display default */
652 { 568 {
653 int resource_name_length = max (sizeof (".emacsVisual"), 569 char *buf1 = (char *)alloca (strlen (app_name) + 17);
654 sizeof (".privateColormap")); 570 char *buf2 = (char *)alloca (strlen (app_class) + 17);
655 char *buf1 = alloca_array (char, strlen (app_name) + resource_name_length);
656 char *buf2 = alloca_array (char, strlen (app_class) + resource_name_length);
657 char *type; 571 char *type;
658 XrmValue value; 572 XrmValue value;
659 573
660 sprintf (buf1, "%s.emacsVisual", app_name); 574 sprintf (buf1, "%s.emacsVisual", app_name);
661 sprintf (buf2, "%s.EmacsVisual", app_class); 575 sprintf (buf2, "%s.EmacsVisual", app_class);
662 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True) 576 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)
663 { 577 {
664 int cnt = 0; 578 int cnt = 0, vis_class = PseudoColor;
665 int vis_class = PseudoColor;
666 XVisualInfo vinfo; 579 XVisualInfo vinfo;
667 char *str = (char*) value.addr; 580 char *res, *str = (char*)value.addr;
668 581
669 #define CHECK_VIS_CLASS(visual_class) \ 582 #define CHECK_VIS_CLASS(class) \
670 else if (memcmp (str, #visual_class, sizeof (#visual_class) - 1) == 0) \ 583 else if (strncmp (str, #class, sizeof (#class) - 1) == 0) \
671 cnt = sizeof (#visual_class) - 1, vis_class = visual_class 584 cnt = sizeof (#class) - 1, vis_class = class
672 585
673 if (1) 586 if (1)
674 ; 587 ;
675 CHECK_VIS_CLASS (StaticGray); 588 CHECK_VIS_CLASS (StaticGray);
676 CHECK_VIS_CLASS (StaticColor); 589 CHECK_VIS_CLASS (StaticColor);
679 CHECK_VIS_CLASS (PseudoColor); 592 CHECK_VIS_CLASS (PseudoColor);
680 CHECK_VIS_CLASS (DirectColor); 593 CHECK_VIS_CLASS (DirectColor);
681 594
682 if (cnt) 595 if (cnt)
683 { 596 {
684 depth = atoi (str + cnt); 597 res = str + cnt;
598 depth = atoi (res);
685 if (depth == 0) 599 if (depth == 0)
686 { 600 {
687 stderr_out ("Invalid Depth specification in %s... ignoring...\n", str); 601 stderr_out ("Invalid Depth specification in %s... ignoring...\n", str);
688 } 602 }
689 else 603 else
737 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, AllocNone); 651 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, AllocNone);
738 } 652 }
739 else 653 else
740 { 654 {
741 /* We have to create a matching colormap anyway... 655 /* We have to create a matching colormap anyway...
742 #### think about using standard colormaps (need the Xmu libs?) */ 656 ### think about using standard colormaps (need the Xmu libs?) */
743 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone); 657 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone);
744 XInstallColormap(dpy, cmap); 658 XInstallColormap(dpy, cmap);
745 } 659 }
746 } 660 }
747 } 661 }
780 XtSetArg (al[4], XtNheight, HeightOfScreen (ScreenOfDisplay (dpy, screen))); 694 XtSetArg (al[4], XtNheight, HeightOfScreen (ScreenOfDisplay (dpy, screen)));
781 XtSetValues (app_shell, al, countof (al)); 695 XtSetValues (app_shell, al, countof (al));
782 XtRealizeWidget (app_shell); 696 XtRealizeWidget (app_shell);
783 } 697 }
784 698
785 #ifdef HAVE_WMCOMMAND 699 #ifdef HAVE_SESSION
786 { 700 {
787 int new_argc; 701 int new_argc;
788 char **new_argv; 702 char **new_argv;
789 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv); 703 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv);
790 XSetCommand (XtDisplay (app_shell), XtWindow (app_shell), new_argv, new_argc); 704 XSetCommand (XtDisplay (app_shell), XtWindow (app_shell), new_argv, new_argc);
791 free_argc_argv (new_argv); 705 free_argc_argv (new_argv);
792 } 706 }
793 #endif /* HAVE_WMCOMMAND */ 707 #endif /* HAVE_SESSION */
794 708
795 709
796 #ifdef HAVE_OFFIX_DND 710 #ifdef HAVE_OFFIX_DND
797 DndInitialize ( app_shell ); 711 DndInitialize ( app_shell );
798 #endif 712 #endif
812 init_one_device (d); 726 init_one_device (d);
813 727
814 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow(app_shell)); 728 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow(app_shell));
815 DEVICE_X_GRAY_PIXMAP (d) = None; 729 DEVICE_X_GRAY_PIXMAP (d) = None;
816 Xatoms_of_device_x (d); 730 Xatoms_of_device_x (d);
817 Xatoms_of_select_x (d); 731 Xatoms_of_xselect (d);
818 Xatoms_of_objects_x (d); 732 Xatoms_of_objects_x (d);
819 x_init_device_class (d); 733 x_init_device_class (d);
820 734
821 /* Run the elisp side of the X device initialization. */ 735 /* Run the elisp side of the X device initialization. */
822 call0 (Qinit_pre_x_win); 736 call0 (Qinit_pre_x_win);
827 { 741 {
828 call0 (Qinit_post_x_win); 742 call0 (Qinit_post_x_win);
829 } 743 }
830 744
831 static void 745 static void
832 x_mark_device (struct device *d) 746 x_mark_device (struct device *d, void (*markobj) (Lisp_Object))
833 { 747 {
834 mark_object (DEVICE_X_WM_COMMAND_FRAME (d)); 748 markobj (DEVICE_X_WM_COMMAND_FRAME (d));
835 mark_object (DEVICE_X_DATA (d)->x_keysym_map_hash_table); 749 markobj (DEVICE_X_DATA (d)->x_keysym_map_hash_table);
836 } 750 }
837 751
838 752
839 /************************************************************************/ 753 /************************************************************************/
840 /* closing an X connection */ 754 /* closing an X connection */
911 825
912 /************************************************************************/ 826 /************************************************************************/
913 /* handle X errors */ 827 /* handle X errors */
914 /************************************************************************/ 828 /************************************************************************/
915 829
916 const char * 830 CONST char *
917 x_event_name (int event_type) 831 x_event_name (int event_type)
918 { 832 {
919 static const char *events[] = 833 static CONST char *events[] =
920 { 834 {
921 "0: ERROR!", 835 "0: ERROR!",
922 "1: REPLY", 836 "1: REPLY",
923 "KeyPress", 837 "KeyPress",
924 "KeyRelease", 838 "KeyRelease",
1360 LOCALE, if a device can be derived (i.e. if LOCALE is a frame or device), 1274 LOCALE, if a device can be derived (i.e. if LOCALE is a frame or device),
1361 and otherwise defaults to the value of `default-x-device'. 1275 and otherwise defaults to the value of `default-x-device'.
1362 The sixth arg NOERROR, if non-nil, means do not signal an error if a 1276 The sixth arg NOERROR, if non-nil, means do not signal an error if a
1363 bogus resource specification was retrieved (e.g. if a non-integer was 1277 bogus resource specification was retrieved (e.g. if a non-integer was
1364 given when an integer was requested). In this case, a warning is issued 1278 given when an integer was requested). In this case, a warning is issued
1365 instead, unless NOERROR is t, in which case no warning is issued. 1279 instead.
1366 1280
1367 The resource names passed to this function are looked up relative to the 1281 The resource names passed to this function are looked up relative to the
1368 locale. 1282 locale.
1369 1283
1370 If you want to search for a subresource, you just need to specify the 1284 If you want to search for a subresource, you just need to specify the
1419 1333
1420 The returned value of this function is nil if the queried resource is not 1334 The returned value of this function is nil if the queried resource is not
1421 found. If the third arg is `string', a string is returned, and if it is 1335 found. If the third arg is `string', a string is returned, and if it is
1422 `integer', an integer is returned. If the third arg is `boolean', then the 1336 `integer', an integer is returned. If the third arg is `boolean', then the
1423 returned value is the list (t) for true, (nil) for false, and is nil to 1337 returned value is the list (t) for true, (nil) for false, and is nil to
1424 mean ``unspecified''. 1338 mean ``unspecified.''
1425 */ 1339 */
1426 (name, class, type, locale, device, no_error)) 1340 (name, class, type, locale, device, no_error))
1427 { 1341 {
1428 char* name_string, *class_string; 1342 char* name_string, *class_string;
1429 char *raw_result; 1343 char *raw_result;
1682 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in 1596 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
1683 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system. 1597 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
1684 */ 1598 */
1685 (keysym)) 1599 (keysym))
1686 { 1600 {
1687 const char *keysym_ext; 1601 CONST char *keysym_ext;
1688 1602
1689 CHECK_STRING (keysym); 1603 CHECK_STRING (keysym);
1690 TO_EXTERNAL_FORMAT (LISP_STRING, keysym, 1604 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext);
1691 C_STRING_ALLOCA, keysym_ext,
1692 Qctext);
1693 1605
1694 return XStringToKeysym (keysym_ext) ? Qt : Qnil; 1606 return XStringToKeysym (keysym_ext) ? Qt : Qnil;
1695 } 1607 }
1696 1608
1697 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /* 1609 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /*
1698 Return a hash table containing a key for all keysyms on DEVICE. 1610 Return a hash table which contains a hash key for all keysyms which
1699 DEVICE must be an X11 display device. See `x-keysym-on-keyboard-p'. 1611 name keys on the keyboard. See `x-keysym-on-keyboard-p'.
1700 */ 1612 */
1701 (device)) 1613 (device))
1702 { 1614 {
1703 struct device *d = decode_device (device); 1615 struct device *d = decode_device (device);
1704 if (!DEVICE_X_P (d)) 1616 if (!DEVICE_X_P (d))
1836 DEFUN ("x-grab-keyboard", Fx_grab_keyboard, 0, 1, 0, /* 1748 DEFUN ("x-grab-keyboard", Fx_grab_keyboard, 0, 1, 0, /*
1837 Grab the keyboard on the given device (defaulting to the selected one). 1749 Grab the keyboard on the given device (defaulting to the selected one).
1838 So long as the keyboard is grabbed, all keyboard events will be delivered 1750 So long as the keyboard is grabbed, all keyboard events will be delivered
1839 to emacs -- it is not possible for other X clients to eavesdrop on them. 1751 to emacs -- it is not possible for other X clients to eavesdrop on them.
1840 Ungrab the keyboard with `x-ungrab-keyboard' (use an unwind-protect). 1752 Ungrab the keyboard with `x-ungrab-keyboard' (use an unwind-protect).
1841 Returns t if the grab is successful, nil otherwise. 1753 Returns t if the grab was successful; nil otherwise.
1842 */ 1754 */
1843 (device)) 1755 (device))
1844 { 1756 {
1845 struct device *d = decode_x_device (device); 1757 struct device *d = decode_x_device (device);
1846 Window w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d))); 1758 Window w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d)));
1888 */ 1800 */
1889 (device)) 1801 (device))
1890 { 1802 {
1891 Display *dpy = get_x_display (device); 1803 Display *dpy = get_x_display (device);
1892 int ndirs_return; 1804 int ndirs_return;
1893 const char **directories = (const char **) XGetFontPath (dpy, &ndirs_return); 1805 CONST char **directories = (CONST char **) XGetFontPath (dpy, &ndirs_return);
1894 Lisp_Object font_path = Qnil; 1806 Lisp_Object font_path = Qnil;
1895 1807
1896 if (!directories) 1808 if (!directories)
1897 signal_simple_error ("Can't get X font path", device); 1809 signal_simple_error ("Can't get X font path", device);
1898 1810
1899 while (ndirs_return--) 1811 while (ndirs_return--)
1900 font_path = Fcons (build_ext_string (directories[ndirs_return], 1812 font_path = Fcons (build_ext_string (directories[ndirs_return],
1901 Qfile_name), 1813 FORMAT_FILENAME), font_path);
1902 font_path);
1903 1814
1904 return font_path; 1815 return font_path;
1905 } 1816 }
1906 1817
1907 DEFUN ("x-set-font-path", Fx_set_font_path, 1, 2, 0, /* 1818 DEFUN ("x-set-font-path", Fx_set_font_path, 1, 2, 0, /*
1920 */ 1831 */
1921 (font_path, device)) 1832 (font_path, device))
1922 { 1833 {
1923 Display *dpy = get_x_display (device); 1834 Display *dpy = get_x_display (device);
1924 Lisp_Object path_entry; 1835 Lisp_Object path_entry;
1925 const char **directories; 1836 CONST char **directories;
1926 int i=0,ndirs=0; 1837 int i=0,ndirs=0;
1927 1838
1928 EXTERNAL_LIST_LOOP (path_entry, font_path) 1839 EXTERNAL_LIST_LOOP (path_entry, font_path)
1929 { 1840 {
1930 CHECK_STRING (XCAR (path_entry)); 1841 CHECK_STRING (XCAR (path_entry));
1931 ndirs++; 1842 ndirs++;
1932 } 1843 }
1933 1844
1934 directories = alloca_array (const char *, ndirs); 1845 directories = alloca_array (CONST char *, ndirs);
1935 1846
1936 EXTERNAL_LIST_LOOP (path_entry, font_path) 1847 EXTERNAL_LIST_LOOP (path_entry, font_path)
1937 { 1848 {
1938 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (path_entry), 1849 GET_C_STRING_FILENAME_DATA_ALLOCA (XCAR (path_entry), directories[i++]);
1939 C_STRING_ALLOCA, directories[i++],
1940 Qfile_name);
1941 } 1850 }
1942 1851
1943 expect_x_error (dpy); 1852 expect_x_error (dpy);
1944 XSetFontPath (dpy, (char **) directories, ndirs); 1853 XSetFontPath (dpy, (char **) directories, ndirs);
1945 signal_if_x_error (dpy, 1/*resumable_p*/); 1854 signal_if_x_error (dpy, 1/*resumable_p*/);
1982 defsymbol (&Qinit_pre_x_win, "init-pre-x-win"); 1891 defsymbol (&Qinit_pre_x_win, "init-pre-x-win");
1983 defsymbol (&Qinit_post_x_win, "init-post-x-win"); 1892 defsymbol (&Qinit_post_x_win, "init-post-x-win");
1984 } 1893 }
1985 1894
1986 void 1895 void
1987 reinit_console_type_create_device_x (void)
1988 {
1989 /* Initialize variables to speed up X resource interactions */
1990 const char *valid_resource_chars =
1991 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1992 while (*valid_resource_chars)
1993 valid_resource_char_p[(unsigned int) (*valid_resource_chars++)] = 1;
1994
1995 name_char_dynarr = Dynarr_new (char);
1996 class_char_dynarr = Dynarr_new (char);
1997 }
1998
1999 void
2000 console_type_create_device_x (void) 1896 console_type_create_device_x (void)
2001 { 1897 {
2002 reinit_console_type_create_device_x ();
2003 CONSOLE_HAS_METHOD (x, init_device); 1898 CONSOLE_HAS_METHOD (x, init_device);
2004 CONSOLE_HAS_METHOD (x, finish_init_device); 1899 CONSOLE_HAS_METHOD (x, finish_init_device);
2005 CONSOLE_HAS_METHOD (x, mark_device); 1900 CONSOLE_HAS_METHOD (x, mark_device);
2006 CONSOLE_HAS_METHOD (x, delete_device); 1901 CONSOLE_HAS_METHOD (x, delete_device);
2007 CONSOLE_HAS_METHOD (x, device_system_metrics); 1902 CONSOLE_HAS_METHOD (x, device_system_metrics);
2008 } 1903
2009 1904 {
2010 void 1905 /* Initialize variables to speed up X resource interactions */
2011 reinit_vars_of_device_x (void) 1906 CONST char *valid_resource_chars =
2012 { 1907 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
2013 error_expected = 0; 1908 while (*valid_resource_chars)
2014 error_occurred = 0; 1909 valid_resource_char_p[(unsigned int) (*valid_resource_chars++)] = 1;
2015 1910
2016 in_resource_setting = 0; 1911 name_char_dynarr = Dynarr_new (char);
1912 class_char_dynarr = Dynarr_new (char);
1913 }
2017 } 1914 }
2018 1915
2019 void 1916 void
2020 vars_of_device_x (void) 1917 vars_of_device_x (void)
2021 { 1918 {
2022 reinit_vars_of_device_x ();
2023
2024 DEFVAR_LISP ("x-emacs-application-class", &Vx_emacs_application_class /* 1919 DEFVAR_LISP ("x-emacs-application-class", &Vx_emacs_application_class /*
2025 The X application class of the XEmacs process. 1920 The X application class of the XEmacs process.
2026 This controls, among other things, the name of the `app-defaults' file 1921 This controls, among other things, the name of the `app-defaults' file
2027 that XEmacs will use. For changes to this variable to take effect, they 1922 that XEmacs will use. For changes to this variable to take effect, they
2028 must be made before the connection to the X server is initialized, that is, 1923 must be made before the connection to the X server is initialized, that is,
2061 1956
2062 Fprovide (Qx); 1957 Fprovide (Qx);
2063 1958
2064 staticpro (&Vdefault_x_device); 1959 staticpro (&Vdefault_x_device);
2065 Vdefault_x_device = Qnil; 1960 Vdefault_x_device = Qnil;
2066 } 1961
1962 error_expected = 0;
1963 error_occurred = 0;
1964
1965 in_resource_setting = 0;
1966 }