unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ralf Angeli <angeli@caeruleus.net>
Subject: Re: display-mm-width return value off on Windows
Date: Sat, 05 Aug 2006 16:50:16 +0200	[thread overview]
Message-ID: <eb2b77$3ih$2@sea.gmane.org> (raw)
In-Reply-To: e8jih2$pn0$1@sea.gmane.org

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

* Ralf Angeli (2006-07-06) writes:

> On Windows the return values of `display-mm-width' and
> `display-mm-height' don't really reflect the screen width and height
> in millimeters.

Meanwhile we got another bug report on the AUCTeX list related to this
issue.

I provided a patch for w32fns.c the majority of developers were in
favor of but which hasn't been checked into CVS and a patch for
frame.el about which I haven't got feedback.  I am adding them to this
mail again with updated change log entries for reference:

2006-08-05  Ralf Angeli  <angeli@caeruleus.net>

	* w32fns.c (Fx_display_mm_height, Fx_display_mm_width): Calculate
	size of display by means of size in pixels and number of pixels
	per inch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: w32fns.c.patch --]
[-- Type: text/x-patch, Size: 1256 bytes --]

Index: w32fns.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32fns.c,v
retrieving revision 1.275
diff -u -r1.275 w32fns.c
--- w32fns.c	4 Aug 2006 17:21:21 -0000	1.275
+++ w32fns.c	5 Aug 2006 14:37:37 -0000
@@ -6537,15 +6537,16 @@
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
   HDC hdc;
-  int cap;
+  int height;
 
   hdc = GetDC (dpyinfo->root_window);
 
-  cap = GetDeviceCaps (hdc, VERTSIZE);
+  height = round (25.4 * GetDeviceCaps (hdc, VERTRES)
+		  / GetDeviceCaps (hdc, LOGPIXELSY));
 
   ReleaseDC (dpyinfo->root_window, hdc);
 
-  return make_number (cap);
+  return make_number (height);
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -6559,15 +6560,16 @@
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
   HDC hdc;
-  int cap;
+  int width;
 
   hdc = GetDC (dpyinfo->root_window);
 
-  cap = GetDeviceCaps (hdc, HORZSIZE);
+  width = round (25.4 * GetDeviceCaps (hdc, HORZRES)
+		 / GetDeviceCaps (hdc, LOGPIXELSX));
 
   ReleaseDC (dpyinfo->root_window, hdc);
 
-  return make_number (cap);
+  return make_number (width);
 }
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,

[-- Attachment #3: Type: text/plain, Size: 156 bytes --]


2006-08-05  Ralf Angeli  <angeli@caeruleus.net>

	* frame.el (display-mm-dimensions-alist): New variable.
	(display-mm-height, display-mm-width): Use it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: frame.el.patch --]
[-- Type: text/x-patch, Size: 1900 bytes --]

Index: frame.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/frame.el,v
retrieving revision 1.237
diff -u -r1.237 frame.el
--- frame.el	21 Jul 2006 07:42:52 -0000	1.237
+++ frame.el	5 Aug 2006 14:36:20 -0000
@@ -1083,17 +1083,35 @@
      (t
       (frame-width (if (framep display) display (selected-frame)))))))
 
