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: Tue, 11 Jul 2006 20:43:11 +0200 Organization: nil Message-ID: References: <87slldpd8s.fsf@neutrino.caeruleus.net> <44AFB1E1.20906@student.lu.se> <8764i7kywu.fsf@neutrino.caeruleus.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1152643499 15629 80.91.229.2 (11 Jul 2006 18:44:59 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 Jul 2006 18:44:59 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 11 20:44:57 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 1G0NDn-0002Lw-BG for ged-emacs-devel@m.gmane.org; Tue, 11 Jul 2006 20:44:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G0NDm-0003LQ-Op for ged-emacs-devel@m.gmane.org; Tue, 11 Jul 2006 14:44:34 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G0NDB-0002s2-Oh for emacs-devel@gnu.org; Tue, 11 Jul 2006 14:43:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G0NDA-0002qq-Bx for emacs-devel@gnu.org; Tue, 11 Jul 2006 14:43:57 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G0ND9-0002qR-Uu for emacs-devel@gnu.org; Tue, 11 Jul 2006 14:43:56 -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 1G0NEW-0002TP-DL for emacs-devel@gnu.org; Tue, 11 Jul 2006 14:45:20 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1G0NCh-00027H-LI for emacs-devel@gnu.org; Tue, 11 Jul 2006 20:43:27 +0200 Original-Received: from p54a50244.dip0.t-ipconnect.de ([84.165.2.68]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Jul 2006 20:43:27 +0200 Original-Received: from angeli by p54a50244.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Jul 2006 20:43:27 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 151 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: p54a50244.dip0.t-ipconnect.de Cancel-Lock: sha1:c9pccKmwaU8fa8dz6Pmd7ySPhO8= 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:56933 Archived-At: --=-=-= * Eli Zaretskii (2006-07-09) writes: >> From: Ralf Angeli >> >> If `GetDeviceCaps (hdc, HORSIZE)' always assumes a fixed DPI value >> that would explain why the values are so inaccurate especially on >> displays with a high DPI value. In that case I think it makes sense >> to use the DPI value when calculating the size (as my patch does) and >> assume that the user set it to a value matching her monitor. >> >> As a last resort we could provide user options (in Emacs) for setting >> the correct size of the screen which will be used as return values for >> `display-mm-{width,height}'. > > Sounds like a good plan to me. Here are change log entries and patches to achieve that: 2006-07-11 Ralf Angeli * frame.el (display-mm-height): New variable. (display-mm-height): Use it. (display-mm-width): New variable. (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.236 diff -u -r1.236 frame.el --- frame.el 25 Mar 2006 07:40:18 -0000 1.236 +++ frame.el 11 Jul 2006 18:40:03 -0000 @@ -1081,17 +1081,35 @@ (t (frame-width (if (framep display) display (selected-frame))))))) +(defcustom display-mm-height nil + "Height of display in millimeters. +If non-nil, used as return value for function `display-mm-height'." + :version "22.1" + :type 'integer + :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))) +If the information is unavailable, value is nil. Return value of +variable `display-mm-height' if set." + (or display-mm-height + (and (memq (framep-on-display display) '(x w32 mac)) + (x-display-mm-height display)))) + +(defcustom display-mm-width nil + "Width of display in millimeters. +If non-nil, used as return value for function `display-mm-width'." + :version "22.1" + :type 'integer + :group 'frames) (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))) +If the information is unavailable, value is nil. Return value of +variable `display-mm-width' if set." + (or display-mm-width + (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. --=-=-= 2006-07-11 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.271 diff -u -r1.271 w32fns.c --- w32fns.c 30 Jun 2006 13:40:21 -0000 1.271 +++ w32fns.c 11 Jul 2006 18:38:37 -0000 @@ -6502,15 +6502,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, @@ -6524,15 +6525,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, --=-=-= -- 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 --=-=-=--