comparison src/macfns.c @ 76744:726af0adfd34

(Fx_display_mm_height, Fx_display_mm_width): Scale whole screen size in pixels by millimeters per pixel of main display.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Mon, 26 Mar 2007 08:12:55 +0000
parents 742ee8b5b284
children 922696f363b0 6a7b94200117 dc002877ce12 4ef881a120fe
comparison
equal deleted inserted replaced
76743:fe33a7b5e7bd 76744:726af0adfd34
3103 If omitted or nil, that stands for the selected frame's display. */) 3103 If omitted or nil, that stands for the selected frame's display. */)
3104 (display) 3104 (display)
3105 Lisp_Object display; 3105 Lisp_Object display;
3106 { 3106 {
3107 struct mac_display_info *dpyinfo = check_x_display_info (display); 3107 struct mac_display_info *dpyinfo = check_x_display_info (display);
3108 3108 float mm_per_pixel;
3109 /* Only of the main display. */ 3109
3110 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 3110 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
3111 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020 3111 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3112 if (CGDisplayScreenSize != NULL) 3112 if (CGDisplayScreenSize != NULL)
3113 #endif 3113 #endif
3114 { 3114 {
3115 CGSize size; 3115 CGSize size;
3116 3116
3117 BLOCK_INPUT; 3117 BLOCK_INPUT;
3118 size = CGDisplayScreenSize (kCGDirectMainDisplay); 3118 size = CGDisplayScreenSize (kCGDirectMainDisplay);
3119 mm_per_pixel = size.height / CGDisplayPixelsHigh (kCGDirectMainDisplay);
3119 UNBLOCK_INPUT; 3120 UNBLOCK_INPUT;
3120
3121 return make_number ((int) (size.height + .5f));
3122 } 3121 }
3123 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020 3122 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3124 else 3123 else
3125 #endif 3124 #endif
3126 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ 3125 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
3127 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020 3126 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3128 { 3127 {
3129 /* This is an approximation. */ 3128 /* This is an approximation. */
3130 return make_number ((int) (dpyinfo->height * 25.4 / dpyinfo->resy)); 3129 mm_per_pixel = 25.4f / dpyinfo->resy;
3131 } 3130 }
3132 #endif 3131 #endif
3132
3133 return make_number ((int) (dpyinfo->height * mm_per_pixel + 0.5f));
3133 } 3134 }
3134 3135
3135 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 3136 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
3136 doc: /* Return the width in millimeters of DISPLAY. 3137 doc: /* Return the width in millimeters of DISPLAY.
3137 The optional argument DISPLAY specifies which display to ask about. 3138 The optional argument DISPLAY specifies which display to ask about.
3139 If omitted or nil, that stands for the selected frame's display. */) 3140 If omitted or nil, that stands for the selected frame's display. */)
3140 (display) 3141 (display)
3141 Lisp_Object display; 3142 Lisp_Object display;
3142 { 3143 {
3143 struct mac_display_info *dpyinfo = check_x_display_info (display); 3144 struct mac_display_info *dpyinfo = check_x_display_info (display);
3144 3145 float mm_per_pixel;
3145 /* Only of the main display. */ 3146
3146 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 3147 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
3147 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020 3148 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3148 if (CGDisplayScreenSize != NULL) 3149 if (CGDisplayScreenSize != NULL)
3149 #endif 3150 #endif
3150 { 3151 {
3151 CGSize size; 3152 CGSize size;
3152 3153
3153 BLOCK_INPUT; 3154 BLOCK_INPUT;
3154 size = CGDisplayScreenSize (kCGDirectMainDisplay); 3155 size = CGDisplayScreenSize (kCGDirectMainDisplay);
3156 mm_per_pixel = size.width / CGDisplayPixelsWide (kCGDirectMainDisplay);
3155 UNBLOCK_INPUT; 3157 UNBLOCK_INPUT;
3156
3157 return make_number ((int) (size.width + .5f));
3158 } 3158 }
3159 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020 3159 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3160 else 3160 else
3161 #endif 3161 #endif
3162 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */ 3162 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
3163 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020 3163 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3164 { 3164 {
3165 /* This is an approximation. */ 3165 /* This is an approximation. */
3166 return make_number ((int) (dpyinfo->width * 25.4 / dpyinfo->resx)); 3166 mm_per_pixel = 25.4f / dpyinfo->resx;
3167 } 3167 }
3168 #endif 3168 #endif
3169
3170 return make_number ((int) (dpyinfo->width * mm_per_pixel + 0.5f));
3169 } 3171 }
3170 3172
3171 DEFUN ("x-display-backing-store", Fx_display_backing_store, 3173 DEFUN ("x-display-backing-store", Fx_display_backing_store,
3172 Sx_display_backing_store, 0, 1, 0, 3174 Sx_display_backing_store, 0, 1, 0,
3173 doc: /* Returns an indication of whether DISPLAY does backing store. 3175 doc: /* Returns an indication of whether DISPLAY does backing store.