+(defcustom display-mm-dimensions-alist nil
+  "Alist for specifying screen dimensions in millimeters.
+Each element of the alist has the form (display . (width . height)),
+e.g. (\":0.0\" . (287 . 215)).
+
+The dimensions will be used for `display-mm-height' and
+`display-mm-width' if defined for the respective display."
+  :version "22.1"
+  :type '(alist :key-type (string :tag "Display")
+		:value-type (cons :tag "Dimensions"
+				  (integer :tag "Width")
+				  (integer :tag "Height")))
+  :group 'frames)
+
 (defun display-mm-height (&optional display)
   "Return the height of DISPLAY's screen in millimeters.
 If the information is unavailable, value is nil."
-  (and (memq (framep-on-display display) '(x w32 mac))
-       (x-display-mm-height display)))
+  (or (cddr (assoc (or display (frame-parameter nil 'display))
+		   display-mm-dimensions-alist))
+      (and (memq (framep-on-display display) '(x w32 mac))
+	   (x-display-mm-height display))))
 
 (defun display-mm-width (&optional display)
   "Return the width of DISPLAY's screen in millimeters.
 If the information is unavailable, value is nil."
-  (and (memq (framep-on-display display) '(x w32 mac))
-       (x-display-mm-width display)))
+  (or (cadr (assoc (or display (frame-parameter nil 'display))
+		   display-mm-dimensions-alist))
+      (and (memq (framep-on-display display) '(x w32 mac))
+	   (x-display-mm-width display))))
 
 (defun display-backing-store (&optional display)
   "Return the backing store capability of DISPLAY's screen.

[-- Attachment #5: Type: text/plain, Size: 232 bytes --]


Could somebody please apply at least one of them or tell me what to
change in order for them to get accepted?  I am planning to upload a
new precompiled version of Emacs for Windows to alpha.gnu.org once
this is settled.

-- 
Ralf

[-- Attachment #6: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  parent reply	other threads:[~2006-08-05 14:50 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-06 17:50 display-mm-width return value off on Windows Ralf Angeli
2006-07-06 21:08 ` Eli Zaretskii
2006-07-06 21:25   ` David Kastrup
2006-07-07  5:56   ` Ralf Angeli
2006-07-07 10:18     ` Eli Zaretskii
2006-07-07 10:22     ` Eli Zaretskii
2006-07-07 12:05       ` Lennart Borgman
2006-07-07 16:54       ` Ralf Angeli
2006-07-08 12:58         ` Eli Zaretskii
2006-07-08 13:23           ` Lennart Borgman
2006-07-08 14:42             ` Eli Zaretskii
2006-07-08 21:27             ` Jason Rumney
2006-07-08 22:23               ` David Kastrup
2006-07-08 23:03                 ` Jason Rumney
2006-07-09  7:36                   ` Ralf Angeli
2006-07-09  8:03                     ` David Kastrup
2006-07-09  7:41               ` Ralf Angeli
2006-07-09  8:05                 ` David Kastrup
2006-07-09 18:37                 ` Eli Zaretskii
2006-07-10 10:30                   ` Kim F. Storm
2006-07-10 10:45                     ` David Kastrup
2006-07-10 13:29                       ` Jason Rumney
2006-07-10 14:19                         ` David Kastrup
2006-07-10 21:28                           ` Jason Rumney
2006-07-10 22:05                             ` David Kastrup
2006-07-10 20:12                     ` Eli Zaretskii
2006-07-10 23:17                       ` Kim F. Storm
2006-07-10 23:22                         ` David Kastrup
2006-07-11 18:43                   ` Ralf Angeli
2006-07-12 13:07                     ` Kim F. Storm
2006-07-12 19:22                     ` Richard Stallman
2006-07-13 19:38                       ` Ralf Angeli
2006-07-13 19:59                         ` David Kastrup
2006-07-14 17:03                           ` Richard Stallman
2006-07-14 18:16                           ` Stefan Monnier
2006-07-14 18:33                             ` David Kastrup
2006-07-14 21:37                               ` Stefan Monnier
2006-07-15 22:06                                 ` Ralf Angeli
2006-07-16 17:04                                   ` Ralf Angeli
2006-07-14 17:03                         ` Richard Stallman
2006-07-09  9:31               ` Jan Djärv
2006-07-08 17:40           ` Robert J. Chassell
2006-07-06 22:09 ` Jason Rumney
2006-07-06 22:37   ` Lennart Borgman
2006-07-07  5:50   ` Ralf Angeli
2006-07-07  9:09     ` Eli Zaretskii
2006-08-05 14:50 ` Ralf Angeli [this message]
2006-08-19 15:15   ` Ralf Angeli
2006-08-19 15:37     ` David Kastrup
2006-08-19 16:31     ` Jason Rumney
2006-08-19 17:54       ` Ralf Angeli
2006-08-19 22:34         ` Jason Rumney
2006-08-20  8:19           ` Ralf Angeli
2006-08-21  9:06             ` Eli Zaretskii
2006-08-21  9:17               ` Lennart Borgman
2006-08-21 10:22                 ` Eli Zaretskii
2006-08-21 10:36                   ` David Kastrup
2006-08-21 11:45                     ` Jason Rumney
2006-08-21 11:55                       ` David Kastrup
2006-08-21 10:43                   ` Lennart Borgman
2006-08-21 14:07                     ` Eli Zaretskii
2006-08-21 15:03                       ` Lennart Borgman
2006-08-21 19:22               ` Ralf Angeli
2006-08-21 23:10                 ` Eli Zaretskii
2006-08-22  5:57                   ` Ralf Angeli
2006-08-22 19:16                     ` Ralf Angeli
2006-08-22 21:38                       ` Kim F. Storm
2006-08-23 18:31                         ` Ralf Angeli
2006-08-23 22:44                           ` Kim F. Storm
2006-08-24 16:14                             ` Ralf Angeli
2006-08-24 20:18                               ` Kim F. Storm
2006-08-25 16:38                                 ` Ralf Angeli
2006-08-25 22:28                                   ` Kim F. Storm
2006-08-21 23:25                 ` Jason Rumney
2006-08-22  5:51                   ` Ralf Angeli
2006-08-22  7:46                     ` Jason Rumney
2006-08-22 19:24                       ` Ralf Angeli
  -- strict thread matches above, loose matches on Subject: below --
2006-07-14 23:55 Robert J. Chassell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='eb2b77$3ih$2@sea.gmane.org' \
    --to=angeli@caeruleus.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).