Mercurial > hg > xemacs-beta
comparison src/device.c @ 185:3d6bfa290dbd r20-3b19
Import from CVS: tag r20-3b19
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:55:28 +0200 |
parents | 43dd3413c7c7 |
children | a2f645c6b9f8 |
comparison
equal
deleted
inserted
replaced
184:bcd2674570bf | 185:3d6bfa290dbd |
---|---|
139 Given a DEVICE-CLASS, return t if it is valid. | 139 Given a DEVICE-CLASS, return t if it is valid. |
140 Valid classes are 'color, 'grayscale, and 'mono. | 140 Valid classes are 'color, 'grayscale, and 'mono. |
141 */ | 141 */ |
142 (device_class)) | 142 (device_class)) |
143 { | 143 { |
144 if (valid_device_class_p (device_class)) | 144 return valid_device_class_p (device_class) ? Qt : Qnil; |
145 return Qt; | |
146 else | |
147 return Qnil; | |
148 } | 145 } |
149 | 146 |
150 DEFUN ("device-class-list", Fdevice_class_list, 0, 0, 0, /* | 147 DEFUN ("device-class-list", Fdevice_class_list, 0, 0, 0, /* |
151 Return a list of valid device classes. | 148 Return a list of valid device classes. |
152 */ | 149 */ |
156 } | 153 } |
157 | 154 |
158 static struct device * | 155 static struct device * |
159 allocate_device (Lisp_Object console) | 156 allocate_device (Lisp_Object console) |
160 { | 157 { |
161 Lisp_Object device = Qnil; | 158 Lisp_Object device; |
162 struct device *d = alloc_lcrecord (sizeof (struct device), lrecord_device); | 159 struct device *d = alloc_lcrecord_type (struct device, lrecord_device); |
163 struct gcpro gcpro1; | 160 struct gcpro gcpro1; |
164 | 161 |
165 zero_lcrecord (d); | 162 zero_lcrecord (d); |
166 | 163 |
167 XSETDEVICE (device, d); | 164 XSETDEVICE (device, d); |
251 void | 248 void |
252 select_device_1 (Lisp_Object device) | 249 select_device_1 (Lisp_Object device) |
253 { | 250 { |
254 struct device *dev = XDEVICE (device); | 251 struct device *dev = XDEVICE (device); |
255 Lisp_Object old_selected_device = Fselected_device (Qnil); | 252 Lisp_Object old_selected_device = Fselected_device (Qnil); |
256 | 253 |
257 if (EQ (device, old_selected_device)) | 254 if (EQ (device, old_selected_device)) |
258 return; | 255 return; |
259 | 256 |
260 /* now select the device's console */ | 257 /* now select the device's console */ |
261 CONSOLE_SELECTED_DEVICE (XCONSOLE (DEVICE_CONSOLE (dev))) = device; | 258 CONSOLE_SELECTED_DEVICE (XCONSOLE (DEVICE_CONSOLE (dev))) = device; |
297 If DEVICE is nil, the selected device is used. | 294 If DEVICE is nil, the selected device is used. |
298 If DEVICE is the selected device, this makes FRAME the selected frame. | 295 If DEVICE is the selected device, this makes FRAME the selected frame. |
299 */ | 296 */ |
300 (device, frame)) | 297 (device, frame)) |
301 { | 298 { |
302 XSETDEVICE (device, decode_device (device)); | 299 struct device *d = decode_device (device); |
300 | |
301 XSETDEVICE (device, d); | |
303 CHECK_LIVE_FRAME (frame); | 302 CHECK_LIVE_FRAME (frame); |
304 | 303 |
305 if (! EQ (device, FRAME_DEVICE (XFRAME (frame)))) | 304 if (! EQ (device, FRAME_DEVICE (XFRAME (frame)))) |
306 error ("In `set-device-selected-frame', FRAME is not on DEVICE"); | 305 error ("In `set-device-selected-frame', FRAME is not on DEVICE"); |
307 | 306 |
315 DEFUN ("devicep", Fdevicep, 1, 1, 0, /* | 314 DEFUN ("devicep", Fdevicep, 1, 1, 0, /* |
316 Return non-nil if OBJECT is a device. | 315 Return non-nil if OBJECT is a device. |
317 */ | 316 */ |
318 (object)) | 317 (object)) |
319 { | 318 { |
320 if (!DEVICEP (object)) | 319 return DEVICEP (object) ? Qt : Qnil; |
321 return Qnil; | |
322 return Qt; | |
323 } | 320 } |
324 | 321 |
325 DEFUN ("device-live-p", Fdevice_live_p, 1, 1, 0, /* | 322 DEFUN ("device-live-p", Fdevice_live_p, 1, 1, 0, /* |
326 Return non-nil if OBJECT is a device that has not been deleted. | 323 Return non-nil if OBJECT is a device that has not been deleted. |
327 */ | 324 */ |
328 (object)) | 325 (object)) |
329 { | 326 { |
330 if (!DEVICEP (object) || !DEVICE_LIVE_P (XDEVICE (object))) | 327 return DEVICEP (object) && DEVICE_LIVE_P (XDEVICE (object)) ? Qt : Qnil; |
331 return Qnil; | |
332 return Qt; | |
333 } | 328 } |
334 | 329 |
335 DEFUN ("device-name", Fdevice_name, 0, 1, 0, /* | 330 DEFUN ("device-name", Fdevice_name, 0, 1, 0, /* |
336 Return the name of the specified device. | 331 Return the name of the specified device. |
337 DEVICE defaults to the selected device if omitted. | 332 DEVICE defaults to the selected device if omitted. |
497 | 492 |
498 static Lisp_Object | 493 static Lisp_Object |
499 delete_deviceless_console(Lisp_Object console) | 494 delete_deviceless_console(Lisp_Object console) |
500 { | 495 { |
501 if (NILP (XCONSOLE (console)->device_list)) | 496 if (NILP (XCONSOLE (console)->device_list)) |
502 Fdelete_console(console, Qnil); | 497 Fdelete_console (console, Qnil); |
503 return Qnil; | 498 return Qnil; |
504 } | 499 } |
505 | 500 |
506 DEFUN ("make-device", Fmake_device, 2, 3, 0, /* | 501 DEFUN ("make-device", Fmake_device, 2, 3, 0, /* |
507 Create a new device of type TYPE, attached to connection CONNECTION. | 502 Create a new device of type TYPE, attached to connection CONNECTION. |
886 Return the width in pixels of DEVICE, or nil if unknown. | 881 Return the width in pixels of DEVICE, or nil if unknown. |
887 */ | 882 */ |
888 (device)) | 883 (device)) |
889 { | 884 { |
890 struct device *d = decode_device (device); | 885 struct device *d = decode_device (device); |
891 int retval; | 886 int retval = DEVMETH_OR_GIVEN (d, device_pixel_width, (d), 0); |
892 | 887 |
893 retval = DEVMETH_OR_GIVEN (d, device_pixel_width, (d), 0); | 888 return retval <= 0 ? Qnil : make_int (retval); |
894 if (retval <= 0) | |
895 return Qnil; | |
896 | |
897 return make_int (retval); | |
898 } | 889 } |
899 | 890 |
900 DEFUN ("device-pixel-height", Fdevice_pixel_height, 0, 1, 0, /* | 891 DEFUN ("device-pixel-height", Fdevice_pixel_height, 0, 1, 0, /* |
901 Return the height in pixels of DEVICE, or nil if unknown. | 892 Return the height in pixels of DEVICE, or nil if unknown. |
902 */ | 893 */ |
903 (device)) | 894 (device)) |
904 { | 895 { |
905 struct device *d = decode_device (device); | 896 struct device *d = decode_device (device); |
906 int retval; | 897 int retval = DEVMETH_OR_GIVEN (d, device_pixel_height, (d), 0); |
907 | 898 |
908 retval = DEVMETH_OR_GIVEN (d, device_pixel_height, (d), 0); | 899 return retval <= 0 ? Qnil : make_int (retval); |
909 if (retval <= 0) | |
910 return Qnil; | |
911 | |
912 return make_int (retval); | |
913 } | 900 } |
914 | 901 |
915 DEFUN ("device-mm-width", Fdevice_mm_width, 0, 1, 0, /* | 902 DEFUN ("device-mm-width", Fdevice_mm_width, 0, 1, 0, /* |
916 Return the width in millimeters of DEVICE, or nil if unknown. | 903 Return the width in millimeters of DEVICE, or nil if unknown. |
917 */ | 904 */ |
918 (device)) | 905 (device)) |
919 { | 906 { |
920 struct device *d = decode_device (device); | 907 struct device *d = decode_device (device); |
921 int retval; | 908 int retval = DEVMETH_OR_GIVEN (d, device_mm_width, (d), 0); |
922 | 909 |
923 retval = DEVMETH_OR_GIVEN (d, device_mm_width, (d), 0); | 910 return retval <= 0 ? Qnil : make_int (retval); |
924 if (retval <= 0) | |
925 return Qnil; | |
926 | |
927 return make_int (retval); | |
928 } | 911 } |
929 | 912 |
930 DEFUN ("device-mm-height", Fdevice_mm_height, 0, 1, 0, /* | 913 DEFUN ("device-mm-height", Fdevice_mm_height, 0, 1, 0, /* |
931 Return the height in millimeters of DEVICE, or nil if unknown. | 914 Return the height in millimeters of DEVICE, or nil if unknown. |
932 */ | 915 */ |
933 (device)) | 916 (device)) |
934 { | 917 { |
935 struct device *d = decode_device (device); | 918 struct device *d = decode_device (device); |
936 int retval; | 919 int retval = DEVMETH_OR_GIVEN (d, device_mm_height, (d), 0); |
937 | 920 |
938 retval = DEVMETH_OR_GIVEN (d, device_mm_height, (d), 0); | 921 return retval <= 0 ? Qnil : make_int (retval); |
939 if (retval <= 0) | |
940 return Qnil; | |
941 | |
942 return make_int (retval); | |
943 } | 922 } |
944 | 923 |
945 DEFUN ("device-bitplanes", Fdevice_bitplanes, 0, 1, 0, /* | 924 DEFUN ("device-bitplanes", Fdevice_bitplanes, 0, 1, 0, /* |
946 Return the number of bitplanes of DEVICE, or nil if unknown. | 925 Return the number of bitplanes of DEVICE, or nil if unknown. |
947 */ | 926 */ |
948 (device)) | 927 (device)) |
949 { | 928 { |
950 struct device *d = decode_device (device); | 929 struct device *d = decode_device (device); |
951 int retval; | 930 int retval = DEVMETH_OR_GIVEN (d, device_bitplanes, (d), 0); |
952 | 931 |
953 retval = DEVMETH_OR_GIVEN (d, device_bitplanes, (d), 0); | 932 return retval <= 0 ? Qnil : make_int (retval); |
954 if (retval <= 0) | |
955 return Qnil; | |
956 | |
957 return make_int (retval); | |
958 } | 933 } |
959 | 934 |
960 DEFUN ("device-color-cells", Fdevice_color_cells, 0, 1, 0, /* | 935 DEFUN ("device-color-cells", Fdevice_color_cells, 0, 1, 0, /* |
961 Return the number of color cells of DEVICE, or nil if unknown. | 936 Return the number of color cells of DEVICE, or nil if unknown. |
962 */ | 937 */ |
963 (device)) | 938 (device)) |
964 { | 939 { |
965 struct device *d = decode_device (device); | 940 struct device *d = decode_device (device); |
966 int retval; | 941 int retval = DEVMETH_OR_GIVEN (d, device_color_cells, (d), 0); |
967 | 942 |
968 retval = DEVMETH_OR_GIVEN (d, device_color_cells, (d), 0); | 943 return retval <= 0 ? Qnil : make_int (retval); |
969 if (retval <= 0) | |
970 return Qnil; | |
971 | |
972 return make_int (retval); | |
973 } | 944 } |
974 | 945 |
975 DEFUN ("set-device-baud-rate", Fset_device_baud_rate, 2, 2, 0, /* | 946 DEFUN ("set-device-baud-rate", Fset_device_baud_rate, 2, 2, 0, /* |
976 Set the output baud rate of DEVICE to RATE. | 947 Set the output baud rate of DEVICE to RATE. |
977 On most systems, changing this value will affect the amount of padding | 948 On most systems, changing this value will affect the amount of padding |
1038 loop may result. */ | 1009 loop may result. */ |
1039 if (!NILP (object)) | 1010 if (!NILP (object)) |
1040 call1_with_handler (Qreally_early_error_handler, function, object); | 1011 call1_with_handler (Qreally_early_error_handler, function, object); |
1041 else | 1012 else |
1042 call0_with_handler (Qreally_early_error_handler, function); | 1013 call0_with_handler (Qreally_early_error_handler, function); |
1043 | 1014 |
1044 UNLOCK_DEVICE (d); | 1015 UNLOCK_DEVICE (d); |
1045 Vinhibit_quit = old_inhibit_quit; | 1016 Vinhibit_quit = old_inhibit_quit; |
1046 gc_currently_forbidden = old_gc_currently_forbidden; | 1017 gc_currently_forbidden = old_gc_currently_forbidden; |
1047 } | 1018 } |
1048 | 1019 |