Mercurial > hg > xemacs-beta
comparison src/device-x.c @ 183:e121b013d1f0 r20-3b18
Import from CVS: tag r20-3b18
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:54:23 +0200 |
parents | 9ad43877534d |
children | 3d6bfa290dbd |
comparison
equal
deleted
inserted
replaced
182:f07455f06202 | 183:e121b013d1f0 |
---|---|
50 #include "systime.h" | 50 #include "systime.h" |
51 | 51 |
52 Lisp_Object Vdefault_x_device; | 52 Lisp_Object Vdefault_x_device; |
53 | 53 |
54 /* Qdisplay in general.c */ | 54 /* Qdisplay in general.c */ |
55 Lisp_Object Qx_error; | 55 Lisp_Object Qx_error; |
56 Lisp_Object Qinit_pre_x_win, Qinit_post_x_win; | 56 Lisp_Object Qinit_pre_x_win, Qinit_post_x_win; |
57 | 57 |
58 /* $B@ZJ"(B, n. Japanese ritual suicide. */ | 58 /* $B@ZJ"(B, n. Japanese ritual suicide. */ |
59 int x_seppuku_on_epipe; | 59 int x_seppuku_on_epipe; |
60 | 60 |
63 | 63 |
64 Lisp_Object Vx_initial_argv_list; /* #### ugh! */ | 64 Lisp_Object Vx_initial_argv_list; /* #### ugh! */ |
65 | 65 |
66 static XrmOptionDescRec emacs_options[] = | 66 static XrmOptionDescRec emacs_options[] = |
67 { | 67 { |
68 {(String)"-geometry", (String)".geometry", XrmoptionSepArg, NULL}, | 68 {"-geometry", ".geometry", XrmoptionSepArg, NULL}, |
69 {(String)"-iconic", (String)".iconic", XrmoptionNoArg, (XtPointer) "yes"}, | 69 {"-iconic", ".iconic", XrmoptionNoArg, (XtPointer) "yes"}, |
70 | 70 |
71 {(String)"-internal-border-width", (String)"*EmacsFrame.internalBorderWidth", | 71 {"-internal-border-width", "*EmacsFrame.internalBorderWidth", |
72 XrmoptionSepArg, NULL}, | 72 XrmoptionSepArg, NULL}, |
73 {(String)"-ib", (String)"*EmacsFrame.internalBorderWidth", XrmoptionSepArg, | 73 {"-ib", "*EmacsFrame.internalBorderWidth", XrmoptionSepArg, NULL}, |
74 NULL}, | 74 {"-scrollbar-width", "*EmacsFrame.scrollBarWidth", XrmoptionSepArg, NULL}, |
75 {(String)"-scrollbar-width", (String)"*EmacsFrame.scrollBarWidth", | 75 {"-scrollbar-height", "*EmacsFrame.scrollBarHeight", XrmoptionSepArg, NULL}, |
76 XrmoptionSepArg, NULL}, | |
77 {(String)"-scrollbar-height", (String)"*EmacsFrame.scrollBarHeight", | |
78 XrmoptionSepArg, NULL}, | |
79 | 76 |
80 /* #### Beware! If the type of the shell changes, update this. */ | 77 /* #### Beware! If the type of the shell changes, update this. */ |
81 {(String)"-T", (String)"*TopLevelEmacsShell.title", XrmoptionSepArg, NULL}, | 78 {"-T", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL}, |
82 {(String)"-wn", (String)"*TopLevelEmacsShell.title", XrmoptionSepArg, NULL}, | 79 {"-wn", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL}, |
83 {(String)"-title", (String)"*TopLevelEmacsShell.title", XrmoptionSepArg, | 80 {"-title", "*TopLevelEmacsShell.title", XrmoptionSepArg, NULL}, |
84 NULL}, | 81 |
85 {(String)"-iconname", (String)"*TopLevelEmacsShell.iconName", | 82 {"-iconname", "*TopLevelEmacsShell.iconName", XrmoptionSepArg, NULL}, |
86 XrmoptionSepArg, NULL}, | 83 {"-in", "*TopLevelEmacsShell.iconName", XrmoptionSepArg, NULL}, |
87 {(String)"-in", (String)"*TopLevelEmacsShell.iconName", XrmoptionSepArg, | 84 {"-mc", "*pointerColor", XrmoptionSepArg, NULL}, |
88 NULL}, | 85 {"-cr", "*cursorColor", XrmoptionSepArg, NULL}, |
89 {(String)"-mc", (String)"*pointerColor", XrmoptionSepArg, NULL}, | 86 {"-fontset", "*FontSet", XrmoptionSepArg, NULL}, |
90 {(String)"-cr", (String)"*cursorColor", XrmoptionSepArg, NULL}, | |
91 {(String)"-fontset", (String)"*FontSet", XrmoptionSepArg, NULL}, | |
92 }; | 87 }; |
93 | 88 |
94 static void validify_resource_string (char *str); | 89 static void validify_resource_string (char *str); |
95 | 90 |
96 /* Functions to synchronize mirroring resources and specifiers */ | 91 /* Functions to synchronize mirroring resources and specifiers */ |
274 does not override resources defined elsewhere */ | 269 does not override resources defined elsewhere */ |
275 CONST char *data_dir; | 270 CONST char *data_dir; |
276 char path[MAXPATHLEN]; | 271 char path[MAXPATHLEN]; |
277 XrmDatabase db = XtDatabase (dpy); /* ### XtScreenDatabase(dpy) ? */ | 272 XrmDatabase db = XtDatabase (dpy); /* ### XtScreenDatabase(dpy) ? */ |
278 CONST char *locale = XrmLocaleOfDatabase (db); | 273 CONST char *locale = XrmLocaleOfDatabase (db); |
279 | 274 |
280 if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) | 275 if (STRINGP (Vdata_directory) && XSTRING_LENGTH (Vdata_directory) > 0) |
281 { | 276 { |
282 GET_C_STRING_FILENAME_DATA_ALLOCA (Vdata_directory, data_dir); | 277 GET_C_STRING_FILENAME_DATA_ALLOCA (Vdata_directory, data_dir); |
283 sprintf (path, "%sapp-defaults/%s/%s", data_dir, locale, app_class); | 278 sprintf (path, "%sapp-defaults/%s/%s", data_dir, locale, app_class); |
284 if (!access (path, R_OK)) | 279 if (!access (path, R_OK)) |
386 | 381 |
387 if (display) | 382 if (display) |
388 { | 383 { |
389 #ifdef FREE_CHECKING | 384 #ifdef FREE_CHECKING |
390 checking_free = (__free_hook != 0); | 385 checking_free = (__free_hook != 0); |
391 | 386 |
392 /* Disable strict free checking, to avoid bug in X library */ | 387 /* Disable strict free checking, to avoid bug in X library */ |
393 if (checking_free) | 388 if (checking_free) |
394 disable_strict_free_check (); | 389 disable_strict_free_check (); |
395 #endif | 390 #endif |
396 | 391 |
405 #ifdef FREE_CHECKING | 400 #ifdef FREE_CHECKING |
406 if (checking_free) | 401 if (checking_free) |
407 enable_strict_free_check (); | 402 enable_strict_free_check (); |
408 #endif | 403 #endif |
409 } | 404 } |
410 | 405 |
411 if (EQ (device, Vdefault_x_device)) | 406 if (EQ (device, Vdefault_x_device)) |
412 { | 407 { |
413 Lisp_Object devcons, concons; | 408 Lisp_Object devcons, concons; |
414 /* #### handle deleting last X device */ | 409 /* #### handle deleting last X device */ |
415 Vdefault_x_device = Qnil; | 410 Vdefault_x_device = Qnil; |
783 strcat (class_tail, "."); | 778 strcat (class_tail, "."); |
784 class_tail++; | 779 class_tail++; |
785 } | 780 } |
786 } | 781 } |
787 | 782 |
788 #endif | 783 #endif /* 0 */ |
789 | 784 |
790 /* Only the characters [-_A-Za-z0-9] are allowed in the individual | 785 /* Only the characters [-_A-Za-z0-9] are allowed in the individual |
791 sections of a resource. Convert invalid characters to -. */ | 786 sections of a resource. Convert invalid characters to -. */ |
792 | 787 |
793 static void | 788 static void |
879 } | 874 } |
880 | 875 |
881 DEFUN ("x-get-resource", Fx_get_resource, 3, 6, 0, /* | 876 DEFUN ("x-get-resource", Fx_get_resource, 3, 6, 0, /* |
882 Retrieve an X resource from the resource manager. | 877 Retrieve an X resource from the resource manager. |
883 | 878 |
884 The first arg is the name of the resource to retrieve, such as \"font\". | 879 The first arg is the name of the resource to retrieve, such as "font". |
885 The second arg is the class of the resource to retrieve, like \"Font\". | 880 The second arg is the class of the resource to retrieve, like "Font". |
886 The third arg should be one of the symbols 'string, 'integer, 'natnum, or | 881 The third arg should be one of the symbols 'string, 'integer, 'natnum, or |
887 'boolean, specifying the type of object that the database is searched for. | 882 'boolean, specifying the type of object that the database is searched for. |
888 The fourth arg is the locale to search for the resources on, and can | 883 The fourth arg is the locale to search for the resources on, and can |
889 currently be a a buffer, a frame, a device, or 'global. If omitted, it | 884 currently be a a buffer, a frame, a device, or 'global. If omitted, it |
890 defaults to 'global. | 885 defaults to 'global. |
891 The fifth arg is the device to search for the resources on. (The resource | 886 The fifth arg is the device to search for the resources on. (The resource |
892 database for a particular device is constructed by combining non-device- | 887 database for a particular device is constructed by combining non-device- |
893 specific resources such any command-line resources specified and any | 888 specific resources such as any command-line resources specified and any |
894 app-defaults files found [or the fallback resources supplied by XEmacs, | 889 app-defaults files found [or the fallback resources supplied by XEmacs, |
895 if no app-defaults file is found] with device-specific resources such as | 890 if no app-defaults file is found] with device-specific resources such as |
896 those supplied using xrdb.) If omitted, it defaults to the device of | 891 those supplied using xrdb.) If omitted, it defaults to the device of |
897 LOCALE, if a device can be derived (i.e. if LOCALE is a frame or device), | 892 LOCALE, if a device can be derived (i.e. if LOCALE is a frame or device), |
898 and otherwise defaults to the value of `default-x-device'. | 893 and otherwise defaults to the value of `default-x-device'. |
904 The resource names passed to this function are looked up relative to the | 899 The resource names passed to this function are looked up relative to the |
905 locale. | 900 locale. |
906 | 901 |
907 If you want to search for a subresource, you just need to specify the | 902 If you want to search for a subresource, you just need to specify the |
908 resource levels in NAME and CLASS. For example, NAME could be | 903 resource levels in NAME and CLASS. For example, NAME could be |
909 \"modeline.attributeFont\", and CLASS \"Face.AttributeFont\". | 904 "modeline.attributeFont", and CLASS "Face.AttributeFont". |
910 | 905 |
911 Specifically, | 906 Specifically, |
912 | 907 |
913 1) If LOCALE is a buffer, a call | 908 1) If LOCALE is a buffer, a call |
914 | 909 |
915 (x-get-resource \"foreground\" \"Foreground\" 'string SOME-BUFFER) | 910 (x-get-resource "foreground" "Foreground" 'string SOME-BUFFER) |
916 | 911 |
917 is an interface to a C call something like | 912 is an interface to a C call something like |
918 | 913 |
919 XrmGetResource (db, \"xemacs.buffer.BUFFER-NAME.foreground\", | 914 XrmGetResource (db, "xemacs.buffer.BUFFER-NAME.foreground", |
920 \"Emacs.EmacsLocaleType.EmacsBuffer.Foreground\", | 915 "Emacs.EmacsLocaleType.EmacsBuffer.Foreground", |
921 \"String\"); | 916 "String"); |
922 | 917 |
923 2) If LOCALE is a frame, a call | 918 2) If LOCALE is a frame, a call |
924 | 919 |
925 (x-get-resource \"foreground\" \"Foreground\" 'string SOME-FRAME) | 920 (x-get-resource "foreground" "Foreground" 'string SOME-FRAME) |
926 | 921 |
927 is an interface to a C call something like | 922 is an interface to a C call something like |
928 | 923 |
929 XrmGetResource (db, \"xemacs.frame.FRAME-NAME.foreground\", | 924 XrmGetResource (db, "xemacs.frame.FRAME-NAME.foreground", |
930 \"Emacs.EmacsLocaleType.EmacsFrame.Foreground\", | 925 "Emacs.EmacsLocaleType.EmacsFrame.Foreground", |
931 \"String\"); | 926 "String"); |
932 | 927 |
933 3) If LOCALE is a device, a call | 928 3) If LOCALE is a device, a call |
934 | 929 |
935 (x-get-resource \"foreground\" \"Foreground\" 'string SOME-DEVICE) | 930 (x-get-resource "foreground" "Foreground" 'string SOME-DEVICE) |
936 | 931 |
937 is an interface to a C call something like | 932 is an interface to a C call something like |
938 | 933 |
939 XrmGetResource (db, \"xemacs.device.DEVICE-NAME.foreground\", | 934 XrmGetResource (db, "xemacs.device.DEVICE-NAME.foreground", |
940 \"Emacs.EmacsLocaleType.EmacsDevice.Foreground\", | 935 "Emacs.EmacsLocaleType.EmacsDevice.Foreground", |
941 \"String\"); | 936 "String"); |
942 | 937 |
943 4) If LOCALE is 'global, a call | 938 4) If LOCALE is 'global, a call |
944 | 939 |
945 (x-get-resource \"foreground\" \"Foreground\" 'string 'global) | 940 (x-get-resource "foreground" "Foreground" 'string 'global) |
946 | 941 |
947 is an interface to a C call something like | 942 is an interface to a C call something like |
948 | 943 |
949 XrmGetResource (db, \"xemacs.foreground\", | 944 XrmGetResource (db, "xemacs.foreground", |
950 \"Emacs.Foreground\", | 945 "Emacs.Foreground", |
951 \"String\"); | 946 "String"); |
952 | 947 |
953 Note that for 'global, no prefix is added other than that of the | 948 Note that for 'global, no prefix is added other than that of the |
954 application itself; thus, you can use this locale to retrieve | 949 application itself; thus, you can use this locale to retrieve |
955 arbitrary application resources, if you really want to. | 950 arbitrary application resources, if you really want to. |
956 | 951 |
971 | 966 |
972 CHECK_STRING (name); | 967 CHECK_STRING (name); |
973 CHECK_STRING (class); | 968 CHECK_STRING (class); |
974 CHECK_SYMBOL (type); | 969 CHECK_SYMBOL (type); |
975 | 970 |
976 if (!EQ (type, Qstring) && !EQ (type, Qboolean) && | 971 if (!EQ (type, Qstring) && |
977 !EQ (type, Qinteger) && !EQ (type, Qnatnum)) | 972 !EQ (type, Qboolean) && |
973 !EQ (type, Qinteger) && | |
974 !EQ (type, Qnatnum)) | |
978 return maybe_signal_continuable_error | 975 return maybe_signal_continuable_error |
979 (Qwrong_type_argument, | 976 (Qwrong_type_argument, |
980 list2 (build_translated_string | 977 list2 (build_translated_string |
981 ("should be string, integer, natnum or boolean"), | 978 ("should be string, integer, natnum or boolean"), |
982 type), | 979 type), |
1022 | 1019 |
1023 if (EQ (type, Qstring)) | 1020 if (EQ (type, Qstring)) |
1024 return build_string (raw_result); | 1021 return build_string (raw_result); |
1025 else if (EQ (type, Qboolean)) | 1022 else if (EQ (type, Qboolean)) |
1026 { | 1023 { |
1027 if (!strcasecmp (raw_result, "off") || | 1024 if (!strcasecmp (raw_result, "off") || |
1028 !strcasecmp (raw_result, "false") || | 1025 !strcasecmp (raw_result, "false") || |
1029 !strcasecmp (raw_result,"no")) | 1026 !strcasecmp (raw_result, "no")) |
1030 return Fcons (Qnil, Qnil); | 1027 return Fcons (Qnil, Qnil); |
1031 else if (!strcasecmp (raw_result, "on") || | 1028 else if (!strcasecmp (raw_result, "on") || |
1032 !strcasecmp (raw_result, "true") || | 1029 !strcasecmp (raw_result, "true") || |
1033 !strcasecmp (raw_result, "yes")) | 1030 !strcasecmp (raw_result, "yes")) |
1034 return Fcons (Qt, Qnil); | 1031 return Fcons (Qt, Qnil); |
1035 else | 1032 else |
1036 return maybe_continuable_error (Qresource, errb, | 1033 return maybe_continuable_error (Qresource, errb, |
1065 Return the resource prefix for LOCALE on DEVICE. | 1062 Return the resource prefix for LOCALE on DEVICE. |
1066 The resource prefix is the strings used to prefix resources if | 1063 The resource prefix is the strings used to prefix resources if |
1067 the LOCALE and DEVICE arguments were passed to `x-get-resource'. | 1064 the LOCALE and DEVICE arguments were passed to `x-get-resource'. |
1068 The returned value is a cons of a name prefix and a class prefix. | 1065 The returned value is a cons of a name prefix and a class prefix. |
1069 For example, if LOCALE is a frame, the returned value might be | 1066 For example, if LOCALE is a frame, the returned value might be |
1070 \(\"xemacs.frame.FRAME-NAME\" . \"Emacs.EmacsLocaleType.EmacsFrame\"). | 1067 \("xemacs.frame.FRAME-NAME" . "Emacs.EmacsLocaleType.EmacsFrame"). |
1071 If no valid X device for resourcing can be obtained, this function | 1068 If no valid X device for resourcing can be obtained, this function |
1072 returns nil. (In such a case, `x-get-resource' would always return nil.) | 1069 returns nil. (In such a case, `x-get-resource' would always return nil.) |
1073 */ | 1070 */ |
1074 (locale, device)) | 1071 (locale, device)) |
1075 { | 1072 { |
1204 (device)) | 1201 (device)) |
1205 { | 1202 { |
1206 Display *dpy = get_x_display (device); | 1203 Display *dpy = get_x_display (device); |
1207 char *vendor = ServerVendor (dpy); | 1204 char *vendor = ServerVendor (dpy); |
1208 | 1205 |
1209 if (vendor) | 1206 return build_string (vendor ? vendor : ""); |
1210 return (build_string (vendor)); | |
1211 else | |
1212 return (build_string ("")); | |
1213 } | 1207 } |
1214 | 1208 |
1215 DEFUN ("x-server-version", Fx_server_version, 0, 1, 0, /* | 1209 DEFUN ("x-server-version", Fx_server_version, 0, 1, 0, /* |
1216 Return the version numbers of the X server `device' is on. | 1210 Return the version numbers of the X server `device' is on. |
1217 The returned value is a list of three integers: the major and minor | 1211 The returned value is a list of three integers: the major and minor |
1233 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system. | 1227 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system. |
1234 */ | 1228 */ |
1235 (keysym)) | 1229 (keysym)) |
1236 { | 1230 { |
1237 CONST char *keysym_ext; | 1231 CONST char *keysym_ext; |
1238 | 1232 |
1239 CHECK_STRING (keysym); | 1233 CHECK_STRING (keysym); |
1240 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext); | 1234 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext); |
1241 if (XStringToKeysym (keysym_ext)) | 1235 |
1242 return Qt; | 1236 return XStringToKeysym (keysym_ext) ? Qt : Qnil; |
1243 return Qnil; | |
1244 } | 1237 } |
1245 | 1238 |
1246 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, 1, 2, 0, /* | 1239 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, 1, 2, 0, /* |
1247 Return true if KEYSYM names a key on the keyboard of DEVICE. | 1240 Return true if KEYSYM names a key on the keyboard of DEVICE. |
1248 More precisely, return true if pressing a physical key | 1241 More precisely, return true if pressing a physical key |
1255 struct device *d = decode_device(device); | 1248 struct device *d = decode_device(device); |
1256 CONST char *keysym_string; | 1249 CONST char *keysym_string; |
1257 KeySym keysym_KeySym; | 1250 KeySym keysym_KeySym; |
1258 KeySym *keysym_ptr, *keysym_last; | 1251 KeySym *keysym_ptr, *keysym_last; |
1259 int min_code, max_code, keysyms_per_code; | 1252 int min_code, max_code, keysyms_per_code; |
1260 | 1253 |
1261 if (!DEVICE_X_P (d)) | 1254 if (!DEVICE_X_P (d)) |
1262 signal_simple_error ("Not an X device", device); | 1255 signal_simple_error ("Not an X device", device); |
1263 CHECK_STRING (keysym); | 1256 CHECK_STRING (keysym); |
1264 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_string); | 1257 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_string); |
1265 keysym_KeySym = XStringToKeysym (keysym_string); | 1258 keysym_KeySym = XStringToKeysym (keysym_string); |
1266 if (!keysym_KeySym) /* Invalid keysym */ | 1259 if (!keysym_KeySym) /* Invalid keysym */ |
1267 return Qnil; | 1260 return Qnil; |
1268 | 1261 |
1269 XDisplayKeycodes (DEVICE_X_DISPLAY (d), &min_code, &max_code); | 1262 XDisplayKeycodes (DEVICE_X_DISPLAY (d), &min_code, &max_code); |
1270 keysyms_per_code = DEVICE_X_DATA (d)->x_keysym_map_keysyms_per_code; | 1263 keysyms_per_code = DEVICE_X_DATA (d)->x_keysym_map_keysyms_per_code; |
1271 keysym_ptr = DEVICE_X_DATA (d)->x_keysym_map; | 1264 keysym_ptr = DEVICE_X_DATA (d)->x_keysym_map; |
1272 keysym_last = keysym_ptr + (max_code - min_code) * keysyms_per_code; | 1265 keysym_last = keysym_ptr + (max_code - min_code) * keysyms_per_code; |
1273 for ( ; keysym_ptr <= keysym_last; keysym_ptr += keysyms_per_code) | 1266 for ( ; keysym_ptr <= keysym_last; keysym_ptr += keysyms_per_code) |
1274 { | 1267 { |
1275 if (keysym_KeySym == *keysym_ptr) | 1268 if (keysym_KeySym == *keysym_ptr) |
1276 return Qt; | 1269 return Qt; |
1277 } | 1270 } |
1278 | 1271 |
1279 return Qnil; | 1272 return Qnil; |
1280 } | 1273 } |
1281 | 1274 |
1282 | 1275 |
1283 /************************************************************************/ | 1276 /************************************************************************/ |
1325 pointer_mode, /* Stall keyboard events */ | 1318 pointer_mode, /* Stall keyboard events */ |
1326 w, /* Stay in this window */ | 1319 w, /* Stay in this window */ |
1327 (NILP (cursor) ? 0 | 1320 (NILP (cursor) ? 0 |
1328 : XIMAGE_INSTANCE_X_CURSOR (cursor)), | 1321 : XIMAGE_INSTANCE_X_CURSOR (cursor)), |
1329 CurrentTime); | 1322 CurrentTime); |
1330 return ((result == GrabSuccess) ? Qt : Qnil); | 1323 return (result == GrabSuccess) ? Qt : Qnil; |
1331 } | 1324 } |
1332 | 1325 |
1333 DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, 0, 1, 0, /* | 1326 DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, 0, 1, 0, /* |
1334 Release a pointer grab made with `x-grab-pointer'. | 1327 Release a pointer grab made with `x-grab-pointer'. |
1335 If optional first arg DEVICE is nil the default device is used. | 1328 If optional first arg DEVICE is nil the default device is used. |