emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Display-relative coordinates


From: martin rudalics
Subject: Re: Display-relative coordinates
Date: Thu, 28 Jul 2016 21:07:55 +0200

>> I've been fiddling a bit with test code like this, but haven't
>> really found anything reasonable yet:
>
>> ;; Try to get screen-relative X, Y (pixels) for current point
>> (let* ((posn-at-pt  (posn-at-point))
>>         (x-y         (and posn-at-pt  (posn-x-y posn-at-pt)))
>>         (win-edges   (and x-y  (window-inside-absolute-pixel-edges)))
>>          (x           (and x-y  (+ (car x-y) (car win-edges))))
>>          (y           (and x-y  (+ (cdr x-y) (cadr win-edges))))
>>          (y           (and y  (top-fudge-pixels y))))
>>    ...)
>
>> (defun top-fudge-pixels (y)
>>    (let ((y2  y))
>>      (when tool-bar-mode (setq y2  (+ 40 tp)))
>>      (when menu-bar-mode (setq y2  (+ 25 tp)))
>>      (setq y2  (+ y2 28))  ; Frame title bar
>>      y2))
>
> What are the problems you see with the above (except that 'tp' is a
> void variable)?  It looks OK to me, modulo the kludges in
> top-fudge-pixels (why not use frame-geometry, which exists for that
> purpose?).

FWIW ‘window-inside-absolute-pixel-edges’ didn't work on Windows before
Emacs 25.  On Emacs 25 ‘window-absolute-pixel-position’ is all that's
needed.

martin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]