Mercurial > hg > xemacs-beta
comparison src/device.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children | 41dbb7a9d5f2 |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
1 /* Generic device functions. | 1 /* Generic device functions. |
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. | 3 Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
4 Copyright (C) 1995, 1996 Ben Wing | 4 Copyright (C) 1995, 1996 Ben Wing |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
66 Qcolor_menu_button, Qcolor_menu_disabled, Qcolor_toolbar, | 66 Qcolor_menu_button, Qcolor_menu_disabled, Qcolor_toolbar, |
67 Qcolor_scrollbar, Qcolor_desktop, Qcolor_workspace, Qfont_default, | 67 Qcolor_scrollbar, Qcolor_desktop, Qcolor_workspace, Qfont_default, |
68 Qfont_menubar, Qfont_dialog, Qsize_cursor, Qsize_scrollbar, | 68 Qfont_menubar, Qfont_dialog, Qsize_cursor, Qsize_scrollbar, |
69 Qsize_menu, Qsize_toolbar, Qsize_toolbar_button, | 69 Qsize_menu, Qsize_toolbar, Qsize_toolbar_button, |
70 Qsize_toolbar_border, Qsize_icon, Qsize_icon_small, Qsize_device, | 70 Qsize_toolbar_border, Qsize_icon, Qsize_icon_small, Qsize_device, |
71 Qsize_workspace, Qoffset_workspace, Qsize_device_mm, Qdevice_dpi, | 71 Qsize_workspace, Qsize_device_mm, Qdevice_dpi, Qnum_bit_planes, |
72 Qnum_bit_planes, Qnum_color_cells, Qmouse_buttons, Qswap_buttons, | 72 Qnum_color_cells, Qmouse_buttons, Qswap_buttons, Qshow_sounds, |
73 Qshow_sounds, Qslow_device, Qsecurity; | 73 Qslow_device, Qsecurity; |
74 | 74 |
75 Lisp_Object Qdevicep, Qdevice_live_p; | 75 Lisp_Object Qdevicep, Qdevice_live_p; |
76 Lisp_Object Qdelete_device; | |
76 Lisp_Object Qcreate_device_hook; | 77 Lisp_Object Qcreate_device_hook; |
77 Lisp_Object Qdelete_device_hook; | 78 Lisp_Object Qdelete_device_hook; |
78 Lisp_Object Vdevice_class_list; | 79 Lisp_Object Vdevice_class_list; |
79 | 80 |
80 | 81 |
81 static Lisp_Object | 82 static Lisp_Object |
82 mark_device (Lisp_Object obj) | 83 mark_device (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
83 { | 84 { |
84 struct device *d = XDEVICE (obj); | 85 struct device *d = XDEVICE (obj); |
85 | 86 |
86 mark_object (d->name); | 87 markobj (d->name); |
87 mark_object (d->connection); | 88 markobj (d->connection); |
88 mark_object (d->canon_connection); | 89 markobj (d->canon_connection); |
89 mark_object (d->console); | 90 markobj (d->console); |
90 mark_object (d->selected_frame); | 91 markobj (d->selected_frame); |
91 mark_object (d->frame_with_focus_real); | 92 markobj (d->frame_with_focus_real); |
92 mark_object (d->frame_with_focus_for_hooks); | 93 markobj (d->frame_with_focus_for_hooks); |
93 mark_object (d->frame_that_ought_to_have_focus); | 94 markobj (d->frame_that_ought_to_have_focus); |
94 mark_object (d->device_class); | 95 markobj (d->device_class); |
95 mark_object (d->user_defined_tags); | 96 markobj (d->user_defined_tags); |
96 mark_object (d->pixel_to_glyph_cache.obj1); | 97 markobj (d->pixel_to_glyph_cache.obj1); |
97 mark_object (d->pixel_to_glyph_cache.obj2); | 98 markobj (d->pixel_to_glyph_cache.obj2); |
98 | 99 |
99 mark_object (d->color_instance_cache); | 100 markobj (d->color_instance_cache); |
100 mark_object (d->font_instance_cache); | 101 markobj (d->font_instance_cache); |
101 #ifdef MULE | 102 #ifdef MULE |
102 mark_object (d->charset_font_cache); | 103 markobj (d->charset_font_cache); |
103 #endif | 104 #endif |
104 mark_object (d->image_instance_cache); | 105 markobj (d->image_instance_cache); |
105 | 106 |
106 if (d->devmeths) | 107 if (d->devmeths) |
107 { | 108 { |
108 mark_object (d->devmeths->symbol); | 109 markobj (d->devmeths->symbol); |
109 MAYBE_DEVMETH (d, mark_device, (d)); | 110 MAYBE_DEVMETH (d, mark_device, (d, markobj)); |
110 } | 111 } |
111 | 112 |
112 return (d->frame_list); | 113 return (d->frame_list); |
113 } | 114 } |
114 | 115 |
123 XSTRING_DATA (d->name), d->header.uid); | 124 XSTRING_DATA (d->name), d->header.uid); |
124 | 125 |
125 sprintf (buf, "#<%s-device", !DEVICE_LIVE_P (d) ? "dead" : | 126 sprintf (buf, "#<%s-device", !DEVICE_LIVE_P (d) ? "dead" : |
126 DEVICE_TYPE_NAME (d)); | 127 DEVICE_TYPE_NAME (d)); |
127 write_c_string (buf, printcharfun); | 128 write_c_string (buf, printcharfun); |
128 if (DEVICE_LIVE_P (d) && !NILP (DEVICE_CONNECTION (d))) | 129 if (DEVICE_LIVE_P (d)) |
129 { | 130 { |
130 write_c_string (" on ", printcharfun); | 131 write_c_string (" on ", printcharfun); |
131 print_internal (DEVICE_CONNECTION (d), printcharfun, 1); | 132 print_internal (DEVICE_CONNECTION (d), printcharfun, 1); |
132 } | 133 } |
133 sprintf (buf, " 0x%x>", d->header.uid); | 134 sprintf (buf, " 0x%x>", d->header.uid); |
134 write_c_string (buf, printcharfun); | 135 write_c_string (buf, printcharfun); |
135 } | 136 } |
136 | 137 |
137 DEFINE_LRECORD_IMPLEMENTATION ("device", device, | 138 DEFINE_LRECORD_IMPLEMENTATION ("device", device, |
138 mark_device, print_device, 0, 0, 0, 0, | 139 mark_device, print_device, 0, 0, 0, |
139 struct device); | 140 struct device); |
140 | 141 |
141 int | 142 int |
142 valid_device_class_p (Lisp_Object class) | 143 valid_device_class_p (Lisp_Object class) |
143 { | 144 { |
384 | 385 |
385 static Lisp_Object | 386 static Lisp_Object |
386 semi_canonicalize_device_connection (struct console_methods *meths, | 387 semi_canonicalize_device_connection (struct console_methods *meths, |
387 Lisp_Object name, Error_behavior errb) | 388 Lisp_Object name, Error_behavior errb) |
388 { | 389 { |
389 if (HAS_CONTYPE_METH_P (meths, semi_canonicalize_device_connection)) | 390 return CONTYPE_METH_OR_GIVEN (meths, semi_canonicalize_device_connection, |
390 return CONTYPE_METH (meths, semi_canonicalize_device_connection, | 391 (name, errb), name); |
391 (name, errb)); | |
392 else | |
393 return CONTYPE_METH_OR_GIVEN (meths, canonicalize_device_connection, | |
394 (name, errb), name); | |
395 } | 392 } |
396 | 393 |
397 static Lisp_Object | 394 static Lisp_Object |
398 canonicalize_device_connection (struct console_methods *meths, | 395 canonicalize_device_connection (struct console_methods *meths, |
399 Lisp_Object name, Error_behavior errb) | 396 Lisp_Object name, Error_behavior errb) |
400 { | 397 { |
401 if (HAS_CONTYPE_METH_P (meths, canonicalize_device_connection)) | 398 return CONTYPE_METH_OR_GIVEN (meths, canonicalize_device_connection, |
402 return CONTYPE_METH (meths, canonicalize_device_connection, | 399 (name, errb), name); |
403 (name, errb)); | |
404 else | |
405 return CONTYPE_METH_OR_GIVEN (meths, semi_canonicalize_device_connection, | |
406 (name, errb), name); | |
407 } | 400 } |
408 | 401 |
409 static Lisp_Object | 402 static Lisp_Object |
410 find_device_of_type (struct console_methods *meths, Lisp_Object canon) | 403 find_device_of_type (struct console_methods *meths, Lisp_Object canon) |
411 { | 404 { |
889 recompute_all_cached_specifiers_in_frame (f); | 882 recompute_all_cached_specifiers_in_frame (f); |
890 MARK_FRAME_FACES_CHANGED (f); | 883 MARK_FRAME_FACES_CHANGED (f); |
891 MARK_FRAME_GLYPHS_CHANGED (f); | 884 MARK_FRAME_GLYPHS_CHANGED (f); |
892 MARK_FRAME_SUBWINDOWS_CHANGED (f); | 885 MARK_FRAME_SUBWINDOWS_CHANGED (f); |
893 MARK_FRAME_TOOLBARS_CHANGED (f); | 886 MARK_FRAME_TOOLBARS_CHANGED (f); |
894 MARK_FRAME_GUTTERS_CHANGED (f); | |
895 f->menubar_changed = 1; | 887 f->menubar_changed = 1; |
896 } | 888 } |
897 } | 889 } |
898 return Qnil; | 890 return Qnil; |
899 } | 891 } |
916 Return the output baud rate of DEVICE. | 908 Return the output baud rate of DEVICE. |
917 */ | 909 */ |
918 (device)) | 910 (device)) |
919 { | 911 { |
920 return make_int (DEVICE_BAUD_RATE (decode_device (device))); | 912 return make_int (DEVICE_BAUD_RATE (decode_device (device))); |
921 } | |
922 | |
923 DEFUN ("device-printer-p", Fdevice_printer_p, 0, 1, 0, /* | |
924 Return t if DEVICE is a printer, nil if it is a display. DEVICE defaults | |
925 to selected device if omitted, and must be live if specified. | |
926 */ | |
927 (device)) | |
928 { | |
929 return DEVICE_PRINTER_P (decode_device (device)) ? Qt : Qnil; | |
930 } | 913 } |
931 | 914 |
932 DEFUN ("device-system-metric", Fdevice_system_metric, 1, 3, 0, /* | 915 DEFUN ("device-system-metric", Fdevice_system_metric, 1, 3, 0, /* |
933 Get a metric for DEVICE as provided by the system. | 916 Get a metric for DEVICE as provided by the system. |
934 | 917 |
982 size-toolbar Toolbar width and height. | 965 size-toolbar Toolbar width and height. |
983 size-toolbar-button Toolbar button size. | 966 size-toolbar-button Toolbar button size. |
984 size-toolbar-border Toolbar border width and height. | 967 size-toolbar-border Toolbar border width and height. |
985 size-icon Icon dimensions. | 968 size-icon Icon dimensions. |
986 size-icon-small Small icon dimensions. | 969 size-icon-small Small icon dimensions. |
987 size-device Device screen or paper size in pixels. | 970 size-device Device screen size in pixels. |
988 size-workspace Workspace size in pixels. This can be less than or | 971 size-workspace Workspace size in pixels. This can be less than the |
989 equal to the above. For diplays, this is the area | 972 above if window manager has decorations which |
990 available to applications less window manager | 973 effectively shrink the area remaining for application |
991 decorations. For printers, this is the size of | 974 windows. |
992 printable area. | |
993 offset-workspace Offset of workspace area from the top left corner | |
994 of screen or paper, in pixels. | |
995 size-device-mm Device screen size in millimeters. | 975 size-device-mm Device screen size in millimeters. |
996 device-dpi Device resolution, in dots per inch. | 976 device-dpi Device resolution, in dots per inch. |
997 num-bit-planes Integer, number of device bit planes. | 977 num-bit-planes Integer, number of device bit planes. |
998 num-color-cells Integer, number of device color cells. | 978 num-color-cells Integer, number of device color cells. |
999 | 979 |
1046 FROB (size_toolbar_border); | 1026 FROB (size_toolbar_border); |
1047 FROB (size_icon); | 1027 FROB (size_icon); |
1048 FROB (size_icon_small); | 1028 FROB (size_icon_small); |
1049 FROB (size_device); | 1029 FROB (size_device); |
1050 FROB (size_workspace); | 1030 FROB (size_workspace); |
1051 FROB (offset_workspace); | |
1052 FROB (size_device_mm); | 1031 FROB (size_device_mm); |
1053 FROB (device_dpi); | 1032 FROB (device_dpi); |
1054 FROB (num_bit_planes); | 1033 FROB (num_bit_planes); |
1055 FROB (num_color_cells); | 1034 FROB (num_color_cells); |
1056 FROB (mouse_buttons); | 1035 FROB (mouse_buttons); |
1109 FROB (size_toolbar_border); | 1088 FROB (size_toolbar_border); |
1110 FROB (size_icon); | 1089 FROB (size_icon); |
1111 FROB (size_icon_small); | 1090 FROB (size_icon_small); |
1112 FROB (size_device); | 1091 FROB (size_device); |
1113 FROB (size_workspace); | 1092 FROB (size_workspace); |
1114 FROB (offset_workspace); | |
1115 FROB (size_device_mm); | 1093 FROB (size_device_mm); |
1116 FROB (device_dpi); | 1094 FROB (device_dpi); |
1117 FROB (num_bit_planes); | 1095 FROB (num_bit_planes); |
1118 FROB (num_color_cells); | 1096 FROB (num_color_cells); |
1119 FROB (mouse_buttons); | 1097 FROB (mouse_buttons); |
1198 asynch_device_change_method) (); | 1176 asynch_device_change_method) (); |
1199 } | 1177 } |
1200 /* reset the flag to 0 unless another notification occurred while | 1178 /* reset the flag to 0 unless another notification occurred while |
1201 we were processing this one. Block SIGWINCH during this | 1179 we were processing this one. Block SIGWINCH during this |
1202 check to prevent a possible race condition. */ | 1180 check to prevent a possible race condition. */ |
1203 #ifdef SIGWINCH | 1181 #ifndef WINDOWSNT |
1204 EMACS_BLOCK_SIGNAL (SIGWINCH); | 1182 EMACS_BLOCK_SIGNAL (SIGWINCH); |
1205 #endif | 1183 #endif |
1206 if (old_asynch_device_change_pending == asynch_device_change_pending) | 1184 if (old_asynch_device_change_pending == asynch_device_change_pending) |
1207 asynch_device_change_pending = 0; | 1185 asynch_device_change_pending = 0; |
1208 #ifdef SIGWINCH | 1186 #ifndef WINDOWSNT |
1209 EMACS_UNBLOCK_SIGNAL (SIGWINCH); | 1187 EMACS_UNBLOCK_SIGNAL (SIGWINCH); |
1210 #endif | 1188 #endif |
1211 } | 1189 } |
1212 | 1190 |
1213 void | 1191 void |
1243 /************************************************************************/ | 1221 /************************************************************************/ |
1244 | 1222 |
1245 void | 1223 void |
1246 syms_of_device (void) | 1224 syms_of_device (void) |
1247 { | 1225 { |
1248 INIT_LRECORD_IMPLEMENTATION (device); | |
1249 | |
1250 DEFSUBR (Fvalid_device_class_p); | 1226 DEFSUBR (Fvalid_device_class_p); |
1251 DEFSUBR (Fdevice_class_list); | 1227 DEFSUBR (Fdevice_class_list); |
1252 | 1228 |
1253 DEFSUBR (Fdfw_device); | 1229 DEFSUBR (Fdfw_device); |
1254 DEFSUBR (Fselected_device); | 1230 DEFSUBR (Fselected_device); |
1269 DEFSUBR (Fdevice_system_metrics); | 1245 DEFSUBR (Fdevice_system_metrics); |
1270 DEFSUBR (Fdevice_system_metric); | 1246 DEFSUBR (Fdevice_system_metric); |
1271 DEFSUBR (Fset_device_baud_rate); | 1247 DEFSUBR (Fset_device_baud_rate); |
1272 DEFSUBR (Fdevice_baud_rate); | 1248 DEFSUBR (Fdevice_baud_rate); |
1273 DEFSUBR (Fdomain_device_type); | 1249 DEFSUBR (Fdomain_device_type); |
1274 DEFSUBR (Fdevice_printer_p); | |
1275 | 1250 |
1276 defsymbol (&Qdevicep, "devicep"); | 1251 defsymbol (&Qdevicep, "devicep"); |
1277 defsymbol (&Qdevice_live_p, "device-live-p"); | 1252 defsymbol (&Qdevice_live_p, "device-live-p"); |
1253 defsymbol (&Qdelete_device, "delete-device"); | |
1278 | 1254 |
1279 defsymbol (&Qcreate_device_hook, "create-device-hook"); | 1255 defsymbol (&Qcreate_device_hook, "create-device-hook"); |
1280 defsymbol (&Qdelete_device_hook, "delete-device-hook"); | 1256 defsymbol (&Qdelete_device_hook, "delete-device-hook"); |
1281 | 1257 |
1282 /* Qcolor defined in general.c */ | 1258 /* Qcolor defined in general.c */ |
1309 defsymbol (&Qsize_toolbar_border, "size-toolbar-border"); | 1285 defsymbol (&Qsize_toolbar_border, "size-toolbar-border"); |
1310 defsymbol (&Qsize_icon, "size-icon"); | 1286 defsymbol (&Qsize_icon, "size-icon"); |
1311 defsymbol (&Qsize_icon_small, "size-icon-small"); | 1287 defsymbol (&Qsize_icon_small, "size-icon-small"); |
1312 defsymbol (&Qsize_device, "size-device"); | 1288 defsymbol (&Qsize_device, "size-device"); |
1313 defsymbol (&Qsize_workspace, "size-workspace"); | 1289 defsymbol (&Qsize_workspace, "size-workspace"); |
1314 defsymbol (&Qoffset_workspace, "offset-workspace"); | |
1315 defsymbol (&Qsize_device_mm, "size-device-mm"); | 1290 defsymbol (&Qsize_device_mm, "size-device-mm"); |
1316 defsymbol (&Qnum_bit_planes, "num-bit-planes"); | 1291 defsymbol (&Qnum_bit_planes, "num-bit-planes"); |
1317 defsymbol (&Qnum_color_cells, "num-color-cells"); | 1292 defsymbol (&Qnum_color_cells, "num-color-cells"); |
1318 defsymbol (&Qdevice_dpi, "device-dpi"); | 1293 defsymbol (&Qdevice_dpi, "device-dpi"); |
1319 defsymbol (&Qmouse_buttons, "mouse-buttons"); | 1294 defsymbol (&Qmouse_buttons, "mouse-buttons"); |
1322 defsymbol (&Qslow_device, "slow-device"); | 1297 defsymbol (&Qslow_device, "slow-device"); |
1323 defsymbol (&Qsecurity, "security"); | 1298 defsymbol (&Qsecurity, "security"); |
1324 } | 1299 } |
1325 | 1300 |
1326 void | 1301 void |
1327 reinit_vars_of_device (void) | |
1328 { | |
1329 staticpro_nodump (&Vdefault_device); | |
1330 Vdefault_device = Qnil; | |
1331 asynch_device_change_pending = 0; | |
1332 } | |
1333 | |
1334 void | |
1335 vars_of_device (void) | 1302 vars_of_device (void) |
1336 { | 1303 { |
1337 reinit_vars_of_device (); | |
1338 | |
1339 DEFVAR_LISP ("create-device-hook", &Vcreate_device_hook /* | 1304 DEFVAR_LISP ("create-device-hook", &Vcreate_device_hook /* |
1340 Function or functions to call when a device is created. | 1305 Function or functions to call when a device is created. |
1341 One argument, the newly-created device. | 1306 One argument, the newly-created device. |
1342 This is called after the first frame has been created, but before | 1307 This is called after the first frame has been created, but before |
1343 calling the `create-frame-hook'. | 1308 calling the `create-frame-hook'. |
1349 Function or functions to call when a device is deleted. | 1314 Function or functions to call when a device is deleted. |
1350 One argument, the to-be-deleted device. | 1315 One argument, the to-be-deleted device. |
1351 */ ); | 1316 */ ); |
1352 Vdelete_device_hook = Qnil; | 1317 Vdelete_device_hook = Qnil; |
1353 | 1318 |
1319 staticpro (&Vdefault_device); | |
1320 Vdefault_device = Qnil; | |
1321 | |
1322 asynch_device_change_pending = 0; | |
1323 | |
1354 Vdevice_class_list = list3 (Qcolor, Qgrayscale, Qmono); | 1324 Vdevice_class_list = list3 (Qcolor, Qgrayscale, Qmono); |
1355 staticpro (&Vdevice_class_list); | 1325 staticpro (&Vdevice_class_list); |
1356 | 1326 |
1357 /* Death to devices.el !!! */ | 1327 /* Death to devices.el !!! */ |
1358 Fprovide(intern("devices")); | 1328 Fprovide(intern("devices")); |