From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#32672: 27.0.50; image resize on window resizing Date: Wed, 27 Nov 2019 23:53:46 +0200 Organization: LINKOV.NET Message-ID: <87a78iyz8l.fsf@mail.linkov.net> References: <87pnxmyjgt.fsf@mail.linkov.net> <87r2e3j1mp.fsf@mail.linkov.net> <878sqbfaqo.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="253874"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 32672@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 27 22:57:33 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ia5JU-0013vI-KC for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Nov 2019 22:57:32 +0100 Original-Received: from localhost ([::1]:43554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia5JT-00012I-99 for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Nov 2019 16:57:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51949) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ia5J1-0000yH-Fr for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ia5J0-0002EC-Be for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ia5J0-0002Dw-6J for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ia5J0-0008A7-5X for bug-gnu-emacs@gnu.org; Wed, 27 Nov 2019 16:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Nov 2019 21:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32672 X-GNU-PR-Package: emacs Original-Received: via spool by 32672-submit@debbugs.gnu.org id=B32672.157489179531331 (code B ref 32672); Wed, 27 Nov 2019 21:57:02 +0000 Original-Received: (at 32672) by debbugs.gnu.org; 27 Nov 2019 21:56:35 +0000 Original-Received: from localhost ([127.0.0.1]:56310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ia5IZ-00089F-A4 for submit@debbugs.gnu.org; Wed, 27 Nov 2019 16:56:35 -0500 Original-Received: from brown.birch.relay.mailchannels.net ([23.83.209.23]:6129) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ia5IX-000893-PI; Wed, 27 Nov 2019 16:56:34 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8351C21CE5; Wed, 27 Nov 2019 21:56:32 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a94.g.dreamhost.com (100-96-4-107.trex.outbound.svc.cluster.local [100.96.4.107]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 15FD7214BD; Wed, 27 Nov 2019 21:56:32 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a94.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Wed, 27 Nov 2019 21:56:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Wipe-Cooperative: 56bcac8e650012e9_1574891792340_4082469618 X-MC-Loop-Signature: 1574891792339:1169412243 X-MC-Ingress-Time: 1574891792339 Original-Received: from pdx1-sub0-mail-a94.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a94.g.dreamhost.com (Postfix) with ESMTP id CB2869C456; Wed, 27 Nov 2019 13:56:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=EQiS3cDnDWlD5vyOromKBWGjGKQ=; b= sm2dMpyvznLKyfz8vx+DI3KGJuCgjk7ZzVqk0ZnYx+rNkkS5ufHXiB43OwynQ0UR xIkVbb3TJpAGm0Jf8ef0akOctn6I45d736i3uzlS0X6UQdFqaEl53qGPgpHyp290 yN3O1i0+8MQN3CvmEW/GKn1ia+4tlFwVDCVLxypGlX8= Original-Received: from mail.jurta.org (m91-129-96-42.cust.tele2.ee [91.129.96.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a94.g.dreamhost.com (Postfix) with ESMTPSA id B11EF9C458; Wed, 27 Nov 2019 13:56:23 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a94 In-Reply-To: <878sqbfaqo.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 26 Sep 2019 15:27:59 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:172562 Archived-At: --=-=-= Content-Type: text/plain tags 32672 fixed close 32672 27.0.50 quit >> Using new hooks I noticed only one problem that when the same image buffer is >> displayed in several windows then using `other-window' to switch between them, >> the selection-change hook is not always called. > > [...] > >> + (add-hook 'window-size-change-functions (debounce #'image-window-change 1) nil t) >> + (add-hook 'window-state-change-functions (debounce #'image-window-change 1) nil t) >> + (add-hook 'window-selection-change-functions (debounce #'image-window-change 1) nil t) >> + > > I think this sounds like a nice addition for image-mode... but were the > remaining edge cases ever resolved? I see that the patch hasn't been > applied. This is installed now with the following patch and closed. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=image--window-change.patch diff --git a/lisp/image-mode.el b/lisp/image-mode.el index db6864649d..09d7828047 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -599,6 +599,10 @@ image-mode--setup-mode (add-hook 'change-major-mode-hook #'image-toggle-display-text nil t) (add-hook 'after-revert-hook #'image-after-revert-hook nil t) + (add-hook 'window-size-change-functions #'image--window-change nil t) + (add-hook 'window-state-change-functions #'image--window-change nil t) + (add-hook 'window-selection-change-functions #'image--window-change nil t) + (run-mode-hooks 'image-mode-hook) (let ((image (image-get-display-property)) (msg1 (substitute-command-keys @@ -856,6 +860,27 @@ image-after-revert-hook (get-buffer-window-list (current-buffer) 'nomini 'visible)) (image-toggle-display-image))) +(defvar image--window-change-function + (debounce 1.0 + (lambda (window) + (when (window-live-p window) + (with-current-buffer (window-buffer) + (when (derived-mode-p 'image-mode) + (let ((spec (image-get-display-property))) + (when (eq (car-safe spec) 'image) + (let* ((image-width (plist-get (cdr spec) :max-width)) + (image-height (plist-get (cdr spec) :max-height)) + (edges (window-inside-pixel-edges window)) + (window-width (- (nth 2 edges) (nth 0 edges))) + (window-height (- (nth 3 edges) (nth 1 edges)))) + (when (and image-width image-height + (or (not (= image-width window-width)) + (not (= image-height window-height)))) + (image-toggle-display-image))))))))))) + +(defun image--window-change (window) + (funcall image--window-change-function window)) + ;;; Animated images --=-=-=--