comparison src/device.c @ 282:c42ec1d1cded r21-0b39

Import from CVS: tag r21-0b39
author cvs
date Mon, 13 Aug 2007 10:33:18 +0200
parents c5d627a313b1
children 558f606b08ae
comparison
equal deleted inserted replaced
281:090b52736db2 282:c42ec1d1cded
53 Lisp_Object Vcreate_device_hook, Vdelete_device_hook; 53 Lisp_Object Vcreate_device_hook, Vdelete_device_hook;
54 54
55 /* Device classes */ 55 /* Device classes */
56 /* Qcolor defined in general.c */ 56 /* Qcolor defined in general.c */
57 Lisp_Object Qgrayscale, Qmono; 57 Lisp_Object Qgrayscale, Qmono;
58
59 /* Device metrics symbols */
60 Lisp_Object Qcolor_default, Qcolor_select, Qcolor_balloon, Qcolor_3d_face;
61 Lisp_Object Qcolor_3d_light, Qcolor_3d_dark, Qcolor_menu, Qcolor_menu_high;
62 Lisp_Object Qcolor_menu_button, Qcolor_menu_unsel, Qcolor_toolbar;
63 Lisp_Object Qcolor_scrollbar, Qcolor_desktop, Qcolor_workspace, Qfont_default;
64 Lisp_Object Qfont_menubar, Qfont_dialog, Qsize_cursor, Qsize_scrollbar;
65 Lisp_Object Qsize_menu, Qsize_toolbar, Qsize_tbbutton, Qsize_tbborder, Qsize_icon;
66 Lisp_Object Qsize_icon_small, Qsize_device, Qsize_workspace, Qsize_device_mm;
67 Lisp_Object Qdevice_dpi, Qmouse_buttons, Qswap_buttons;
68 Lisp_Object Qshow_sounds, Qslow_device, Qsecurity, Qdbcs, Qime, Qmid_east;
69 Lisp_Object Qnum_bit_planes, Qnum_color_cells;
58 70
59 Lisp_Object Qdevicep, Qdevice_live_p; 71 Lisp_Object Qdevicep, Qdevice_live_p;
60 Lisp_Object Qdelete_device; 72 Lisp_Object Qdelete_device;
61 Lisp_Object Qcreate_device_hook; 73 Lisp_Object Qcreate_device_hook;
62 Lisp_Object Qdelete_device_hook; 74 Lisp_Object Qdelete_device_hook;
260 272
261 /* select the device's selected frame's selected window. This will call 273 /* select the device's selected frame's selected window. This will call
262 selected_frame_1()->selected_device_1()->selected_console_1(). */ 274 selected_frame_1()->selected_device_1()->selected_console_1(). */
263 if (!NILP (DEVICE_SELECTED_FRAME (XDEVICE (device)))) 275 if (!NILP (DEVICE_SELECTED_FRAME (XDEVICE (device))))
264 Fselect_window (FRAME_SELECTED_WINDOW 276 Fselect_window (FRAME_SELECTED_WINDOW
265 (XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device))))); 277 (XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device)))),
278 Qnil);
266 else 279 else
267 error ("Can't select a device with no frames"); 280 error ("Can't select a device with no frames");
268 return Qnil; 281 return Qnil;
269 } 282 }
270 283
868 } 881 }
869 } 882 }
870 return Qnil; 883 return Qnil;
871 } 884 }
872 885
873 DEFUN ("device-pixel-width", Fdevice_pixel_width, 0, 1, 0, /*
874 Return the width in pixels of DEVICE, or nil if unknown.
875 */
876 (device))
877 {
878 struct device *d = decode_device (device);
879 int retval = DEVMETH_OR_GIVEN (d, device_pixel_width, (d), 0);
880
881 return retval <= 0 ? Qnil : make_int (retval);
882 }
883
884 DEFUN ("device-pixel-height", Fdevice_pixel_height, 0, 1, 0, /*
885 Return the height in pixels of DEVICE, or nil if unknown.
886 */
887 (device))
888 {
889 struct device *d = decode_device (device);
890 int retval = DEVMETH_OR_GIVEN (d, device_pixel_height, (d), 0);
891
892 return retval <= 0 ? Qnil : make_int (retval);
893 }
894
895 DEFUN ("device-mm-width", Fdevice_mm_width, 0, 1, 0, /*
896 Return the width in millimeters of DEVICE, or nil if unknown.
897 */
898 (device))
899 {
900 struct device *d = decode_device (device);
901 int retval = DEVMETH_OR_GIVEN (d, device_mm_width, (d), 0);
902
903 return retval <= 0 ? Qnil : make_int (retval);
904 }
905
906 DEFUN ("device-mm-height", Fdevice_mm_height, 0, 1, 0, /*
907 Return the height in millimeters of DEVICE, or nil if unknown.
908 */
909 (device))
910 {
911 struct device *d = decode_device (device);
912 int retval = DEVMETH_OR_GIVEN (d, device_mm_height, (d), 0);
913
914 return retval <= 0 ? Qnil : make_int (retval);
915 }
916
917 DEFUN ("device-bitplanes", Fdevice_bitplanes, 0, 1, 0, /*
918 Return the number of bitplanes of DEVICE, or nil if unknown.
919 */
920 (device))
921 {
922 struct device *d = decode_device (device);
923 int retval = DEVMETH_OR_GIVEN (d, device_bitplanes, (d), 0);
924
925 return retval <= 0 ? Qnil : make_int (retval);
926 }
927
928 DEFUN ("device-color-cells", Fdevice_color_cells, 0, 1, 0, /*
929 Return the number of color cells of DEVICE, or nil if unknown.
930 */
931 (device))
932 {
933 struct device *d = decode_device (device);
934 int retval = DEVMETH_OR_GIVEN (d, device_color_cells, (d), 0);
935
936 return retval <= 0 ? Qnil : make_int (retval);
937 }
938
939 DEFUN ("set-device-baud-rate", Fset_device_baud_rate, 2, 2, 0, /* 886 DEFUN ("set-device-baud-rate", Fset_device_baud_rate, 2, 2, 0, /*
940 Set the output baud rate of DEVICE to RATE. 887 Set the output baud rate of DEVICE to RATE.
941 On most systems, changing this value will affect the amount of padding 888 On most systems, changing this value will affect the amount of padding
942 and other strategic decisions made during redisplay. 889 and other strategic decisions made during redisplay.
943 */ 890 */
954 Return the output baud rate of DEVICE. 901 Return the output baud rate of DEVICE.
955 */ 902 */
956 (device)) 903 (device))
957 { 904 {
958 return make_int (DEVICE_BAUD_RATE (decode_device (device))); 905 return make_int (DEVICE_BAUD_RATE (decode_device (device)));
906 }
907
908 DEFUN ("device-system-metrics", Fdevice_system_metrics, 2, 2, 0, /*
909 Get metrics for DEVICE as provided by the system.
910
911 METRIC must be a symbol specifying requested metric. Note that
912 the metrics returned are these provided by the system internally,
913 not read from resources, so obtained from the mostly internal level.
914
915 If a metric is not provided by the system, return value is nil.
916 Boolean values are returned as zero and non-zero integers.
917
918 Metrics, by group, are:
919
920 COLORS. Colors are returned as valid color instantiators. No other
921 assumption on the returned valie should be made (i.e. it can be a
922 string on one system but a color instance on another). For colors,
923 returned value is a cons of foreground and background colors. Note
924 that if the system provides only one color of the pair, the second
925 one may be nil.
926
927 'color-default Standard window text foreground and background.
928 'color-select Selection highligh text and backgroun colors.
929 'color-balloon Ballon popup text and background colors.
930 'color-3d-face 3-D object (button, modeline) text and surface colors.
931 'color-3d-light Fore and back colors for 3-D edges facing light source.
932 'color-3d-dark Fore and back colors for 3-D edges facing away from
933 light source.
934 'color-menu Text and background for menus
935 'color-menu-high Selected menu item colors
936 'color-menu-button Menu button colors
937 'color-menu-unsel Unselectable menu item colors
938 'color-toolbar Toolbar foreground and background colors
939 'color-scrollbar Scrollbar foreground and background colors
940 'color-desktop Desktop window colors
941 'color-workspace Workspace window colors
942
943 FONTS. Fonts are returned as valid font instantiators. No other
944 assumption on the returned value should be made (i.e. it can be a
945 string on one system but font instance on another).
946
947 'font-default Default fixed width font.
948 'font-menubar Menubar font
949 'font-dialog Dialog boxes font
950
951 GEOMETRY. These metrics are returned as conses of (X . Y). As with colors,
952 either car or cdr of the cons may be nil if the system does not provide one
953 of corresponding dimensions.
954 'size-cursor Mouse cursor size.
955 'size-scrollbar Scrollbars (WIDTH . HEIGHT)
956 'size-menu Menubar height, as (nil . HEIGHT)
957 'size-toolbar Toolbar width and height.
958 'size-tbbutton Toolbar button size.
959 'size-tbborder Toolbar border width and height.
960 'size-icon Icon dimensions.
961 'size-icon-small Small icon dimensions.
962 'size-device Device screen size in pixels.
963 'size-workspace Workspace size in pixels. This can be less than the above
964 if window manager has decorations which effectively shrink
965 the area remaining for application windows.
966 'size-device-mm Device screen size in millimeters.
967 'device-dpi Device resolution, in dots per inch.
968
969 'num-bit-planes Integer, number of deive bit planes.
970 'num-color-cells Integer, number of device color cells.
971
972 FEATURES. This group reports various device features. Boolean values retuned
973 as integer 1 for true and zero for false, or nil if the feature is unknown
974 for the system.
975
976 'mouse-buttons Number of mouse buttons, or zero if no mouse (integer).
977 'swap-buttons Non-zero if left and right mouse buttons are swapped
978 'show-sounds User preference for visual over audible bell (boolean).
979 'slow-device Device is slow, avoid animation (boolean).
980 'security Non-zero if user environment is secure.
981 'dbcs Window system supports DBCS (boolean).
982 'ime Device embeds an input method editor (boolean).
983 'mid-east Non-zero if the window system is enabled for Hebrew
984 and Arabic (left-to-right reading) languages.
985 */
986 (device, metric))
987 {
988 struct device *d = decode_device (device);
989 enum device_metrics m;
990
991 /* Decode metric */
992 if (EQ (metric, Qcolor_default)) m = color_default;
993 else if (EQ (metric, Qcolor_select)) m = color_select;
994 else if (EQ (metric, Qcolor_balloon)) m = color_balloon;
995 else if (EQ (metric, Qcolor_3d_face)) m = color_3d_face;
996 else if (EQ (metric, Qcolor_3d_light)) m = color_3d_light;
997 else if (EQ (metric, Qcolor_3d_dark)) m = color_3d_dark;
998 else if (EQ (metric, Qcolor_menu)) m = color_menu;
999 else if (EQ (metric, Qcolor_menu_high)) m = color_menu_high;
1000 else if (EQ (metric, Qcolor_menu_button)) m = color_menu_button;
1001 else if (EQ (metric, Qcolor_menu_unsel)) m = color_menu_unsel;
1002 else if (EQ (metric, Qcolor_toolbar)) m = color_toolbar;
1003 else if (EQ (metric, Qcolor_scrollbar)) m = color_scrollbar;
1004 else if (EQ (metric, Qcolor_desktop)) m = color_desktop;
1005 else if (EQ (metric, Qcolor_workspace)) m = color_workspace;
1006 else if (EQ (metric, Qfont_default)) m = font_default;
1007 else if (EQ (metric, Qfont_menubar)) m = font_menubar;
1008 else if (EQ (metric, Qfont_dialog)) m = font_dialog;
1009 else if (EQ (metric, Qsize_cursor)) m = size_cursor;
1010 else if (EQ (metric, Qsize_scrollbar)) m = size_scrollbar;
1011 else if (EQ (metric, Qsize_menu)) m = size_menu;
1012 else if (EQ (metric, Qsize_toolbar)) m = size_toolbar;
1013 else if (EQ (metric, Qsize_tbbutton)) m = size_tbbutton;
1014 else if (EQ (metric, Qsize_tbborder)) m = size_tbborder;
1015 else if (EQ (metric, Qsize_icon)) m = size_icon;
1016 else if (EQ (metric, Qsize_icon_small)) m = size_icon_small;
1017 else if (EQ (metric, Qsize_device)) m = size_device;
1018 else if (EQ (metric, Qsize_workspace)) m = size_workspace;
1019 else if (EQ (metric, Qsize_device_mm)) m = size_device_mm;
1020 else if (EQ (metric, Qdevice_dpi)) m = device_dpi;
1021 else if (EQ (metric, Qnum_bit_planes)) m = num_bit_planes;
1022 else if (EQ (metric, Qnum_color_cells)) m = num_color_cells;
1023 else if (EQ (metric, Qmouse_buttons)) m = mouse_buttons;
1024 else if (EQ (metric, Qswap_buttons)) m = swap_buttons;
1025 else if (EQ (metric, Qshow_sounds)) m = show_sounds;
1026 else if (EQ (metric, Qslow_device)) m = slow_device;
1027 else if (EQ (metric, Qsecurity)) m = security;
1028 else if (EQ (metric, Qdbcs)) m = dbcs;
1029 else if (EQ (metric, Qime)) m = ime;
1030 else if (EQ (metric, Qmid_east)) m = mid_east;
1031 else
1032 signal_simple_error ("Invalid device metric symbol", metric);
1033
1034 return DEVMETH_OR_GIVEN (d, device_system_metrics, (d, m), Qnil);
959 } 1035 }
960 1036
961 Lisp_Object 1037 Lisp_Object
962 domain_device_type (Lisp_Object domain) 1038 domain_device_type (Lisp_Object domain)
963 { 1039 {
1093 DEFSUBR (Fmake_device); 1169 DEFSUBR (Fmake_device);
1094 DEFSUBR (Fdelete_device); 1170 DEFSUBR (Fdelete_device);
1095 DEFSUBR (Fdevice_frame_list); 1171 DEFSUBR (Fdevice_frame_list);
1096 DEFSUBR (Fdevice_class); 1172 DEFSUBR (Fdevice_class);
1097 DEFSUBR (Fset_device_class); 1173 DEFSUBR (Fset_device_class);
1098 DEFSUBR (Fdevice_pixel_width); 1174 DEFSUBR (Fdevice_system_metrics);
1099 DEFSUBR (Fdevice_pixel_height);
1100 DEFSUBR (Fdevice_mm_width);
1101 DEFSUBR (Fdevice_mm_height);
1102 DEFSUBR (Fdevice_bitplanes);
1103 DEFSUBR (Fdevice_color_cells);
1104 DEFSUBR (Fset_device_baud_rate); 1175 DEFSUBR (Fset_device_baud_rate);
1105 DEFSUBR (Fdevice_baud_rate); 1176 DEFSUBR (Fdevice_baud_rate);
1106 DEFSUBR (Fdomain_device_type); 1177 DEFSUBR (Fdomain_device_type);
1107 1178
1108 defsymbol (&Qdevicep, "devicep"); 1179 defsymbol (&Qdevicep, "devicep");
1113 defsymbol (&Qdelete_device_hook, "delete-device-hook"); 1184 defsymbol (&Qdelete_device_hook, "delete-device-hook");
1114 1185
1115 /* Qcolor defined in general.c */ 1186 /* Qcolor defined in general.c */
1116 defsymbol (&Qgrayscale, "grayscale"); 1187 defsymbol (&Qgrayscale, "grayscale");
1117 defsymbol (&Qmono, "mono"); 1188 defsymbol (&Qmono, "mono");
1189
1190 /* Device metrics symbols */
1191 defsymbol (&Qcolor_default, "color-default");
1192 defsymbol (&Qcolor_select, "color-select");
1193 defsymbol (&Qcolor_balloon, "color-balloon");
1194 defsymbol (&Qcolor_3d_face, "color-3d-face");
1195 defsymbol (&Qcolor_3d_light, "color-3d-light");
1196 defsymbol (&Qcolor_3d_dark, "color-3d-dark");
1197 defsymbol (&Qcolor_menu, "color-menu");
1198 defsymbol (&Qcolor_menu_high, "color-menu-high");
1199 defsymbol (&Qcolor_menu_button, "color-menu-button");
1200 defsymbol (&Qcolor_menu_unsel, "color-menu-unsel");
1201 defsymbol (&Qcolor_toolbar, "color-toolbar");
1202 defsymbol (&Qcolor_scrollbar, "color-scrollbar");
1203 defsymbol (&Qcolor_desktop, "color-desktop");
1204 defsymbol (&Qcolor_workspace, "color-workspace");
1205 defsymbol (&Qfont_default, "font-default");
1206 defsymbol (&Qfont_menubar, "font-menubar");
1207 defsymbol (&Qfont_dialog, "font-dialog");
1208 defsymbol (&Qsize_cursor, "size-cursor");
1209 defsymbol (&Qsize_scrollbar, "size-scrollbar");
1210 defsymbol (&Qsize_menu, "size-menu");
1211 defsymbol (&Qsize_toolbar, "size-toolbar");
1212 defsymbol (&Qsize_tbbutton, "size-tbbutton");
1213 defsymbol (&Qsize_tbborder, "size-tbborder");
1214 defsymbol (&Qsize_icon, "size-icon");
1215 defsymbol (&Qsize_icon_small, "size-icon-small");
1216 defsymbol (&Qsize_device, "size-device");
1217 defsymbol (&Qsize_workspace, "size-workspace");
1218 defsymbol (&Qsize_device_mm, "size-device-mm");
1219 defsymbol (&Qnum_bit_planes, "num-bit-planes");
1220 defsymbol (&Qnum_color_cells, "num-color-cells");
1221 defsymbol (&Qdevice_dpi, "device-dpi");
1222 defsymbol (&Qmouse_buttons, "mouse-buttons");
1223 defsymbol (&Qswap_buttons, "swap-buttons");
1224 defsymbol (&Qshow_sounds, "show-sounds");
1225 defsymbol (&Qslow_device, "slow-device");
1226 defsymbol (&Qsecurity, "security");
1227 defsymbol (&Qdbcs, "dbcs");
1228 defsymbol (&Qime, "ime");
1229 defsymbol (&Qmid_east, "mid-east");
1118 } 1230 }
1119 1231
1120 void 1232 void
1121 vars_of_device (void) 1233 vars_of_device (void)
1122 { 1234 {