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.bugs Subject: bug#69602: 29.1; Image :map should adjust with :scale and :rotation Date: Thu, 07 Mar 2024 11:27:53 +0200 Message-ID: <86bk7q2xye.fsf@gnu.org> References: <87msramv72.fsf@breatheoutbreathe.in> <86jzmejzfd.fsf@gnu.org> <87a5namqyz.fsf@breatheoutbreathe.in> <86cys63281.fsf@gnu.org> <87wmqelakx.fsf@breatheoutbreathe.in> 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="33869"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69602@debbugs.gnu.org, stephen.berman@gmx.net, juri@linkov.net To: Joseph Turner Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 07 10:28:50 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1riA3W-0008cQ-EJ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Mar 2024 10:28:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riA3G-0007dG-Vn; Thu, 07 Mar 2024 04:28:35 -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 1riA3D-0007Ra-Lg for bug-gnu-emacs@gnu.org; Thu, 07 Mar 2024 04:28:31 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1riA3D-00065K-Dz for bug-gnu-emacs@gnu.org; Thu, 07 Mar 2024 04:28:31 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1riA3i-0004TU-Nm for bug-gnu-emacs@gnu.org; Thu, 07 Mar 2024 04:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Mar 2024 09:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69602 X-GNU-PR-Package: emacs Original-Received: via spool by 69602-submit@debbugs.gnu.org id=B69602.170980372417160 (code B ref 69602); Thu, 07 Mar 2024 09:29:02 +0000 Original-Received: (at 69602) by debbugs.gnu.org; 7 Mar 2024 09:28:44 +0000 Original-Received: from localhost ([127.0.0.1]:52552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1riA3P-0004Sh-HL for submit@debbugs.gnu.org; Thu, 07 Mar 2024 04:28:43 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53598) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1riA3M-0004SD-Fx for 69602@debbugs.gnu.org; Thu, 07 Mar 2024 04:28:41 -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 1riA2k-00062V-G5; Thu, 07 Mar 2024 04:28:03 -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=rCQasw3NBQ9OUPIfberVHYN0IUb7GREN2BVpK3DumXo=; b=XH1K8WRaJ9lsxASEaIZw oBQzL9A4Dd7ElvsGxQ1m5poQvthpu8w8+Vh0c5VbqA79PJhlV9skTu9wc1dbhp6QO2s4WiKSssSY1 kB3u4DQZ/G0uS33gMG2xJfHPrzqbTpsrCgHOJ8PAnQqNjjYLThuTmwSeI80qWYwiKQEFzCWRSwwmD Ou8UrBKzA3TYhig00tw16PzAZNCW8BvGNRCrNUwXClEefjZmplTah92GopW3VVKHg0UphecguJ3xc Q9Gnfl/5xsvKqjWH5bu4cOGV+tV1mQBy0/vkQJJGtZoikqRNW6kYchgY78DWm6Wgl1SnhkO2uxdgg lOaeSf5NZOFxwQ==; In-Reply-To: <87wmqelakx.fsf@breatheoutbreathe.in> (message from Joseph Turner on Thu, 07 Mar 2024 00:08:57 -0800) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281154 Archived-At: > From: Joseph Turner > Cc: 69602@debbugs.gnu.org, stephen.berman@gmx.net, juri@linkov.net > Date: Thu, 07 Mar 2024 00:08:57 -0800 > > > Eli Zaretskii writes: > > >> > Note that the map's coordinates should reflect the displayed image > >> > after all transforms have been done (rotation, scaling and so on), > >> > and also note that Emacs (by default) performs auto-scaling of > >> > images, so to make things match up, you should either specify > >> > ‘:scale 1.0’ when creating the image, or use the result of > >> > ‘image-compute-scaling-factor’ to compute the elements of the map. > >> > > >> > Can this technique help? > >> > >> Thank you for your help! > >> > >> When the user runs `image-increase-size', where should third-party code > >> recompute :map to fit the new image scale? > >> > >> There's no `image-after-change-size-hook' nor `image-after-rotate-hook'. > > > > I think the idea is to define the value of :map such that it runs > > image-compute-scaling-factor as part of computing the coordinates of > > the map. > > Sorry, I don't understand. I hoped :map allows its value to be a form that is evaluated when the image is being processed, in which case that form could call image-compute-scaling-factor when it produces the coordinates. If that doesn't work, then... > When creating an image, we set its :map property according to the return > value of `image-compute-scaling-factor'. Once the image is inserted into > the buffer, the user may run `image-increase-size' or `image-rotate', > which changes how the image is displayed but not its :map. > > Now, we need to rerun `image-compute-scaling-factor' and recompute :map. > However, there is no hook which runs after the user runs those commands, > so AFAICT there's no way for our code to know when to recompute :map. ...AFAIU, when an image is rescaled, we call image-transform-properties to produce the updated image properties. So I guess you'd like that function to recompute the coordinates in :map according to the transform? IOW, I don't understand why you think the problem can only be solved in C: AFAIK almost all of the machinery that performs image transforms is implemented in Lisp, and each time an image is rescaled, we basically re-process the image descriptor anew.