all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Drew Adams <drew.adams@oracle.com>
Cc: emacs-devel@gnu.org
Subject: Re: Display-relative coordinates
Date: Fri, 29 Jul 2016 16:39:38 +0300	[thread overview]
Message-ID: <83d1lwr2at.fsf@gnu.org> (raw)
In-Reply-To: <bd748cdc-2ab2-4576-9e85-1040706ffcc8@default> (message from Drew Adams on Thu, 28 Jul 2016 13:20:35 -0700 (PDT))

> Date: Thu, 28 Jul 2016 13:20:35 -0700 (PDT)
> From: Drew Adams <drew.adams@oracle.com>
> 
> 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.



  reply	other threads:[~2016-07-29 13:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<831t2dsu3y.fsf@gnu.org>
2016-07-28 20:20 ` Display-relative coordinates Drew Adams
2016-07-29 13:39   ` Eli Zaretskii [this message]
     [not found] <<<831t2dsu3y.fsf@gnu.org>
     [not found] ` <<bd748cdc-2ab2-4576-9e85-1040706ffcc8@default>
     [not found]   ` <<83d1lwr2at.fsf@gnu.org>
2016-07-29 15:38     ` Drew Adams
2016-07-29 17:42       ` Eli Zaretskii
2016-07-28 14:41 Eli Zaretskii
2016-07-28 19:07 ` martin rudalics
2016-07-28 20:20   ` Drew Adams
2016-07-29  5:54     ` martin rudalics
2016-07-29 15:38       ` Drew Adams

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

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

  git send-email \
    --in-reply-to=83d1lwr2at.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.