[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `window-absolute-pixel-position' with vscroll
From: |
Eli Zaretskii |
Subject: |
Re: `window-absolute-pixel-position' with vscroll |
Date: |
Thu, 22 Jun 2023 19:59:53 +0300 |
> From: Rahguzar <rahguzar@zohomail.eu>
> Date: Wed, 21 Jun 2023 22:42:22 +0200
> CC: help-gnu-emacs@gnu.org
>
> Due to some reason I didn't receive your message and only saw it
> because I checked archives just now.
I reply to the list only, so you should either be subscribed or check
the archives.
> (progn
> (goto-char (point-max))
> (insert "\n")
> (insert-image (create-image "path/to/image"))
> (insert "\n")
> (insert-image (create-image "path/to/image")))
>
> I pasted it in scratch buffer starting from `emacs -Q` and then
> evaluated it.
>
> Now go to the first image and use `i +` till the image height is larger
> than the window height (more about needing this below).
>
> Then do `M-: (set-window-vscroll nil 100 t t)`
>
> Where 100 is just a place holder but the number should be smaller than
> the window height and large enough that the second image comes into
> view.
>
> Next do `M-: (window-absolute-pixel-position (point))`
> I got `(1896 . 0)` which I don't know how to interpret since that is
> supposed to represent the top-left corner of the image but that corner
> is not visible in window and I don't know how that 1896 came to be there.
window-absolute-pixel-position returns the coordinates relative to the
top-left corner of the _display_ (i.e. the terminal) on which the
window is displayed. Without knowing where the window was on your
display, I cannot help you interpret the value. Perhaps it would help
if you move the window's frame to the top-left corner of the screen,
and repeat your experiment.
> Next do `M-: (window-absolute-pixel-position (+ 2 (point)))`
>
> I got `(8 . 862)`, which matches what I expect from evaluating
> `(pos-visible-in-window-p (point) nil t)`. Although I remember this
> result being confusing too but I think it was just me being confused.
pos-visible-in-window-p returns X/Y coordinates relative to the
top-left corner of the _window_. So its origin is different, and
perhaps that difference is what caused your confusion.
> While doing this I noticed that I can't set vscroll until image is
> taller than the window i.e. in this case the top of first the image
> remains glued to the top of the window. This is not the case with text
> i.e. `M-: (progn (goto-char (point-min)) (set-window-vscroll nil 10 t t))`
> in the scratch buffer partially hides the top line for me as expected
> but if the window starts at an image less tall than the window and I do
> `M-: (set-window-vscroll nil 100 t t)` the top of the image remains
> visible even if the image is more than 100 pixels tall.
pixel-scroll-precision-mode does what you want, so it is certainly
possible.