unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* `window-absolute-pixel-position' with vscroll
@ 2023-06-20 19:23 Rahguzar
  2023-06-21 12:50 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Rahguzar @ 2023-06-20 19:23 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,
Reading the manual and documentation I understand the
`window-absolute-pixel-position' if there is no vscroll. If however the
value of `(window-vscroll)` is non-nil calling

(window-absolute-pixel-position (window-start))

produces results which I don't know how to interpret since the upper
left corner of the line is not visible. I wanted to know the pixel
position of the start of some subsequent visible line but results of
`(window-absolute-pixel-position pos)' didn't make sense to me. I
eventually managed to do it by using a combination of
`pos-visible-in-window-p' and `line-pixel-height' but maybe there is a
simpler way using `window-absolute-pixel-position'.

Thanks in advance,
Rahguzar



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: `window-absolute-pixel-position' with vscroll
  2023-06-20 19:23 Rahguzar
@ 2023-06-21 12:50 ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2023-06-21 12:50 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rahguzar <rahguzar@zohomail.eu>
> Date: Tue, 20 Jun 2023 21:23:25 +0200
> 
> Reading the manual and documentation I understand the
> `window-absolute-pixel-position' if there is no vscroll. If however the
> value of `(window-vscroll)` is non-nil calling
> 
> (window-absolute-pixel-position (window-start))
> 
> produces results which I don't know how to interpret since the upper
> left corner of the line is not visible. I wanted to know the pixel
> position of the start of some subsequent visible line but results of
> `(window-absolute-pixel-position pos)' didn't make sense to me.

Please show some Lisp in which you tried to use
window-absolute-pixel-position and whose results didn't make sense to
you.  Perhaps also explain why the results didn't make sense.
Otherwise it is very hard to help you make sense out of the results
(or perhaps conclude that we have a bug that needs fixing).

Thanks.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: `window-absolute-pixel-position' with vscroll
@ 2023-06-21 20:42 Rahguzar
  2023-06-22 16:59 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Rahguzar @ 2023-06-21 20:42 UTC (permalink / raw)
  To: eliz; +Cc: help-gnu-emacs

Hi Eli,

Due to some reason I didn't receive your message and only saw it
because I checked archives just now.

Consider the following code,

(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.

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.

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.

Thanks,
Rahguzar



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: `window-absolute-pixel-position' with vscroll
  2023-06-21 20:42 Rahguzar
@ 2023-06-22 16:59 ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2023-06-22 16:59 UTC (permalink / raw)
  To: help-gnu-emacs

> 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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: `window-absolute-pixel-position' with vscroll
       [not found] ` <83fs6i1a64.fsf@gnu.org>
@ 2023-06-23 15:22   ` Rahguzar
  2023-06-23 15:47     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Rahguzar @ 2023-06-23 15:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs


Hi Eli,
Eli Zaretskii <eliz@gnu.org> writes:

> [Why private email?]

Sorry about that. I clicked the reply via email to button in the
archives page and forgot to add the cc. I have now added the list to cc.

>> From: Rahguzar <rahguzar@zohomail.eu>
>> Date: Fri, 23 Jun 2023 16:49:09 +0200
>>
>> > 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.
>>
>> This was the cause of my confusion. Though it seems to me that the
>> position is not relative to the upper left corner of the terminal.
>> Rather it is relative upper left corner of the Emacs frame excluding the
>> menu bar and tool bar. Starting with `emacs -Q` and doing
>>
>> `M:- (window-absolute-pixel-position (window-start))`
>>
>> always prints `(0 . 0)`.
>
> Not here, it doesn't.  What I get is result that depends on the
> position of the Emacs frame on display.
>
> Are you trying this in "emacs -nw" or in a GUI session?

I am using GUI session built with pgtk.

Thanks,
Rahguzar



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: `window-absolute-pixel-position' with vscroll
  2023-06-23 15:22   ` `window-absolute-pixel-position' with vscroll Rahguzar
@ 2023-06-23 15:47     ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2023-06-23 15:47 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Rahguzar <rahguzar@zohomail.eu>
> Date: Fri, 23 Jun 2023 17:22:01 +0200
> cc: help-gnu-emacs@gnu.org
> 
> >> This was the cause of my confusion. Though it seems to me that the
> >> position is not relative to the upper left corner of the terminal.
> >> Rather it is relative upper left corner of the Emacs frame excluding the
> >> menu bar and tool bar. Starting with `emacs -Q` and doing
> >>
> >> `M:- (window-absolute-pixel-position (window-start))`
> >>
> >> always prints `(0 . 0)`.
> >
> > Not here, it doesn't.  What I get is result that depends on the
> > position of the Emacs frame on display.
> >
> > Are you trying this in "emacs -nw" or in a GUI session?
> 
> I am using GUI session built with pgtk.

Ah, then this is a known problem with the PGTK builds: the Wayland and
similar backends don't supply the information which Emacs needs to
calculate the offset from the display screen's top-left corner.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-23 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87r0q2dxvz.fsf@zohomail.eu>
     [not found] ` <83fs6i1a64.fsf@gnu.org>
2023-06-23 15:22   ` `window-absolute-pixel-position' with vscroll Rahguzar
2023-06-23 15:47     ` Eli Zaretskii
2023-06-21 20:42 Rahguzar
2023-06-22 16:59 ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2023-06-20 19:23 Rahguzar
2023-06-21 12:50 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).