Mercurial > hg > xemacs-beta
comparison src/device-x.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
18 along with XEmacs; see the file COPYING. If not, write to | 18 along with XEmacs; see the file COPYING. If not, write to |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02111-1307, USA. */ |
21 | 21 |
22 /* Synched up with: Not in FSF. */ | 22 /* Synched up with: Not in FSF. */ |
23 | |
24 /* 7-8-00 !!#### This file needs definite Mule review. */ | |
23 | 25 |
24 /* Original authors: Jamie Zawinski and the FSF */ | 26 /* Original authors: Jamie Zawinski and the FSF */ |
25 /* Rewritten by Ben Wing and Chuck Thompson. */ | 27 /* Rewritten by Ben Wing and Chuck Thompson. */ |
26 | 28 |
27 #include <config.h> | 29 #include <config.h> |
48 #include "window.h" | 50 #include "window.h" |
49 | 51 |
50 #include "sysfile.h" | 52 #include "sysfile.h" |
51 #include "systime.h" | 53 #include "systime.h" |
52 | 54 |
53 #if defined(HAVE_DLOPEN) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D) | 55 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D) |
54 #include "sysdll.h" | 56 #include "sysdll.h" |
55 #endif /* HAVE_DLOPEN and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */ | 57 #endif /* HAVE_SHLIB and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */ |
56 | 58 |
57 #ifdef HAVE_OFFIX_DND | 59 #ifdef HAVE_OFFIX_DND |
58 #include "offix.h" | 60 #include "offix.h" |
59 #endif | 61 #endif |
60 | 62 |
244 * I have removed the gratuitous use of getenv("RESOURCE_NAME") | 246 * I have removed the gratuitous use of getenv("RESOURCE_NAME") |
245 * which was in X11R5, but left the matching of any prefix of `-name'. | 247 * which was in X11R5, but left the matching of any prefix of `-name'. |
246 * Finally, if all else fails, return `xemacs', as it is more | 248 * Finally, if all else fails, return `xemacs', as it is more |
247 * appropriate (X11R5 returns `main'). | 249 * appropriate (X11R5 returns `main'). |
248 */ | 250 */ |
249 static char * | 251 static Extbyte * |
250 compute_x_app_name (int argc, char **argv) | 252 compute_x_app_name (int argc, Extbyte **argv) |
251 { | 253 { |
252 int i; | 254 int i; |
253 char *ptr; | 255 Extbyte *ptr; |
254 | 256 |
255 for (i = 1; i < argc - 1; i++) | 257 for (i = 1; i < argc - 1; i++) |
256 if (!strncmp(argv[i], "-name", max (2, strlen (argv[1])))) | 258 if (!strncmp(argv[i], "-name", max (2, strlen (argv[1])))) |
257 return argv[i+1]; | 259 return argv[i+1]; |
258 | 260 |
457 Lisp_Object display; | 459 Lisp_Object display; |
458 Lisp_Object device; | 460 Lisp_Object device; |
459 Display *dpy; | 461 Display *dpy; |
460 Widget app_shell; | 462 Widget app_shell; |
461 int argc; | 463 int argc; |
462 char **argv; | 464 Extbyte **argv; |
463 CONST char *app_class; | 465 const char *app_class; |
464 CONST char *app_name; | 466 const char *app_name; |
465 CONST char *disp_name; | 467 const char *disp_name; |
466 Visual *visual = NULL; | 468 Visual *visual = NULL; |
467 int depth = 8; /* shut up the compiler */ | 469 int depth = 8; /* shut up the compiler */ |
468 Colormap cmap; | 470 Colormap cmap; |
469 int screen; | 471 int screen; |
470 /* */ | 472 /* */ |
471 int best_visual_found = 0; | 473 int best_visual_found = 0; |
472 | 474 |
473 #if defined(HAVE_DLOPEN) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D) | 475 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D) |
474 /* | 476 /* |
475 * In order to avoid the lossage with flat Athena widgets dynamically | 477 * In order to avoid the lossage with flat Athena widgets dynamically |
476 * linking to one of the ThreeD variants, using the dynamic symbol helpers | 478 * 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 | 479 * 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 | 480 * are seems a less toxic idea than having XEmacs crash when we try and |
537 * No error catch here; I can't think of a way to recover anyhow. | 539 * No error catch here; I can't think of a way to recover anyhow. |
538 */ | 540 */ |
539 dll_close (xaw_dll_handle); | 541 dll_close (xaw_dll_handle); |
540 } | 542 } |
541 } | 543 } |
542 #endif /* HAVE_DLOPEN and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */ | 544 #endif /* HAVE_SHLIB and LWLIB_USES_ATHENA and not HAVE_ATHENA_3D */ |
543 | 545 |
544 | 546 |
545 XSETDEVICE (device, d); | 547 XSETDEVICE (device, d); |
546 display = DEVICE_CONNECTION (d); | 548 display = DEVICE_CONNECTION (d); |
547 | 549 |
548 allocate_x_device_struct (d); | 550 allocate_x_device_struct (d); |
549 | 551 |
550 make_argc_argv (Vx_initial_argv_list, &argc, &argv); | 552 make_argc_argv (Vx_initial_argv_list, &argc, &argv); |
551 | 553 |
552 TO_EXTERNAL_FORMAT (LISP_STRING, display, | 554 LISP_STRING_TO_EXTERNAL (display, disp_name, Qctext); |
553 C_STRING_ALLOCA, disp_name, | |
554 Qctext); | |
555 | 555 |
556 /* | 556 /* |
557 * Break apart the old XtOpenDisplay call into XOpenDisplay and | 557 * Break apart the old XtOpenDisplay call into XOpenDisplay and |
558 * XtDisplayInitialize so we can figure out whether there | 558 * XtDisplayInitialize so we can figure out whether there |
559 * are any XEmacs resources in the resource database before | 559 * are any XEmacs resources in the resource database before |
571 signal_simple_error ("X server not responding\n", display); | 571 signal_simple_error ("X server not responding\n", display); |
572 } | 572 } |
573 | 573 |
574 if (STRINGP (Vx_emacs_application_class) && | 574 if (STRINGP (Vx_emacs_application_class) && |
575 XSTRING_LENGTH (Vx_emacs_application_class) > 0) | 575 XSTRING_LENGTH (Vx_emacs_application_class) > 0) |
576 TO_EXTERNAL_FORMAT (LISP_STRING, Vx_emacs_application_class, | 576 LISP_STRING_TO_EXTERNAL (Vx_emacs_application_class, app_class, Qctext); |
577 C_STRING_ALLOCA, app_class, | |
578 Qctext); | |
579 else | 577 else |
580 { | 578 { |
581 app_class = (NILP (Vx_emacs_application_class) && | 579 app_class = (NILP (Vx_emacs_application_class) && |
582 have_xemacs_resources_in_xrdb (dpy)) | 580 have_xemacs_resources_in_xrdb (dpy)) |
583 #ifdef INFODOCK | 581 #ifdef INFODOCK |
593 slow_down_interrupts (); | 591 slow_down_interrupts (); |
594 /* May not be needed but XtOpenDisplay could not deal with signals here. | 592 /* May not be needed but XtOpenDisplay could not deal with signals here. |
595 Yuck. */ | 593 Yuck. */ |
596 XtDisplayInitialize (Xt_app_con, dpy, compute_x_app_name (argc, argv), | 594 XtDisplayInitialize (Xt_app_con, dpy, compute_x_app_name (argc, argv), |
597 app_class, emacs_options, | 595 app_class, emacs_options, |
598 XtNumber (emacs_options), &argc, argv); | 596 XtNumber (emacs_options), &argc, (char **) argv); |
599 speed_up_interrupts (); | 597 speed_up_interrupts (); |
600 | 598 |
601 screen = DefaultScreen (dpy); | 599 screen = DefaultScreen (dpy); |
602 if (NILP (Vdefault_x_device)) | 600 if (NILP (Vdefault_x_device)) |
603 Vdefault_x_device = device; | 601 Vdefault_x_device = device; |
607 { | 605 { |
608 /* Read in locale-specific resources from | 606 /* Read in locale-specific resources from |
609 data-directory/app-defaults/$LANG/Emacs. | 607 data-directory/app-defaults/$LANG/Emacs. |
610 This is in addition to the standard app-defaults files, and | 608 This is in addition to the standard app-defaults files, and |
611 does not override resources defined elsewhere */ | 609 does not override resources defined elsewhere */ |
612 CONST char *data_dir; | 610 const char *data_dir; |
613 char *path; | 611 char *path; |
614 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */ | 612 XrmDatabase db = XtDatabase (dpy); /* #### XtScreenDatabase(dpy) ? */ |
615 CONST char *locale = XrmLocaleOfDatabase (db); | 613 const char *locale = XrmLocaleOfDatabase (db); |
616 | 614 |
617 if (STRINGP (Vx_app_defaults_directory) && | 615 if (STRINGP (Vx_app_defaults_directory) && |
618 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) | 616 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) |
619 { | 617 { |
620 TO_EXTERNAL_FORMAT (LISP_STRING, Vx_app_defaults_directory, | 618 LISP_STRING_TO_EXTERNAL (Vx_app_defaults_directory, data_dir, Qfile_name); |
621 C_STRING_ALLOCA, data_dir, | |
622 Qfile_name); | |
623 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7); | 619 path = (char *)alloca (strlen (data_dir) + strlen (locale) + 7); |
624 sprintf (path, "%s%s/Emacs", data_dir, locale); | 620 sprintf (path, "%s%s/Emacs", data_dir, locale); |
625 if (!access (path, R_OK)) | 621 if (!access (path, R_OK)) |
626 XrmCombineFileDatabase (path, &db, False); | 622 XrmCombineFileDatabase (path, &db, False); |
627 } | 623 } |
628 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) | 624 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) |
629 { | 625 { |
630 TO_EXTERNAL_FORMAT (LISP_STRING, Vdata_directory, | 626 LISP_STRING_TO_EXTERNAL (Vdata_directory, data_dir, Qfile_name); |
631 C_STRING_ALLOCA, data_dir, | |
632 Qfile_name); | |
633 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7); | 627 path = (char *)alloca (strlen (data_dir) + 13 + strlen (locale) + 7); |
634 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale); | 628 sprintf (path, "%sapp-defaults/%s/Emacs", data_dir, locale); |
635 if (!access (path, R_OK)) | 629 if (!access (path, R_OK)) |
636 XrmCombineFileDatabase (path, &db, False); | 630 XrmCombineFileDatabase (path, &db, False); |
637 } | 631 } |
783 } | 777 } |
784 | 778 |
785 #ifdef HAVE_WMCOMMAND | 779 #ifdef HAVE_WMCOMMAND |
786 { | 780 { |
787 int new_argc; | 781 int new_argc; |
788 char **new_argv; | 782 Extbyte **new_argv; |
789 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv); | 783 make_argc_argv (Vcommand_line_args, &new_argc, &new_argv); |
790 XSetCommand (XtDisplay (app_shell), XtWindow (app_shell), new_argv, new_argc); | 784 XSetCommand (XtDisplay (app_shell), XtWindow (app_shell), |
785 (char **) new_argv, new_argc); | |
791 free_argc_argv (new_argv); | 786 free_argc_argv (new_argv); |
792 } | 787 } |
793 #endif /* HAVE_WMCOMMAND */ | 788 #endif /* HAVE_WMCOMMAND */ |
794 | 789 |
795 | 790 |
911 | 906 |
912 /************************************************************************/ | 907 /************************************************************************/ |
913 /* handle X errors */ | 908 /* handle X errors */ |
914 /************************************************************************/ | 909 /************************************************************************/ |
915 | 910 |
916 CONST char * | 911 const char * |
917 x_event_name (int event_type) | 912 x_event_name (int event_type) |
918 { | 913 { |
919 static CONST char *events[] = | 914 static const char *events[] = |
920 { | 915 { |
921 "0: ERROR!", | 916 "0: ERROR!", |
922 "1: REPLY", | 917 "1: REPLY", |
923 "KeyPress", | 918 "KeyPress", |
924 "KeyRelease", | 919 "KeyRelease", |
1257 } | 1252 } |
1258 } | 1253 } |
1259 | 1254 |
1260 #endif /* 0 */ | 1255 #endif /* 0 */ |
1261 | 1256 |
1257 /* strcasecmp() is not sufficiently portable or standard, | |
1258 and it's easier just to write our own. */ | |
1259 static int | |
1260 ascii_strcasecmp (const char *s1, const char *s2) | |
1261 { | |
1262 while (1) | |
1263 { | |
1264 char c1 = *s1++; | |
1265 char c2 = *s2++; | |
1266 if (c1 >= 'A' && c1 <= 'Z') c1 += 'a' - 'A'; | |
1267 if (c2 >= 'A' && c2 <= 'Z') c2 += 'a' - 'A'; | |
1268 if (c1 != c2) return c1 - c2; | |
1269 if (c1 == '\0') return 0; | |
1270 } | |
1271 } | |
1272 | |
1262 static char_dynarr *name_char_dynarr; | 1273 static char_dynarr *name_char_dynarr; |
1263 static char_dynarr *class_char_dynarr; | 1274 static char_dynarr *class_char_dynarr; |
1264 | 1275 |
1265 /* Given a locale and device specification from x-get-resource or | 1276 /* Given a locale and device specification from x-get-resource or |
1266 x-get-resource-prefix, return the resource prefix and display to | 1277 x-get-resource-prefix, return the resource prefix and display to |
1360 LOCALE, if a device can be derived (i.e. if LOCALE is a frame or device), | 1371 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'. | 1372 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 | 1373 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 | 1374 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 | 1375 given when an integer was requested). In this case, a warning is issued |
1365 instead. | 1376 instead, unless NOERROR is t, in which case no warning is issued. |
1366 | 1377 |
1367 The resource names passed to this function are looked up relative to the | 1378 The resource names passed to this function are looked up relative to the |
1368 locale. | 1379 locale. |
1369 | 1380 |
1370 If you want to search for a subresource, you just need to specify the | 1381 If you want to search for a subresource, you just need to specify the |
1483 | 1494 |
1484 if (EQ (type, Qstring)) | 1495 if (EQ (type, Qstring)) |
1485 return build_string (raw_result); | 1496 return build_string (raw_result); |
1486 else if (EQ (type, Qboolean)) | 1497 else if (EQ (type, Qboolean)) |
1487 { | 1498 { |
1488 if (!strcasecmp (raw_result, "off") || | 1499 if (!ascii_strcasecmp (raw_result, "off") || |
1489 !strcasecmp (raw_result, "false") || | 1500 !ascii_strcasecmp (raw_result, "false") || |
1490 !strcasecmp (raw_result, "no")) | 1501 !ascii_strcasecmp (raw_result, "no")) |
1491 return Fcons (Qnil, Qnil); | 1502 return Fcons (Qnil, Qnil); |
1492 if (!strcasecmp (raw_result, "on") || | 1503 if (!ascii_strcasecmp (raw_result, "on") || |
1493 !strcasecmp (raw_result, "true") || | 1504 !ascii_strcasecmp (raw_result, "true") || |
1494 !strcasecmp (raw_result, "yes")) | 1505 !ascii_strcasecmp (raw_result, "yes")) |
1495 return Fcons (Qt, Qnil); | 1506 return Fcons (Qt, Qnil); |
1496 return maybe_continuable_error | 1507 return maybe_continuable_error |
1497 (Qresource, errb, | 1508 (Qresource, errb, |
1498 "can't convert %s: %s to a Boolean", name_string, raw_result); | 1509 "can't convert %s: %s to a Boolean", name_string, raw_result); |
1499 } | 1510 } |
1682 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in | 1693 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. | 1694 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system. |
1684 */ | 1695 */ |
1685 (keysym)) | 1696 (keysym)) |
1686 { | 1697 { |
1687 CONST char *keysym_ext; | 1698 const char *keysym_ext; |
1688 | 1699 |
1689 CHECK_STRING (keysym); | 1700 CHECK_STRING (keysym); |
1690 TO_EXTERNAL_FORMAT (LISP_STRING, keysym, | 1701 LISP_STRING_TO_EXTERNAL (keysym, keysym_ext, Qctext); |
1691 C_STRING_ALLOCA, keysym_ext, | |
1692 Qctext); | |
1693 | 1702 |
1694 return XStringToKeysym (keysym_ext) ? Qt : Qnil; | 1703 return XStringToKeysym (keysym_ext) ? Qt : Qnil; |
1695 } | 1704 } |
1696 | 1705 |
1697 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /* | 1706 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /* |
1888 */ | 1897 */ |
1889 (device)) | 1898 (device)) |
1890 { | 1899 { |
1891 Display *dpy = get_x_display (device); | 1900 Display *dpy = get_x_display (device); |
1892 int ndirs_return; | 1901 int ndirs_return; |
1893 CONST char **directories = (CONST char **) XGetFontPath (dpy, &ndirs_return); | 1902 const char **directories = (const char **) XGetFontPath (dpy, &ndirs_return); |
1894 Lisp_Object font_path = Qnil; | 1903 Lisp_Object font_path = Qnil; |
1895 | 1904 |
1896 if (!directories) | 1905 if (!directories) |
1897 signal_simple_error ("Can't get X font path", device); | 1906 signal_simple_error ("Can't get X font path", device); |
1898 | 1907 |
1920 */ | 1929 */ |
1921 (font_path, device)) | 1930 (font_path, device)) |
1922 { | 1931 { |
1923 Display *dpy = get_x_display (device); | 1932 Display *dpy = get_x_display (device); |
1924 Lisp_Object path_entry; | 1933 Lisp_Object path_entry; |
1925 CONST char **directories; | 1934 const char **directories; |
1926 int i=0,ndirs=0; | 1935 int i=0,ndirs=0; |
1927 | 1936 |
1928 EXTERNAL_LIST_LOOP (path_entry, font_path) | 1937 EXTERNAL_LIST_LOOP (path_entry, font_path) |
1929 { | 1938 { |
1930 CHECK_STRING (XCAR (path_entry)); | 1939 CHECK_STRING (XCAR (path_entry)); |
1931 ndirs++; | 1940 ndirs++; |
1932 } | 1941 } |
1933 | 1942 |
1934 directories = alloca_array (CONST char *, ndirs); | 1943 directories = alloca_array (const char *, ndirs); |
1935 | 1944 |
1936 EXTERNAL_LIST_LOOP (path_entry, font_path) | 1945 EXTERNAL_LIST_LOOP (path_entry, font_path) |
1937 { | 1946 { |
1938 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (path_entry), | 1947 LISP_STRING_TO_EXTERNAL (XCAR (path_entry), directories[i++], Qfile_name); |
1939 C_STRING_ALLOCA, directories[i++], | |
1940 Qfile_name); | |
1941 } | 1948 } |
1942 | 1949 |
1943 expect_x_error (dpy); | 1950 expect_x_error (dpy); |
1944 XSetFontPath (dpy, (char **) directories, ndirs); | 1951 XSetFontPath (dpy, (char **) directories, ndirs); |
1945 signal_if_x_error (dpy, 1/*resumable_p*/); | 1952 signal_if_x_error (dpy, 1/*resumable_p*/); |
1985 | 1992 |
1986 void | 1993 void |
1987 reinit_console_type_create_device_x (void) | 1994 reinit_console_type_create_device_x (void) |
1988 { | 1995 { |
1989 /* Initialize variables to speed up X resource interactions */ | 1996 /* Initialize variables to speed up X resource interactions */ |
1990 CONST char *valid_resource_chars = | 1997 const char *valid_resource_chars = |
1991 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; | 1998 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; |
1992 while (*valid_resource_chars) | 1999 while (*valid_resource_chars) |
1993 valid_resource_char_p[(unsigned int) (*valid_resource_chars++)] = 1; | 2000 valid_resource_char_p[(unsigned int) (*valid_resource_chars++)] = 1; |
1994 | 2001 |
1995 name_char_dynarr = Dynarr_new (char); | 2002 name_char_dynarr = Dynarr_new (char); |