Mercurial > hg > xemacs-beta
comparison src/device-x.c @ 440:8de8e3f6228a r21-2-28
Import from CVS: tag r21-2-28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:33:38 +0200 |
parents | a5df635868b2 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
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_DLOPEN) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D) | |
54 #include "sysdll.h" | |
55 #endif /* HAVE_DLOPEN and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */ | |
52 | 56 |
53 #ifdef HAVE_OFFIX_DND | 57 #ifdef HAVE_OFFIX_DND |
54 #include "offix.h" | 58 #include "offix.h" |
55 #endif | 59 #endif |
56 | 60 |
464 Colormap cmap; | 468 Colormap cmap; |
465 int screen; | 469 int screen; |
466 /* */ | 470 /* */ |
467 int best_visual_found = 0; | 471 int best_visual_found = 0; |
468 | 472 |
473 #if defined(HAVE_DLOPEN) && 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_DLOPEN and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */ | |
543 | |
544 | |
469 XSETDEVICE (device, d); | 545 XSETDEVICE (device, d); |
470 display = DEVICE_CONNECTION (d); | 546 display = DEVICE_CONNECTION (d); |
471 | 547 |
472 allocate_x_device_struct (d); | 548 allocate_x_device_struct (d); |
473 | 549 |
474 make_argc_argv (Vx_initial_argv_list, &argc, &argv); | 550 make_argc_argv (Vx_initial_argv_list, &argc, &argv); |
475 | 551 |
476 GET_C_STRING_CTEXT_DATA_ALLOCA (display, disp_name); | 552 TO_EXTERNAL_FORMAT (LISP_STRING, display, |
553 C_STRING_ALLOCA, disp_name, | |
554 Qctext); | |
477 | 555 |
478 /* | 556 /* |
479 * Break apart the old XtOpenDisplay call into XOpenDisplay and | 557 * Break apart the old XtOpenDisplay call into XOpenDisplay and |
480 * XtDisplayInitialize so we can figure out whether there | 558 * XtDisplayInitialize so we can figure out whether there |
481 * are any XEmacs resources in the resource database before | 559 * are any XEmacs resources in the resource database before |
493 signal_simple_error ("X server not responding\n", display); | 571 signal_simple_error ("X server not responding\n", display); |
494 } | 572 } |
495 | 573 |
496 if (STRINGP (Vx_emacs_application_class) && | 574 if (STRINGP (Vx_emacs_application_class) && |
497 XSTRING_LENGTH (Vx_emacs_application_class) > 0) | 575 XSTRING_LENGTH (Vx_emacs_application_class) > 0) |
498 GET_C_STRING_CTEXT_DATA_ALLOCA (Vx_emacs_application_class, app_class); | 576 TO_EXTERNAL_FORMAT (LISP_STRING, Vx_emacs_application_class, |
577 C_STRING_ALLOCA, app_class, | |
578 Qctext); | |
499 else | 579 else |
500 { | 580 { |
501 app_class = (NILP (Vx_emacs_application_class) && | 581 app_class = (NILP (Vx_emacs_application_class) && |
502 have_xemacs_resources_in_xrdb (dpy)) | 582 have_xemacs_resources_in_xrdb (dpy)) |
503 #ifdef INFODOCK | 583 #ifdef INFODOCK |
535 CONST char *locale = XrmLocaleOfDatabase (db); | 615 CONST char *locale = XrmLocaleOfDatabase (db); |
536 | 616 |
537 if (STRINGP (Vx_app_defaults_directory) && | 617 if (STRINGP (Vx_app_defaults_directory) && |
538 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) | 618 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) |
539 { | 619 { |
540 GET_C_STRING_FILENAME_DATA_ALLOCA(Vx_app_defaults_directory, data_dir); | 620 TO_EXTERNAL_FORMAT (LISP_STRING, Vx_app_defaults_directory, |
621 C_STRING_ALLOCA, data_dir, | |
622 Qfile_name); | |
541 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7); | 623 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7); |
542 sprintf (path, "%s%s/Emacs", data_dir, locale); | 624 sprintf (path, "%s%s/Emacs", data_dir, locale); |
543 if (!access (path, R_OK)) | 625 if (!access (path, R_OK)) |
544 XrmCombineFileDatabase (path, &db, False); | 626 XrmCombineFileDatabase (path, &db, False); |
545 } | 627 } |
546 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) | 628 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) |
547 { | 629 { |
548 GET_C_STRING_FILENAME_DATA_ALLOCA (Vdata_directory, data_dir); | 630 TO_EXTERNAL_FORMAT (LISP_STRING, Vdata_directory, |
631 C_STRING_ALLOCA, data_dir, | |
632 Qfile_name); | |
549 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7); | 633 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7); |
550 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale); | 634 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale); |
551 if (!access (path, R_OK)) | 635 if (!access (path, R_OK)) |
552 XrmCombineFileDatabase (path, &db, False); | 636 XrmCombineFileDatabase (path, &db, False); |
553 } | 637 } |
653 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, AllocNone); | 737 cmap = XCreateColormap (dpy, RootWindow (dpy, screen), visual, AllocNone); |
654 } | 738 } |
655 else | 739 else |
656 { | 740 { |
657 /* We have to create a matching colormap anyway... | 741 /* We have to create a matching colormap anyway... |
658 ### think about using standard colormaps (need the Xmu libs?) */ | 742 #### think about using standard colormaps (need the Xmu libs?) */ |
659 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone); | 743 cmap = XCreateColormap(dpy, RootWindow(dpy, screen), visual, AllocNone); |
660 XInstallColormap(dpy, cmap); | 744 XInstallColormap(dpy, cmap); |
661 } | 745 } |
662 } | 746 } |
663 } | 747 } |
728 init_one_device (d); | 812 init_one_device (d); |
729 | 813 |
730 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow(app_shell)); | 814 DEVICE_X_GC_CACHE (d) = make_gc_cache (dpy, XtWindow(app_shell)); |
731 DEVICE_X_GRAY_PIXMAP (d) = None; | 815 DEVICE_X_GRAY_PIXMAP (d) = None; |
732 Xatoms_of_device_x (d); | 816 Xatoms_of_device_x (d); |
733 Xatoms_of_xselect (d); | 817 Xatoms_of_select_x (d); |
734 Xatoms_of_objects_x (d); | 818 Xatoms_of_objects_x (d); |
735 x_init_device_class (d); | 819 x_init_device_class (d); |
736 | 820 |
737 /* Run the elisp side of the X device initialization. */ | 821 /* Run the elisp side of the X device initialization. */ |
738 call0 (Qinit_pre_x_win); | 822 call0 (Qinit_pre_x_win); |
1601 (keysym)) | 1685 (keysym)) |
1602 { | 1686 { |
1603 CONST char *keysym_ext; | 1687 CONST char *keysym_ext; |
1604 | 1688 |
1605 CHECK_STRING (keysym); | 1689 CHECK_STRING (keysym); |
1606 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext); | 1690 TO_EXTERNAL_FORMAT (LISP_STRING, keysym, |
1691 C_STRING_ALLOCA, keysym_ext, | |
1692 Qctext); | |
1607 | 1693 |
1608 return XStringToKeysym (keysym_ext) ? Qt : Qnil; | 1694 return XStringToKeysym (keysym_ext) ? Qt : Qnil; |
1609 } | 1695 } |
1610 | 1696 |
1611 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /* | 1697 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /* |
1612 Return a hash table which contains a hash key for all keysyms which | 1698 Return a hash table containing a key for all keysyms on DEVICE. |
1613 name keys on the keyboard. See `x-keysym-on-keyboard-p'. | 1699 DEVICE must be an X11 display device. See `x-keysym-on-keyboard-p'. |
1614 */ | 1700 */ |
1615 (device)) | 1701 (device)) |
1616 { | 1702 { |
1617 struct device *d = decode_device (device); | 1703 struct device *d = decode_device (device); |
1618 if (!DEVICE_X_P (d)) | 1704 if (!DEVICE_X_P (d)) |
1810 if (!directories) | 1896 if (!directories) |
1811 signal_simple_error ("Can't get X font path", device); | 1897 signal_simple_error ("Can't get X font path", device); |
1812 | 1898 |
1813 while (ndirs_return--) | 1899 while (ndirs_return--) |
1814 font_path = Fcons (build_ext_string (directories[ndirs_return], | 1900 font_path = Fcons (build_ext_string (directories[ndirs_return], |
1815 FORMAT_FILENAME), font_path); | 1901 Qfile_name), |
1902 font_path); | |
1816 | 1903 |
1817 return font_path; | 1904 return font_path; |
1818 } | 1905 } |
1819 | 1906 |
1820 DEFUN ("x-set-font-path", Fx_set_font_path, 1, 2, 0, /* | 1907 DEFUN ("x-set-font-path", Fx_set_font_path, 1, 2, 0, /* |
1846 | 1933 |
1847 directories = alloca_array (CONST char *, ndirs); | 1934 directories = alloca_array (CONST char *, ndirs); |
1848 | 1935 |
1849 EXTERNAL_LIST_LOOP (path_entry, font_path) | 1936 EXTERNAL_LIST_LOOP (path_entry, font_path) |
1850 { | 1937 { |
1851 GET_C_STRING_FILENAME_DATA_ALLOCA (XCAR (path_entry), directories[i++]); | 1938 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (path_entry), |
1939 C_STRING_ALLOCA, directories[i++], | |
1940 Qfile_name); | |
1852 } | 1941 } |
1853 | 1942 |
1854 expect_x_error (dpy); | 1943 expect_x_error (dpy); |
1855 XSetFontPath (dpy, (char **) directories, ndirs); | 1944 XSetFontPath (dpy, (char **) directories, ndirs); |
1856 signal_if_x_error (dpy, 1/*resumable_p*/); | 1945 signal_if_x_error (dpy, 1/*resumable_p*/); |