all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: JD Smith <jdtsmith@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: xterm-mouse-mode gives incorrect posn-object-x-y with display space
Date: Thu, 24 Nov 2022 20:34:24 +0200	[thread overview]
Message-ID: <835yf4w6a7.fsf@gnu.org> (raw)
In-Reply-To: <CA354E40-9BCD-47B7-98A1-6F08E8F6B48B@gmail.com> (message from JD Smith on Thu, 24 Nov 2022 12:22:44 -0500)

> From: JD Smith <jdtsmith@gmail.com>
> Date: Thu, 24 Nov 2022 12:22:44 -0500
> 
> The mouse-down events delivered by xterm-mouse-mode do not appear to handle clicks on entities with specified space display widths correctly.  Try this in a graphical window, and again in the terminal, with xterm-mouse-mode enabled:
> 
> (defun my/report-mouse (ev)
>   (interactive "e")
>   (let* ((posn (event-start ev))
> 	 (rel (posn-object-x-y posn)))
>     (message "Got Relative Position %S" rel)))
> 
> (insert "\n\n  ----  "
>         (propertize " "
>                     'extend nil
>                     'display '(space :width (48))
>                     'keymap '(keymap (down-mouse-1 . my/report-mouse))
>                     'font-lock-face 'underline)
>         "  ----  ")
> 
> Mouse 1 click positions relative to the extended-width space (underlined for visibility) are reported correctly in graphical emacs, in screen pixel units.  With xterm-mouse-mode, however, relative positions are always reported as (0 . 0) for me, no matter where you click.  Is something wrong with my assumption that posn-object-x-y should work similarly in graphical as well as terminal emacs with xterm-mouse-mode (modulo the larger “pixel” size)?

This has nothing to do with xterm-mouse.  You simply expect something that
is not supported: when posn-object-x-y says OBJECT, it refers to what
posn-object can return, which is either a string or an image.  IOW, objects
that are Lisp objects, which Lisp programs can access and manipulate.  By
contrast, stretch glyphs produced by 'display' "space" specs are not objects
exposed to Lisp, and for them the X/Y offsets of mouse events are
meaningless.  That in case of GUI frames you get pixel offsets from the
beginning of the stretch is a side effect of the implementation of stretch
glyphs on GUI frames; the TTY implementation is different, so you always get
zero.  You will see the same in text terminals equipped with a mouse, like
when Emacs runs with -nw switch on a terminal with GPM mouse on GNU/Linux or
the MS-Windows shell window.

So bottom line, you shouldn't expect DX and DY offsets in click position
data to be meaningful in this case.



  parent reply	other threads:[~2022-11-24 18:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 17:22 xterm-mouse-mode gives incorrect posn-object-x-y with display space JD Smith
2022-11-24 18:09 ` Stefan Monnier
2022-11-24 18:34 ` Eli Zaretskii [this message]
2022-11-24 21:42   ` JD Smith
2022-11-25  7:21     ` Eli Zaretskii
2022-11-25 15:15       ` JD Smith
2022-11-26 12:07     ` Eli Zaretskii
2022-11-26 18:56       ` Akib Azmain Turja
2022-11-26 19:14         ` Eli Zaretskii
2022-11-27  1:14       ` JD Smith

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=835yf4w6a7.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jdtsmith@gmail.com \
    /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.