comparison src/device-x.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents 9ee227acff29
children 7e54bd776075
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
610 enqueue_magic_eval_event (io_error_delete_device, dev); 610 enqueue_magic_eval_event (io_error_delete_device, dev);
611 611
612 return 0; 612 return 0;
613 } 613 }
614 614
615 DEFUN ("x-debug-mode", Fx_debug_mode, Sx_debug_mode, 1, 2, 0 /* 615 DEFUN ("x-debug-mode", Fx_debug_mode, 1, 2, 0, /*
616 With a true arg, make the connection to the X server synchronous. 616 With a true arg, make the connection to the X server synchronous.
617 With false, make it asynchronous. Synchronous connections are much slower, 617 With false, make it asynchronous. Synchronous connections are much slower,
618 but are useful for debugging. (If you get X errors, make the connection 618 but are useful for debugging. (If you get X errors, make the connection
619 synchronous, and use a debugger to set a breakpoint on `x_error_handler'. 619 synchronous, and use a debugger to set a breakpoint on `x_error_handler'.
620 Your backtrace of the C stack will now be useful. In asynchronous mode, 620 Your backtrace of the C stack will now be useful. In asynchronous mode,
621 the stack above `x_error_handler' isn't helpful because of buffering.) 621 the stack above `x_error_handler' isn't helpful because of buffering.)
622 If DEVICE is not specified, the selected device is assumed. 622 If DEVICE is not specified, the selected device is assumed.
623 623
624 Calling this function is the same as calling the C function `XSynchronize', 624 Calling this function is the same as calling the C function `XSynchronize',
625 or starting the program with the `-sync' command line argument. 625 or starting the program with the `-sync' command line argument.
626 */ ) 626 */
627 (arg, device) 627 (arg, device))
628 Lisp_Object arg, device;
629 { 628 {
630 struct device *d = decode_x_device (device); 629 struct device *d = decode_x_device (device);
631 630
632 XSynchronize (DEVICE_X_DISPLAY (d), !NILP (arg)); 631 XSynchronize (DEVICE_X_DISPLAY (d), !NILP (arg));
633 632
799 strcat (class_out, ".EmacsLocaleType.EmacsDevice"); 798 strcat (class_out, ".EmacsLocaleType.EmacsDevice");
800 } 799 }
801 return; 800 return;
802 } 801 }
803 802
804 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 3, 6, 0 /* 803 DEFUN ("x-get-resource", Fx_get_resource, 3, 6, 0, /*
805 Retrieve an X resource from the resource manager. 804 Retrieve an X resource from the resource manager.
806 805
807 The first arg is the name of the resource to retrieve, such as \"font\". 806 The first arg is the name of the resource to retrieve, such as \"font\".
808 The second arg is the class of the resource to retrieve, like \"Font\". 807 The second arg is the class of the resource to retrieve, like \"Font\".
809 The third arg should be one of the symbols 'string, 'integer, 'natnum, or 808 The third arg should be one of the symbols 'string, 'integer, 'natnum, or
880 The returned value of this function is nil if the queried resource is not 879 The returned value of this function is nil if the queried resource is not
881 found. If the third arg is `string', a string is returned, and if it is 880 found. If the third arg is `string', a string is returned, and if it is
882 `integer', an integer is returned. If the third arg is `boolean', then the 881 `integer', an integer is returned. If the third arg is `boolean', then the
883 returned value is the list (t) for true, (nil) for false, and is nil to 882 returned value is the list (t) for true, (nil) for false, and is nil to
884 mean ``unspecified.'' 883 mean ``unspecified.''
885 */ ) 884 */
886 (name, class, type, locale, device, no_error) 885 (name, class, type, locale, device, no_error))
887 Lisp_Object name, class, type, locale, device, no_error;
888 { 886 {
889 /* #### fixed limit, could be overflowed */ 887 /* #### fixed limit, could be overflowed */
890 char name_string[2048], class_string[2048]; 888 char name_string[2048], class_string[2048];
891 char *raw_result; 889 char *raw_result;
892 XrmDatabase db; 890 XrmDatabase db;
983 981
984 /* Can't get here. */ 982 /* Can't get here. */
985 return Qnil; /* shut up compiler */ 983 return Qnil; /* shut up compiler */
986 } 984 }
987 985
988 DEFUN ("x-get-resource-prefix", Fx_get_resource_prefix, 986 DEFUN ("x-get-resource-prefix", Fx_get_resource_prefix, 1, 2, 0, /*
989 Sx_get_resource_prefix, 1, 2, 0 /*
990 Return the resource prefix for LOCALE on DEVICE. 987 Return the resource prefix for LOCALE on DEVICE.
991 The resource prefix is the strings used to prefix resources if 988 The resource prefix is the strings used to prefix resources if
992 the LOCALE and DEVICE arguments were passed to `x-get-resource'. 989 the LOCALE and DEVICE arguments were passed to `x-get-resource'.
993 The returned value is a cons of a name prefix and a class prefix. 990 The returned value is a cons of a name prefix and a class prefix.
994 For example, if LOCALE is a frame, the returned value might be 991 For example, if LOCALE is a frame, the returned value might be
995 \(\"xemacs.frame.FRAME-NAME\" . \"Emacs.EmacsLocaleType.EmacsFrame\"). 992 \(\"xemacs.frame.FRAME-NAME\" . \"Emacs.EmacsLocaleType.EmacsFrame\").
996 If no valid X device for resourcing can be obtained, this function 993 If no valid X device for resourcing can be obtained, this function
997 returns nil. (In such a case, `x-get-resource' would always return nil.) 994 returns nil. (In such a case, `x-get-resource' would always return nil.)
998 */ ) 995 */
999 (locale, device) 996 (locale, device))
1000 Lisp_Object locale, device;
1001 { 997 {
1002 /* #### fixed limit, could be overflowed */ 998 /* #### fixed limit, could be overflowed */
1003 char name[1024], class[1024]; 999 char name[1024], class[1024];
1004 Display *display; 1000 Display *display;
1005 1001
1007 if (!display) 1003 if (!display)
1008 return Qnil; 1004 return Qnil;
1009 return Fcons (build_string (name), build_string (class)); 1005 return Fcons (build_string (name), build_string (class));
1010 } 1006 }
1011 1007
1012 DEFUN ("x-put-resource", Fx_put_resource, Sx_put_resource, 1, 2, 0 /* 1008 DEFUN ("x-put-resource", Fx_put_resource, 1, 2, 0, /*
1013 Add a resource to the resource database for DEVICE. 1009 Add a resource to the resource database for DEVICE.
1014 RESOURCE-LINE specifies the resource to add and should be a 1010 RESOURCE-LINE specifies the resource to add and should be a
1015 standard resource specification. 1011 standard resource specification.
1016 */ ) 1012 */
1017 (resource_line, device) 1013 (resource_line, device))
1018 Lisp_Object resource_line, device;
1019 { 1014 {
1020 struct device *d = decode_device (device); 1015 struct device *d = decode_device (device);
1021 char *str, *colon_pos; 1016 char *str, *colon_pos;
1022 1017
1023 CHECK_STRING (resource_line); 1018 CHECK_STRING (resource_line);
1043 1038
1044 /************************************************************************/ 1039 /************************************************************************/
1045 /* display information functions */ 1040 /* display information functions */
1046 /************************************************************************/ 1041 /************************************************************************/
1047 1042
1048 DEFUN ("default-x-device", Fdefault_x_device, Sdefault_x_device, 0, 0, 0 /* 1043 DEFUN ("default-x-device", Fdefault_x_device, 0, 0, 0, /*
1049 Return the default X device for resourcing. 1044 Return the default X device for resourcing.
1050 This is the first-created X device that still exists. 1045 This is the first-created X device that still exists.
1051 */ ) 1046 */
1052 () 1047 ())
1053 { 1048 {
1054 return Vdefault_x_device; 1049 return Vdefault_x_device;
1055 } 1050 }
1056 1051
1057 DEFUN ("x-display-visual-class", Fx_display_visual_class, 1052 DEFUN ("x-display-visual-class", Fx_display_visual_class, 0, 1, 0, /*
1058 Sx_display_visual_class, 0, 1, 0 /*
1059 Return the visual class of the X display `device' is on. 1053 Return the visual class of the X display `device' is on.
1060 The returned value will be one of the symbols `static-gray', `gray-scale', 1054 The returned value will be one of the symbols `static-gray', `gray-scale',
1061 `static-color', `pseudo-color', `true-color', or `direct-color'. 1055 `static-color', `pseudo-color', `true-color', or `direct-color'.
1062 */ ) 1056 */
1063 (device) 1057 (device))
1064 Lisp_Object device;
1065 { 1058 {
1066 switch (DefaultVisualOfScreen 1059 switch (DefaultVisualOfScreen
1067 (DefaultScreenOfDisplay (get_x_display (device)))->class) 1060 (DefaultScreenOfDisplay (get_x_display (device)))->class)
1068 { 1061 {
1069 case StaticGray: return (intern ("static-gray")); 1062 case StaticGray: return (intern ("static-gray"));
1125 Display *dpy = DEVICE_X_DISPLAY (d); 1118 Display *dpy = DEVICE_X_DISPLAY (d);
1126 1119
1127 return DisplayCells (dpy, DefaultScreen (dpy)); 1120 return DisplayCells (dpy, DefaultScreen (dpy));
1128 } 1121 }
1129 1122
1130 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0 /* 1123 DEFUN ("x-server-vendor", Fx_server_vendor, 0, 1, 0, /*
1131 Return the vendor ID string of the X server `device' on. 1124 Return the vendor ID string of the X server `device' on.
1132 */ ) 1125 */
1133 (device) 1126 (device))
1134 Lisp_Object device;
1135 { 1127 {
1136 Display *dpy = get_x_display (device); 1128 Display *dpy = get_x_display (device);
1137 char *vendor = ServerVendor (dpy); 1129 char *vendor = ServerVendor (dpy);
1138 1130
1139 if (vendor) 1131 if (vendor)
1140 return (build_string (vendor)); 1132 return (build_string (vendor));
1141 else 1133 else
1142 return (build_string ("")); 1134 return (build_string (""));
1143 } 1135 }
1144 1136
1145 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0 /* 1137 DEFUN ("x-server-version", Fx_server_version, 0, 1, 0, /*
1146 Return the version numbers of the X server `device' is on. 1138 Return the version numbers of the X server `device' is on.
1147 The returned value is a list of three integers: the major and minor 1139 The returned value is a list of three integers: the major and minor
1148 version numbers of the X Protocol in use, and the vendor-specific release 1140 version numbers of the X Protocol in use, and the vendor-specific release
1149 number. See also `x-server-vendor'. 1141 number. See also `x-server-vendor'.
1150 */ ) 1142 */
1151 (device) 1143 (device))
1152 Lisp_Object device;
1153 { 1144 {
1154 Display *dpy = get_x_display (device); 1145 Display *dpy = get_x_display (device);
1155 1146
1156 return list3 (make_int (ProtocolVersion (dpy)), 1147 return list3 (make_int (ProtocolVersion (dpy)),
1157 make_int (ProtocolRevision (dpy)), 1148 make_int (ProtocolRevision (dpy)),
1158 make_int (VendorRelease (dpy))); 1149 make_int (VendorRelease (dpy)));
1159 } 1150 }
1160 1151
1161 DEFUN ("x-valid-keysym-name-p", Fx_valid_keysym_name_p, Sx_valid_keysym_name_p, 1152 DEFUN ("x-valid-keysym-name-p", Fx_valid_keysym_name_p, 1, 1, 0, /*
1162 1, 1, 0 /*
1163 Return true if KEYSYM names a keysym that the X library knows about. 1153 Return true if KEYSYM names a keysym that the X library knows about.
1164 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in 1154 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
1165 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system. 1155 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
1166 */ ) 1156 */
1167 (keysym) 1157 (keysym))
1168 Lisp_Object keysym;
1169 { 1158 {
1170 CONST char *keysym_ext; 1159 CONST char *keysym_ext;
1171 1160
1172 CHECK_STRING (keysym); 1161 CHECK_STRING (keysym);
1173 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext); 1162 GET_C_STRING_CTEXT_DATA_ALLOCA (keysym, keysym_ext);
1174 if (XStringToKeysym (keysym_ext)) 1163 if (XStringToKeysym (keysym_ext))
1175 return Qt; 1164 return Qt;
1176 return Qnil; 1165 return Qnil;
1177 } 1166 }
1178 1167
1179 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, Sx_keysym_on_keyboard_p, 1168 DEFUN ("x-keysym-on-keyboard-p", Fx_keysym_on_keyboard_p, 1, 2, 0, /*
1180 1, 2, 0 /*
1181 Return true if KEYSYM names a key on the keyboard of DEVICE. 1169 Return true if KEYSYM names a key on the keyboard of DEVICE.
1182 More precisely, return true if pressing a physical key 1170 More precisely, return true if pressing a physical key
1183 on the keyboard of DEVICE without any modifier keys generates KEYSYM. 1171 on the keyboard of DEVICE without any modifier keys generates KEYSYM.
1184 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in 1172 Valid keysyms are listed in the files /usr/include/X11/keysymdef.h and in
1185 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system. 1173 /usr/lib/X11/XKeysymDB, or whatever the equivalents are on your system.
1186 */ ) 1174 */
1187 (keysym, device) 1175 (keysym, device))
1188 Lisp_Object keysym, device;
1189 { 1176 {
1190 struct device *d = decode_device(device); 1177 struct device *d = decode_device(device);
1191 CONST char *keysym_string; 1178 CONST char *keysym_string;
1192 KeySym keysym_KeySym; 1179 KeySym keysym_KeySym;
1193 KeySym *keysym_ptr, *keysym_last; 1180 KeySym *keysym_ptr, *keysym_last;
1217 1204
1218 /************************************************************************/ 1205 /************************************************************************/
1219 /* grabs and ungrabs */ 1206 /* grabs and ungrabs */
1220 /************************************************************************/ 1207 /************************************************************************/
1221 1208
1222 DEFUN ("x-grab-pointer", Fx_grab_pointer, Sx_grab_pointer, 0, 3, 0 /* 1209 DEFUN ("x-grab-pointer", Fx_grab_pointer, 0, 3, 0, /*
1223 Grab the pointer and restrict it to its current window. 1210 Grab the pointer and restrict it to its current window.
1224 If optional DEVICE argument is nil, the default device will be used. 1211 If optional DEVICE argument is nil, the default device will be used.
1225 If optional CURSOR argument is non-nil, change the pointer shape to that 1212 If optional CURSOR argument is non-nil, change the pointer shape to that
1226 until `x-ungrab-pointer' is called (it should be an object returned by the 1213 until `x-ungrab-pointer' is called (it should be an object returned by the
1227 `make-cursor-glyph' function). 1214 `make-cursor-glyph' function).
1228 If the second optional argument IGNORE-KEYBOARD is non-nil, ignore all 1215 If the second optional argument IGNORE-KEYBOARD is non-nil, ignore all
1229 keyboard events during the grab. 1216 keyboard events during the grab.
1230 Returns t if the grab is successful, nil otherwise. 1217 Returns t if the grab is successful, nil otherwise.
1231 */ ) 1218 */
1232 (device, cursor, ignore_keyboard) 1219 (device, cursor, ignore_keyboard))
1233 Lisp_Object device, cursor, ignore_keyboard;
1234 { 1220 {
1235 Window w; 1221 Window w;
1236 int pointer_mode, result; 1222 int pointer_mode, result;
1237 struct device *d = decode_x_device (device); 1223 struct device *d = decode_x_device (device);
1238 1224
1264 : XIMAGE_INSTANCE_X_CURSOR (cursor)), 1250 : XIMAGE_INSTANCE_X_CURSOR (cursor)),
1265 CurrentTime); 1251 CurrentTime);
1266 return ((result == GrabSuccess) ? Qt : Qnil); 1252 return ((result == GrabSuccess) ? Qt : Qnil);
1267 } 1253 }
1268 1254
1269 DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, Sx_ungrab_pointer, 0, 1, 0 /* 1255 DEFUN ("x-ungrab-pointer", Fx_ungrab_pointer, 0, 1, 0, /*
1270 Release a pointer grab made with `x-grab-pointer'. 1256 Release a pointer grab made with `x-grab-pointer'.
1271 If optional first arg DEVICE is nil the default device is used. 1257 If optional first arg DEVICE is nil the default device is used.
1272 If it is t the pointer will be released on all X devices. 1258 If it is t the pointer will be released on all X devices.
1273 */ ) 1259 */
1274 (device) 1260 (device))
1275 Lisp_Object device;
1276 { 1261 {
1277 if (!EQ (device, Qt)) 1262 if (!EQ (device, Qt))
1278 { 1263 {
1279 Display *dpy = get_x_display (device); 1264 Display *dpy = get_x_display (device);
1280 XUngrabPointer (dpy, CurrentTime); 1265 XUngrabPointer (dpy, CurrentTime);
1293 } 1278 }
1294 1279
1295 return Qnil; 1280 return Qnil;
1296 } 1281 }
1297 1282
1298 DEFUN ("x-grab-keyboard", Fx_grab_keyboard, Sx_grab_keyboard, 0, 1, 0 /* 1283 DEFUN ("x-grab-keyboard", Fx_grab_keyboard, 0, 1, 0, /*
1299 Grab the keyboard on the given device (defaulting to the selected one). 1284 Grab the keyboard on the given device (defaulting to the selected one).
1300 So long as the keyboard is grabbed, all keyboard events will be delivered 1285 So long as the keyboard is grabbed, all keyboard events will be delivered
1301 to emacs -- it is not possible for other X clients to eavesdrop on them. 1286 to emacs -- it is not possible for other X clients to eavesdrop on them.
1302 Ungrab the keyboard with `x-ungrab-keyboard' (use an unwind-protect). 1287 Ungrab the keyboard with `x-ungrab-keyboard' (use an unwind-protect).
1303 Returns t if the grab was successful; nil otherwise. 1288 Returns t if the grab was successful; nil otherwise.
1304 */ ) 1289 */
1305 (device) 1290 (device))
1306 Lisp_Object device;
1307 { 1291 {
1308 struct device *d = decode_x_device (device); 1292 struct device *d = decode_x_device (device);
1309 Window w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d))); 1293 Window w = XtWindow (FRAME_X_TEXT_WIDGET (device_selected_frame (d)));
1310 Display *dpy = DEVICE_X_DISPLAY (d); 1294 Display *dpy = DEVICE_X_DISPLAY (d);
1311 Status status; 1295 Status status;
1332 } 1316 }
1333 else 1317 else
1334 return Qnil; 1318 return Qnil;
1335 } 1319 }
1336 1320
1337 DEFUN ("x-ungrab-keyboard", Fx_ungrab_keyboard, Sx_ungrab_keyboard, 0, 1, 0 /* 1321 DEFUN ("x-ungrab-keyboard", Fx_ungrab_keyboard, 0, 1, 0, /*
1338 Release a keyboard grab made with `x-grab-keyboard'. 1322 Release a keyboard grab made with `x-grab-keyboard'.
1339 */ ) 1323 */
1340 (device) 1324 (device))
1341 Lisp_Object device;
1342 { 1325 {
1343 Display *dpy = get_x_display (device); 1326 Display *dpy = get_x_display (device);
1344 XUngrabKeyboard (dpy, CurrentTime); 1327 XUngrabKeyboard (dpy, CurrentTime);
1345 return Qnil; 1328 return Qnil;
1346 } 1329 }
1351 /************************************************************************/ 1334 /************************************************************************/
1352 1335
1353 void 1336 void
1354 syms_of_device_x (void) 1337 syms_of_device_x (void)
1355 { 1338 {
1356 defsubr (&Sx_debug_mode); 1339 DEFSUBR (Fx_debug_mode);
1357 defsubr (&Sx_get_resource); 1340 DEFSUBR (Fx_get_resource);
1358 defsubr (&Sx_get_resource_prefix); 1341 DEFSUBR (Fx_get_resource_prefix);
1359 defsubr (&Sx_put_resource); 1342 DEFSUBR (Fx_put_resource);
1360 1343
1361 defsubr (&Sdefault_x_device); 1344 DEFSUBR (Fdefault_x_device);
1362 defsubr (&Sx_display_visual_class); 1345 DEFSUBR (Fx_display_visual_class);
1363 defsubr (&Sx_server_vendor); 1346 DEFSUBR (Fx_server_vendor);
1364 defsubr (&Sx_server_version); 1347 DEFSUBR (Fx_server_version);
1365 defsubr (&Sx_valid_keysym_name_p); 1348 DEFSUBR (Fx_valid_keysym_name_p);
1366 defsubr (&Sx_keysym_on_keyboard_p); 1349 DEFSUBR (Fx_keysym_on_keyboard_p);
1367 1350
1368 defsubr (&Sx_grab_pointer); 1351 DEFSUBR (Fx_grab_pointer);
1369 defsubr (&Sx_ungrab_pointer); 1352 DEFSUBR (Fx_ungrab_pointer);
1370 defsubr (&Sx_grab_keyboard); 1353 DEFSUBR (Fx_grab_keyboard);
1371 defsubr (&Sx_ungrab_keyboard); 1354 DEFSUBR (Fx_ungrab_keyboard);
1372 1355
1373 defsymbol (&Qx_error, "x-error"); 1356 defsymbol (&Qx_error, "x-error");
1374 defsymbol (&Qinit_pre_x_win, "init-pre-x-win"); 1357 defsymbol (&Qinit_pre_x_win, "init-pre-x-win");
1375 defsymbol (&Qinit_post_x_win, "init-post-x-win"); 1358 defsymbol (&Qinit_post_x_win, "init-post-x-win");
1376 } 1359 }