From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Display-relative coordinates Date: Fri, 29 Jul 2016 16:39:38 +0300 Message-ID: <83d1lwr2at.fsf@gnu.org> References: <<831t2dsu3y.fsf@gnu.org>> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1469799794 14414 80.91.229.3 (29 Jul 2016 13:43:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 Jul 2016 13:43:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 29 15:42:59 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bT843-0000MJ-1P for ged-emacs-devel@m.gmane.org; Fri, 29 Jul 2016 15:42:59 +0200 Original-Received: from localhost ([::1]:59651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bT83w-0001xZ-T4 for ged-emacs-devel@m.gmane.org; Fri, 29 Jul 2016 09:42:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bT81G-0000UE-1n for emacs-devel@gnu.org; Fri, 29 Jul 2016 09:40:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bT81B-00040R-Uj for emacs-devel@gnu.org; Fri, 29 Jul 2016 09:40:05 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bT81B-00040K-RR; Fri, 29 Jul 2016 09:40:01 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1556 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bT818-0007gA-0V; Fri, 29 Jul 2016 09:40:00 -0400 In-reply-to: (message from Drew Adams on Thu, 28 Jul 2016 13:20:35 -0700 (PDT)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:206222 Archived-At: > Date: Thu, 28 Jul 2016 13:20:35 -0700 (PDT) > From: Drew Adams > > For example, with emacs -Q, I measure a top-left window position > of, say, (15, 115) pixels from the top-left screen corner, for a > single-window frame. And that corresponds correctly with what I > get for `(window-inside-absolute-pixel-edges)': (15 115 784 722). > > At a given point (buffer position) in the window I measure a vertical > distance from the screen top edge as 354 pixels. But if I try to > calculate that then I get 420 instead: > > (posn-x-y (posn-at-point)) = (350 . 220) > > frame title bar + menu-bar + tool bar, using `frame-geometry' = 85 > (and this corresponds to measuring this distance: ~88) > > (My original code, which you quoted, guessed at about 93 pixels for > title bar + menu-bar + tool bar.) > > 220 + 115 (from w-i-a-p-e) + 85 = 420, not 354. Since the 85 and > the 115 correspond to what I measure, it seems that the 220 value > of y from (posn-x-y (posn-at-point)) is wrong. > > I measured to the bottom of the cursor, not the top. If I account > for the height of a character (12 pixels) then I get 408, but that's > still quite different from 354. > > And FWIW, `window-absolute-pixel-position' (for a not-too-recent > Emacs 25 build) returned 335 for the same distance. So: > > measured = 354 > window-absolute-pixel-position = 335 > calculated using frame-geometry, > posn-at-point, and > window-inside-absolute-pixel-edges = 408 or 420 (char top/bottom) > > Perhaps I'm overlooking something... There is not enough information in the above, and also some surprising data. First, you don't tell how you measure pixels from the screen corner. You don't tell what location of the character cells you take as its coordinates. You also say that the height of a character is 12 pixels, but the default height of a line in "emacs -Q" is 16, not 12. Maybe you could go line by line starting at the first line of the window, show the pixel coordinates of the first (leftmost) character on that line, and then tell which part(s) of the results don't look correct to you. FWIW, if I move a frame such that point is at one of the 4 corners of the screen, and compute its pixel coordinates using posn-at-point and frame-geometry, I get a very good approximation (within a couple of pixels) of my screen dimensions, so I don't think there's a problem in these functions.