From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ralf Angeli Newsgroups: gmane.emacs.devel Subject: Re: display-mm-width return value off on Windows Date: Sat, 05 Aug 2006 16:50:16 +0200 Organization: nil Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1154789462 7942 80.91.229.2 (5 Aug 2006 14:51:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 5 Aug 2006 14:51:02 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 05 16:51:00 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G9NUP-0002sT-It for ged-emacs-devel@m.gmane.org; Sat, 05 Aug 2006 16:50:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G9NUP-0006yY-3m for ged-emacs-devel@m.gmane.org; Sat, 05 Aug 2006 10:50:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G9NUC-0006yL-DY for emacs-devel@gnu.org; Sat, 05 Aug 2006 10:50:44 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G9NUA-0006y9-V1 for emacs-devel@gnu.org; Sat, 05 Aug 2006 10:50:43 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G9NUA-0006y6-QE for emacs-devel@gnu.org; Sat, 05 Aug 2006 10:50:42 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1G9NXy-0005n0-Ex for emacs-devel@gnu.org; Sat, 05 Aug 2006 10:54:38 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1G9NTx-0002nR-F8 for emacs-devel@gnu.org; Sat, 05 Aug 2006 16:50:29 +0200 Original-Received: from p54a54306.dip0.t-ipconnect.de ([84.165.67.6]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Aug 2006 16:50:29 +0200 Original-Received: from angeli by p54a54306.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Aug 2006 16:50:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 148 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: p54a54306.dip0.t-ipconnect.de Cancel-Lock: sha1:/Jx7vPHkKk4SRDX2cmIiBJcfp1Q= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58122 Archived-At: --=-=-= * 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 * 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=w32fns.c.patch 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, --=-=-= 2006-08-05 Ralf Angeli * frame.el (display-mm-dimensions-alist): New variable. (display-mm-height, display-mm-width): Use it. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=frame.el.patch 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. --=-=-= 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 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--