From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: xterm-mouse-mode gives incorrect posn-object-x-y with display space Date: Thu, 24 Nov 2022 20:34:24 +0200 Message-ID: <835yf4w6a7.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32881"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: JD Smith Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 24 19:35:07 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oyH3y-0008O0-T3 for ged-emacs-devel@m.gmane-mx.org; Thu, 24 Nov 2022 19:35:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyH3C-0007HX-J5; Thu, 24 Nov 2022 13:34:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyH32-0007H6-Fe for emacs-devel@gnu.org; Thu, 24 Nov 2022 13:34:13 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyH31-0000wN-Vz; Thu, 24 Nov 2022 13:34:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=+tQeamw6cI1NdoxX6Msai/43AGPMbL4beHGfvASWDKk=; b=hJzw1vr7h4TkT4OmFAD2 7z3oPyNa7kU2r8GjvTlyYTlNBV79bZ4K9k9UyXjWhM/KKT7NWfWL8XP47l+Bxj+UAERbzyNsmTyPP fspDkc4rN8H7dd3D4nzLW0ckCkwrUIAZeugqfzHlASPuIe37yRpqmNEbmFncKurJWsbi//4TWh9p6 KkID16kt97oxs7LQaQ+wmUPC/0wSI6lpVtjcw7h+kE/dwKErocnOiPhJr0iptZKp40KDC+YprAbCH dXU2K5l51l+ro8o/28dV/tdxf6eBDS7ol3Geyfi34iTRbgN5PaAwLkupw1RKPud88kKWmat4/ua/a fCQF5LAWmF7Pwg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyH2z-00036T-66; Thu, 24 Nov 2022 13:34:07 -0500 In-Reply-To: (message from JD Smith on Thu, 24 Nov 2022 12:22:44 -0500) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300443 Archived-At: > From: JD Smith > 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.