comparison src/device-x.c @ 5125:b5df3737028a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 01:58:04 -0600
parents d1247f3cc363 3c3c1d139863
children 2a462149bd6a
comparison
equal deleted inserted replaced
5124:623d57b7fbe8 5125:b5df3737028a
51 51
52 #include "xintrinsicp.h" /* CoreP.h needs this */ 52 #include "xintrinsicp.h" /* CoreP.h needs this */
53 #include <X11/CoreP.h> /* Numerous places access the fields of 53 #include <X11/CoreP.h> /* Numerous places access the fields of
54 a core widget directly. We could 54 a core widget directly. We could
55 use XtGetValues(), but ... */ 55 use XtGetValues(), but ... */
56 #include "xgccache.h" 56 #include "gccache-x.h"
57 #include <X11/Shell.h> 57 #include <X11/Shell.h>
58 #include <X11/Xmu/Error.h> 58 #include <X11/Xmu/Error.h>
59 59
60 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D) 60 #if defined(HAVE_SHLIB) && defined(LWLIB_USES_ATHENA) && !defined(HAVE_ATHENA_3D)
61 #include "sysdll.h" 61 #include "sysdll.h"
206 } 206 }
207 207
208 last_xrm_db = db; 208 last_xrm_db = db;
209 209
210 locale = XrmLocaleOfDatabase (db); 210 locale = XrmLocaleOfDatabase (db);
211 localestr = build_ext_string (locale, Qbinary); 211 localestr = build_extstring (locale, Qbinary);
212 last_coding_system = call1 (Qget_coding_system_from_locale, localestr); 212 last_coding_system = call1 (Qget_coding_system_from_locale, localestr);
213 213
214 return last_coding_system; 214 return last_coding_system;
215 #else 215 #else
216 return Qbinary; 216 return Qbinary;
261 strcat (buf2, "._no_._such_._resource_.Geometry"); 261 strcat (buf2, "._no_._such_._resource_.Geometry");
262 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True) 262 if (XrmGetResource (XtDatabase (dpy), buf1, buf2, &type, &value) == True)
263 { 263 {
264 Ibyte *app_name_int, *app_class_int, *value_addr_int; 264 Ibyte *app_name_int, *app_class_int, *value_addr_int;
265 Lisp_Object codesys = coding_system_of_xrm_database (XtDatabase (dpy)); 265 Lisp_Object codesys = coding_system_of_xrm_database (XtDatabase (dpy));
266 EXTERNAL_TO_C_STRING (app_name, app_name_int, codesys); 266 app_name_int = EXTERNAL_TO_ITEXT (app_name, codesys);
267 EXTERNAL_TO_C_STRING (app_class, app_class_int, codesys); 267 app_class_int = EXTERNAL_TO_ITEXT (app_class, codesys);
268 EXTERNAL_TO_C_STRING (value.addr, value_addr_int, codesys); 268 value_addr_int = EXTERNAL_TO_ITEXT (value.addr, codesys);
269 269
270 warn_when_safe (Qgeometry, Qerror, 270 warn_when_safe (Qgeometry, Qerror,
271 "\n" 271 "\n"
272 "Apparently \"%s*geometry: %s\" or \"%s*geometry: %s\" was\n" 272 "Apparently \"%s*geometry: %s\" or \"%s*geometry: %s\" was\n"
273 "specified in the resource database. Specifying \"*geometry\" will make\n" 273 "specified in the resource database. Specifying \"*geometry\" will make\n"
385 Dynarr_add_validified_lisp_string (Extbyte_dynarr *cda, Lisp_Object str) 385 Dynarr_add_validified_lisp_string (Extbyte_dynarr *cda, Lisp_Object str)
386 { 386 {
387 Bytecount len; 387 Bytecount len;
388 Extbyte *data; 388 Extbyte *data;
389 389
390 TO_EXTERNAL_FORMAT (LISP_STRING, str, ALLOCA, (data, len), Qbinary); 390 LISP_STRING_TO_SIZED_EXTERNAL (str, data, len, Qbinary);
391 Dynarr_add_many (cda, data, len); 391 Dynarr_add_many (cda, data, len);
392 validify_resource_component (Dynarr_atp (cda, Dynarr_length (cda) - len), 392 validify_resource_component (Dynarr_atp (cda, Dynarr_length (cda) - len),
393 len); 393 len);
394 } 394 }
395 395
581 */ 581 */
582 if (xaw_dll_handle != NULL) 582 if (xaw_dll_handle != NULL)
583 { 583 {
584 /* Look for the Xaw3d function */ 584 /* Look for the Xaw3d function */
585 dll_func xaw_function_handle = 585 dll_func xaw_function_handle =
586 dll_function (xaw_dll_handle, "Xaw3dComputeTopShadowRGB"); 586 dll_function (xaw_dll_handle,
587 (const Ibyte *) "Xaw3dComputeTopShadowRGB");
587 588
588 /* If we found it, warn the user in big, nasty, unfriendly letters */ 589 /* If we found it, warn the user in big, nasty, unfriendly letters */
589 if (xaw_function_handle != NULL) 590 if (xaw_function_handle != NULL)
590 { 591 {
591 warn_when_safe (Qdevice, Qcritical, "\n" 592 warn_when_safe (Qdevice, Qcritical, "\n"
619 620
620 allocate_x_device_struct (d); 621 allocate_x_device_struct (d);
621 622
622 make_argc_argv (Vx_initial_argv_list, &argc, &argv); 623 make_argc_argv (Vx_initial_argv_list, &argc, &argv);
623 624
624 LISP_STRING_TO_EXTERNAL (display, disp_name, Qctext); 625 disp_name = LISP_STRING_TO_EXTERNAL (display, Qctext);
625 626
626 /* 627 /*
627 * Break apart the old XtOpenDisplay call into XOpenDisplay and 628 * Break apart the old XtOpenDisplay call into XOpenDisplay and
628 * XtDisplayInitialize so we can figure out whether there 629 * XtDisplayInitialize so we can figure out whether there
629 * are any XEmacs resources in the resource database before 630 * are any XEmacs resources in the resource database before
643 gui_error ("X server not responding\n", display); 644 gui_error ("X server not responding\n", display);
644 } 645 }
645 646
646 if (STRINGP (Vx_emacs_application_class) && 647 if (STRINGP (Vx_emacs_application_class) &&
647 XSTRING_LENGTH (Vx_emacs_application_class) > 0) 648 XSTRING_LENGTH (Vx_emacs_application_class) > 0)
648 LISP_STRING_TO_EXTERNAL (Vx_emacs_application_class, app_class, Qctext); 649 app_class = LISP_STRING_TO_EXTERNAL (Vx_emacs_application_class, Qctext);
649 else 650 else
650 { 651 {
651 if (egetenv ("USE_EMACS_AS_DEFAULT_APPLICATION_CLASS")) 652 if (egetenv ("USE_EMACS_AS_DEFAULT_APPLICATION_CLASS"))
652 { 653 {
653 app_class = (NILP (Vx_emacs_application_class) && 654 app_class = (NILP (Vx_emacs_application_class) &&
663 { 664 {
664 app_class = "XEmacs"; 665 app_class = "XEmacs";
665 } 666 }
666 667
667 /* need to update Vx_emacs_application_class: */ 668 /* need to update Vx_emacs_application_class: */
668 Vx_emacs_application_class = build_string (app_class); 669 Vx_emacs_application_class = build_cistring (app_class);
669 } 670 }
670 671
671 slow_down_interrupts (); 672 slow_down_interrupts ();
672 /* May not be needed but XtOpenDisplay could not deal with signals here. 673 /* May not be needed but XtOpenDisplay could not deal with signals here.
673 Yuck. */ 674 Yuck. */
692 Extbyte *locale_end; 693 Extbyte *locale_end;
693 694
694 if (STRINGP (Vx_app_defaults_directory) && 695 if (STRINGP (Vx_app_defaults_directory) &&
695 XSTRING_LENGTH (Vx_app_defaults_directory) > 0) 696 XSTRING_LENGTH (Vx_app_defaults_directory) > 0)
696 { 697 {
697 LISP_STRING_TO_EXTERNAL (Vx_app_defaults_directory, data_dir, 698 LISP_PATHNAME_CONVERT_OUT (Vx_app_defaults_directory, data_dir);
698 Qfile_name);
699 path = alloca_extbytes (strlen (data_dir) + strlen (locale) + 7); 699 path = alloca_extbytes (strlen (data_dir) + strlen (locale) + 7);
700 format = "%s%s/Emacs"; 700 format = "%s%s/Emacs";
701 } 701 }
702 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) 702 else if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0)
703 { 703 {
704 LISP_STRING_TO_EXTERNAL (Vdata_directory, data_dir, Qfile_name); 704 LISP_PATHNAME_CONVERT_OUT (Vdata_directory, data_dir);
705 path = alloca_extbytes (strlen (data_dir) + 13 + strlen (locale) + 7); 705 path = alloca_extbytes (strlen (data_dir) + 13 + strlen (locale) + 7);
706 format = "%sapp-defaults/%s/Emacs"; 706 format = "%sapp-defaults/%s/Emacs";
707 } 707 }
708 else 708 else
709 { 709 {
738 738
739 no_data_directory: 739 no_data_directory:
740 { 740 {
741 /* Cast off const for G++ 4.3. */ 741 /* Cast off const for G++ 4.3. */
742 Extbyte *temp = (Extbyte *) locale; 742 Extbyte *temp = (Extbyte *) locale;
743 xfree (temp, Extbyte*); 743 xfree (temp);
744 } 744 }
745 } 745 }
746 #endif /* MULE */ 746 #endif /* MULE */
747 747
748 if (NILP (DEVICE_NAME (d))) 748 if (NILP (DEVICE_NAME (d)))
946 946
947 #ifndef NEW_GC 947 #ifndef NEW_GC
948 static void 948 static void
949 free_x_device_struct (struct device *d) 949 free_x_device_struct (struct device *d)
950 { 950 {
951 xfree (d->device_data, void *); 951 xfree (d->device_data);
952 } 952 }
953 #endif /* not NEW_GC */ 953 #endif /* not NEW_GC */
954 954
955 static void 955 static void
956 x_delete_device (struct device *d) 956 x_delete_device (struct device *d)
1001 1001
1002 /************************************************************************/ 1002 /************************************************************************/
1003 /* handle X errors */ 1003 /* handle X errors */
1004 /************************************************************************/ 1004 /************************************************************************/
1005 1005
1006 const char * 1006 const Ascbyte *
1007 x_event_name (int event_type) 1007 x_event_name (int event_type)
1008 { 1008 {
1009 static const char *events[] = 1009 static const Ascbyte *events[] =
1010 { 1010 {
1011 "0: ERROR!", 1011 "0: ERROR!",
1012 "1: REPLY", 1012 "1: REPLY",
1013 "KeyPress", 1013 "KeyPress",
1014 "KeyRelease", 1014 "KeyRelease",
1194 Lisp_Object data; 1194 Lisp_Object data;
1195 if (! x_error_occurred_p (dpy)) 1195 if (! x_error_occurred_p (dpy))
1196 return 0; 1196 return 0;
1197 data = Qnil; 1197 data = Qnil;
1198 qxesprintf (num, "0x%X", (unsigned int) last_error.resourceid); 1198 qxesprintf (num, "0x%X", (unsigned int) last_error.resourceid);
1199 data = Fcons (build_intstring (num), data); 1199 data = Fcons (build_istring (num), data);
1200 qxesprintf (num, "%d", last_error.request_code); 1200 qxesprintf (num, "%d", last_error.request_code);
1201 XGetErrorDatabaseText (last_error.display, "XRequest", (char *) num, "", 1201 XGetErrorDatabaseText (last_error.display, "XRequest", (char *) num, "",
1202 buf, sizeof (buf)); 1202 buf, sizeof (buf));
1203 if (*buf) 1203 if (*buf)
1204 data = Fcons (build_ext_string (buf, Qnative), data); 1204 data = Fcons (build_extstring (buf, Qx_error_message_encoding), data);
1205 else 1205 else
1206 { 1206 {
1207 qxesprintf (num, "Request-%d", last_error.request_code); 1207 qxesprintf (num, "Request-%d", last_error.request_code);
1208 data = Fcons (build_intstring (num), data); 1208 data = Fcons (build_istring (num), data);
1209 } 1209 }
1210 XGetErrorText (last_error.display, last_error.error_code, buf, sizeof (buf)); 1210 XGetErrorText (last_error.display, last_error.error_code, buf, sizeof (buf));
1211 data = Fcons (build_ext_string (buf, Qnative), data); 1211 data = Fcons (build_extstring (buf, Qx_error_message_encoding), data);
1212 again: 1212 again:
1213 Fsignal (Qx_error, data); 1213 Fsignal (Qx_error, data);
1214 if (! resumable_p) goto again; 1214 if (! resumable_p) goto again;
1215 return 1; 1215 return 1;
1216 } 1216 }
1423 XtGetApplicationNameAndClass (*display_out, &appname, &appclass); 1423 XtGetApplicationNameAndClass (*display_out, &appname, &appclass);
1424 name_len = strlen (appname); 1424 name_len = strlen (appname);
1425 class_len = strlen (appclass); 1425 class_len = strlen (appclass);
1426 Dynarr_add_many (name, appname, name_len); 1426 Dynarr_add_many (name, appname, name_len);
1427 Dynarr_add_many (class_, appclass, class_len); 1427 Dynarr_add_many (class_, appclass, class_len);
1428 validify_resource_component (Dynarr_atp (name, 0), name_len); 1428 validify_resource_component (Dynarr_begin (name), name_len);
1429 validify_resource_component (Dynarr_atp (class_, 0), class_len); 1429 validify_resource_component (Dynarr_begin (class_), class_len);
1430 } 1430 }
1431 1431
1432 if (EQ (locale, Qglobal)) 1432 if (EQ (locale, Qglobal))
1433 return; 1433 return;
1434 if (BUFFERP (locale)) 1434 if (BUFFERP (locale))
1566 Dynarr_add (class_Extbyte_dynarr, '.'); 1566 Dynarr_add (class_Extbyte_dynarr, '.');
1567 Dynarr_add_lisp_string (class_Extbyte_dynarr, class_, Qbinary); 1567 Dynarr_add_lisp_string (class_Extbyte_dynarr, class_, Qbinary);
1568 Dynarr_add (name_Extbyte_dynarr, '\0'); 1568 Dynarr_add (name_Extbyte_dynarr, '\0');
1569 Dynarr_add (class_Extbyte_dynarr, '\0'); 1569 Dynarr_add (class_Extbyte_dynarr, '\0');
1570 1570
1571 name_string = Dynarr_atp (name_Extbyte_dynarr, 0); 1571 name_string = Dynarr_begin (name_Extbyte_dynarr);
1572 class_string = Dynarr_atp (class_Extbyte_dynarr, 0); 1572 class_string = Dynarr_begin (class_Extbyte_dynarr);
1573 1573
1574 { 1574 {
1575 XrmValue xrm_value; 1575 XrmValue xrm_value;
1576 XrmName namelist[100]; 1576 XrmName namelist[100];
1577 XrmClass classlist[100]; 1577 XrmClass classlist[100];
1601 return Qnil; 1601 return Qnil;
1602 raw_result = (Extbyte *) xrm_value.addr; 1602 raw_result = (Extbyte *) xrm_value.addr;
1603 } 1603 }
1604 1604
1605 if (EQ (type, Qstring)) 1605 if (EQ (type, Qstring))
1606 return build_ext_string (raw_result, codesys); 1606 return build_extstring (raw_result, codesys);
1607 else if (EQ (type, Qboolean)) 1607 else if (EQ (type, Qboolean))
1608 { 1608 {
1609 if (!strcasecmp (raw_result, "off") || 1609 if (!strcasecmp (raw_result, "off") ||
1610 !strcasecmp (raw_result, "false") || 1610 !strcasecmp (raw_result, "false") ||
1611 !strcasecmp (raw_result, "no")) 1611 !strcasecmp (raw_result, "no"))
1614 !strcasecmp (raw_result, "true") || 1614 !strcasecmp (raw_result, "true") ||
1615 !strcasecmp (raw_result, "yes")) 1615 !strcasecmp (raw_result, "yes"))
1616 return Fcons (Qt, Qnil); 1616 return Fcons (Qt, Qnil);
1617 return maybe_signal_continuable_error_2 1617 return maybe_signal_continuable_error_2
1618 (Qinvalid_operation, "Can't convert to a Boolean", 1618 (Qinvalid_operation, "Can't convert to a Boolean",
1619 build_ext_string (name_string, Qbinary), 1619 build_extstring (name_string, Qbinary),
1620 build_ext_string (raw_result, codesys), Qresource, 1620 build_extstring (raw_result, codesys), Qresource,
1621 errb); 1621 errb);
1622 } 1622 }
1623 else if (EQ (type, Qinteger) || EQ (type, Qnatnum)) 1623 else if (EQ (type, Qinteger) || EQ (type, Qnatnum))
1624 { 1624 {
1625 int i; 1625 int i;
1626 char c; 1626 char c;
1627 if (1 != sscanf (raw_result, "%d%c", &i, &c)) 1627 if (1 != sscanf (raw_result, "%d%c", &i, &c))
1628 return maybe_signal_continuable_error_2 1628 return maybe_signal_continuable_error_2
1629 (Qinvalid_operation, "Can't convert to an integer", 1629 (Qinvalid_operation, "Can't convert to an integer",
1630 build_ext_string (name_string, Qbinary), 1630 build_extstring (name_string, Qbinary),
1631 build_ext_string (raw_result, codesys), Qresource, 1631 build_extstring (raw_result, codesys), Qresource,
1632 errb); 1632 errb);
1633 else if (EQ (type, Qnatnum) && i < 0) 1633 else if (EQ (type, Qnatnum) && i < 0)
1634 return maybe_signal_continuable_error_2 1634 return maybe_signal_continuable_error_2
1635 (Qinvalid_argument, "Invalid numerical value for resource", 1635 (Qinvalid_argument, "Invalid numerical value for resource",
1636 make_int (i), build_ext_string (name_string, Qbinary), 1636 make_int (i), build_extstring (name_string, Qbinary),
1637 Qresource, errb); 1637 Qresource, errb);
1638 else 1638 else
1639 return make_int (i); 1639 return make_int (i);
1640 } 1640 }
1641 else 1641 else
1666 x_get_resource_prefix (locale, device, &display, 1666 x_get_resource_prefix (locale, device, &display,
1667 name_Extbyte_dynarr, class_Extbyte_dynarr); 1667 name_Extbyte_dynarr, class_Extbyte_dynarr);
1668 if (!display) 1668 if (!display)
1669 return Qnil; 1669 return Qnil;
1670 1670
1671 return Fcons (make_string ((Ibyte *) Dynarr_atp (name_Extbyte_dynarr, 0), 1671 return Fcons (make_string ((Ibyte *) Dynarr_begin (name_Extbyte_dynarr),
1672 Dynarr_length (name_Extbyte_dynarr)), 1672 Dynarr_length (name_Extbyte_dynarr)),
1673 make_string ((Ibyte *) Dynarr_atp (class_Extbyte_dynarr, 0), 1673 make_string ((Ibyte *) Dynarr_begin (class_Extbyte_dynarr),
1674 Dynarr_length (class_Extbyte_dynarr))); 1674 Dynarr_length (class_Extbyte_dynarr)));
1675 } 1675 }
1676 1676
1677 DEFUN ("x-put-resource", Fx_put_resource, 1, 2, 0, /* 1677 DEFUN ("x-put-resource", Fx_put_resource, 1, 2, 0, /*
1678 Add a resource to the resource database for DEVICE. 1678 Add a resource to the resource database for DEVICE.
1687 { 1687 {
1688 XrmDatabase db = XtDatabase (DEVICE_X_DISPLAY (d)); 1688 XrmDatabase db = XtDatabase (DEVICE_X_DISPLAY (d));
1689 Extbyte *str, *colon_pos; 1689 Extbyte *str, *colon_pos;
1690 1690
1691 CHECK_STRING (resource_line); 1691 CHECK_STRING (resource_line);
1692 LISP_STRING_TO_EXTERNAL (resource_line, str, 1692 str = LISP_STRING_TO_EXTERNAL (resource_line,
1693 coding_system_of_xrm_database (db)); 1693 coding_system_of_xrm_database (db));
1694 if (!(colon_pos = strchr (str, ':')) || strchr (str, '\n')) 1694 if (!(colon_pos = strchr (str, ':')) || strchr (str, '\n'))
1695 invalid: 1695 invalid:
1696 syntax_error ("Invalid resource line", resource_line); 1696 syntax_error ("Invalid resource line", resource_line);
1697 if ((int) 1697 if ((int)
1698 strspn (str, 1698 strspn (str,
1799 (device)) 1799 (device))
1800 { 1800 {
1801 Display *dpy = get_x_display (device); 1801 Display *dpy = get_x_display (device);
1802 Extbyte *vendor = ServerVendor (dpy); 1802 Extbyte *vendor = ServerVendor (dpy);
1803 1803
1804 return build_ext_string (vendor ? vendor : "", Qx_hpc_encoding); 1804 return build_extstring (vendor ? vendor : "", Qx_hpc_encoding);
1805 } 1805 }
1806 1806
1807 DEFUN ("x-server-version", Fx_server_version, 0, 1, 0, /* 1807 DEFUN ("x-server-version", Fx_server_version, 0, 1, 0, /*
1808 Return the version numbers of the X server DEVICE is on. 1808 Return the version numbers of the X server DEVICE is on.
1809 The returned value is a list of three integers: the major and minor 1809 The returned value is a list of three integers: the major and minor
1827 (keysym)) 1827 (keysym))
1828 { 1828 {
1829 const Extbyte *keysym_ext; 1829 const Extbyte *keysym_ext;
1830 1830
1831 CHECK_STRING (keysym); 1831 CHECK_STRING (keysym);
1832 LISP_STRING_TO_EXTERNAL (keysym, keysym_ext, Qctext); 1832 keysym_ext = LISP_STRING_TO_EXTERNAL (keysym, Qctext);
1833 1833
1834 return XStringToKeysym (keysym_ext) ? Qt : Qnil; 1834 return XStringToKeysym (keysym_ext) ? Qt : Qnil;
1835 } 1835 }
1836 1836
1837 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /* 1837 DEFUN ("x-keysym-hash-table", Fx_keysym_hash_table, 0, 1, 0, /*
2044 2044
2045 if (!directories) 2045 if (!directories)
2046 gui_error ("Can't get X font path", device); 2046 gui_error ("Can't get X font path", device);
2047 2047
2048 while (ndirs_return--) 2048 while (ndirs_return--)
2049 font_path = Fcons (build_ext_string (directories[ndirs_return], 2049 font_path = Fcons (build_extstring (directories[ndirs_return],
2050 Qfile_name), 2050 Qfile_name),
2051 font_path); 2051 font_path);
2052 2052
2053 XFreeFontPath ((char **)directories); 2053 XFreeFontPath ((char **)directories);
2054 2054
2085 2085
2086 directories = alloca_array (Extbyte *, ndirs); 2086 directories = alloca_array (Extbyte *, ndirs);
2087 2087
2088 { 2088 {
2089 EXTERNAL_LIST_LOOP_2 (path_entry, font_path) 2089 EXTERNAL_LIST_LOOP_2 (path_entry, font_path)
2090 { 2090 LISP_PATHNAME_CONVERT_OUT (path_entry, directories[i++]);
2091 LISP_STRING_TO_EXTERNAL (path_entry, directories[i++],
2092 Qfile_name);
2093 }
2094 } 2091 }
2095 2092
2096 expect_x_error (dpy); 2093 expect_x_error (dpy);
2097 XSetFontPath (dpy, directories, ndirs); 2094 XSetFontPath (dpy, directories, ndirs);
2098 signal_if_x_error (dpy, 1/*resumable_p*/); 2095 signal_if_x_error (dpy, 1/*resumable_p*/);