emacs-devel
[Top][All Lists]
Advanced

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

Re: How to create a small child-frame which only show two lines


From: Feng Shu
Subject: Re: How to create a small child-frame which only show two lines
Date: Sat, 06 Jan 2018 18:42:28 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

martin rudalics <address@hidden> writes:

The below is a simple version, and it works well for pyim and is easy
understand.

---------------------------------------------------------------------------

(defun pyim-tooltip-compute-pixel-position (pos pixel-width pixel-height)
  "Return pixel position of POS in WINDOW, which indicates relative
coordinates of bottom left corner of the object, its returned value is
like (X . Y)

If PIXEL-WIDTH and PIXEL-HEIGHT are given, this function regard these
values as the size of a small window located around the POS, for example:
tooltip. These values are used to adjust the small window's location and
let it not disappear by sticking out of the display.

This function is shameless steal from pos-tip."
  (let* ((window (selected-window))
         (frame (window-frame window))
         (xmax (frame-pixel-width frame))
             (ymax (frame-pixel-height frame))
         (posn (posn-at-point pos window))
         (line (cdr (posn-actual-col-row posn)))
         (line-height
                  (or (window-line-height line window)
                          (and (redisplay t)
                                   (window-line-height line window))))
         (x-y (or (posn-x-y posn) '(0 . 0)))
         (x (+ (car (window-inside-pixel-edges window))
                   (car x-y)))
         (y0 (+ (cadr (window-pixel-edges window))
                        (or (nth 2 line-height) (cdr x-y))))
         (y (+ y0 (car line-height))))
    (cons (max 0 (min x (- xmax (or pixel-width 0))))
              (max 0 (if (> (+ y (or pixel-height 0)) ymax)
                             (- y0 (or pixel-height 0))
                   y)))))

-------------------------------------------------------------------

-- 




reply via email to

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