aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2007-03-26 08:12:55 +0000
committerYAMAMOTO Mitsuharu2007-03-26 08:12:55 +0000
commit08f8ca19156a38aee5cd167e62cf69f47be408f9 (patch)
treeadcff0c1f0c888fe8a34b2829118103c98646fe9 /src
parent8907f65c8578507d034e860967a9e0c18e2f42bf (diff)
downloademacs-08f8ca19156a38aee5cd167e62cf69f47be408f9.tar.gz
emacs-08f8ca19156a38aee5cd167e62cf69f47be408f9.zip
(Fx_display_mm_height, Fx_display_mm_width): Scale
whole screen size in pixels by millimeters per pixel of main display.
Diffstat (limited to 'src')
-rw-r--r--src/macfns.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/macfns.c b/src/macfns.c
index d4483621654..b7a8cd7e974 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -3105,8 +3105,8 @@ If omitted or nil, that stands for the selected frame's 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 float mm_per_pixel;
3108 3109
3109 /* Only of the main display. */
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)
@@ -3116,9 +3116,8 @@ If omitted or nil, that stands for the selected frame's display. */)
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
@@ -3127,9 +3126,11 @@ If omitted or nil, that stands for the selected frame's display. */)
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
3135DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 3136DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -3141,8 +3142,8 @@ If omitted or nil, that stands for the selected frame's 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);
3145 float mm_per_pixel;
3144 3146
3145 /* Only of the main display. */
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)
@@ -3152,9 +3153,8 @@ If omitted or nil, that stands for the selected frame's display. */)
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
@@ -3163,9 +3163,11 @@ If omitted or nil, that stands for the selected frame's display. */)
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
3171DEFUN ("x-display-backing-store", Fx_display_backing_store, 3173DEFUN ("x-display-backing-store", Fx_display_backing_store,