all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: 21333@debbugs.gnu.org
Subject: bug#21333: 25.0.50; window-size-change-functions not called after mini-window resize
Date: Tue, 25 Aug 2015 10:34:23 +0000	[thread overview]
Message-ID: <CAOqdjBeH24f0fn8va-RR95EqDKY_FfkGtAirP3bFVw5TpvgmDQ@mail.gmail.com> (raw)
In-Reply-To: <55DC1856.7000501@gmx.at>

[-- Attachment #1: Type: text/plain, Size: 2134 bytes --]

On Tue, Aug 25, 2015 at 7:25 AM, martin rudalics <rudalics@gmx.at> wrote:
>>> Naively spoken it's obvious that when you shrink the minibuffer you show
>>> more lines in the window above and ‘linum-mode’ has to add numbers for
>>> those lines.  And when you enlarge the minibuffer, ‘follow-mode’ will
>>> lose some lines at the bottom of the left window and has to show them at
>>> the top of the right window.
>>
>> In well-behaved modes this happens automatically, as part of
>> redisplay.
>
> Via ‘pre-redisplay-function’?

Well, we have `pre-redisplay-functions', with an s, defined in
simple.el, and I've attached some (trivial) code that takes things a
little further and calls a normal hook when a window's size changed.

> How does a well-behaved mode detect
> whether it has to make "this happen automatically"?  By walking all
> windows and checking whether their sizes, start and end positions
> changed, I suppose.

That's what my code does. I thought I could get away with using the
arguments passed to pre-redisplay-function to limit which windows to
check, but that doesn't work when we "goto retry" and re-run
pre-redisplay-function. I will study the code in xdisp.c further and
see whether I can understand what the purpose of must_finish is.

>> I'd say, don't set the "size changed" flag unless the size really
>> changed.
>
> Sure.

Patch attached (no news on the paperwork so far). I'm not sure
precisely which properties should be checked for change, though.

I do think it would be best not to use set-window-configuration in
restoring state after exiting the minibuffer at all.

> Alternatively, Fset_window_configuration could run a modified version of
> ‘compare-window-configurations’ to compare the current configuration
> with the one to be restored and restore the old configuration iff these
> differ.  I'm not sure whether this would be any cheaper, especially when
> the configuration does change frequently.

I think it would be better to do this explicitly, even if we have to
compare all properties.

Thanks again to both of you,
Pip

[-- Attachment #2: emacs-via-redisplay-014.el --]
[-- Type: text/x-emacs-lisp, Size: 1548 bytes --]

;; generic code:
(defvar predisplay-hook nil
  "Normal hook run before predisplay.")
(defvar window-changed-size-hook nil
  "Normal hook run when a window displaying this buffer changed size.")
(defvar predisplay-sizes (make-hash-table :weakness 'key :test 'eq)
  "Hash table of old window sizes to detect size changes.")

(defun predisplay-check-window ()
  "Run in hook `predisplay-hook' to determine which windows changed size."
  (let* ((w (selected-window))
	 (old-size (gethash w predisplay-sizes))
	 (new-size (cons (window-pixel-width w)
			 (window-pixel-height w))))
    (unless (equal old-size new-size)
      (run-hooks 'window-changed-size-hook)
      (puthash w new-size predisplay-sizes))))

(add-hook 'predisplay-hook #'predisplay-check-window)

(defun predisplay-function (&rest args)
  (dolist (w (window-list-1 nil t t))
    (with-selected-window w
      (run-hooks 'predisplay-hook))))

(add-function :before pre-redisplay-function
              #'predisplay-function)
;; demonstration code:
(defun my-window-changed-size ()
  (insert (format "%dx%d\n" (window-pixel-width (selected-window))
                  (window-pixel-height (selected-window)))))

(defun display-dynamic-size ()
  (add-hook 'window-changed-size-hook #'my-window-changed-size nil t))

;; dead code:

;; I thought this would work, but it doesn't, for reasons I believe
;; Eli described.

;; (defun predisplay-run-hook (window)
;;   (with-selected-window window
;;     (run-hooks 'predisplay-hook)))

;; (push #'predisplay-run-hook pre-redisplay-functions)


[-- Attachment #3: 0001-Only-set-FRAME_WINDOW_SIZES_CHANGED-if-necessary-213.patch --]
[-- Type: text/x-patch, Size: 1441 bytes --]

From 94ba0a8ed127dc147eb68bf019a1e8370622c740 Mon Sep 17 00:00:00 2001
From: Philip <pipcet@gmail.com>
Date: Tue, 25 Aug 2015 10:21:18 +0000
Subject: [PATCH] Only set FRAME_WINDOW_SIZES_CHANGED if necessary (#21333)

---
 src/window.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/window.c b/src/window.c
index 68bc9e5..6bc0982 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6075,7 +6075,6 @@ the return value is nil.  Otherwise the value is t.  */)
 	}
 
       fset_redisplay (f);
-      FRAME_WINDOW_SIZES_CHANGED (f) = true;
 
       /* Problem: Freeing all matrices and later allocating them again
 	 is a serious redisplay flickering problem.  What we would
@@ -6127,6 +6126,13 @@ the return value is nil.  Otherwise the value is t.  */)
 	  /* If we squirreled away the buffer, restore it now.  */
 	  if (BUFFERP (w->combination_limit))
 	    wset_buffer (w, w->combination_limit);
+          if (!FRAME_WINDOW_SIZES_CHANGED (f)) {
+            if (w->pixel_left != XFASTINT (p->pixel_left) ||
+                w->pixel_top != XFASTINT (p->pixel_top) ||
+                w->pixel_width != XFASTINT (p->pixel_width) ||
+                w->pixel_height != XFASTINT (p->pixel_height))
+              FRAME_WINDOW_SIZES_CHANGED (f) = true;
+          }
 	  w->pixel_left = XFASTINT (p->pixel_left);
 	  w->pixel_top = XFASTINT (p->pixel_top);
 	  w->pixel_width = XFASTINT (p->pixel_width);
-- 
2.5.0


  reply	other threads:[~2015-08-25 10:34 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-23 22:06 bug#21333: 25.0.50; window-size-change-functions not called after mini-window resize Pip Cet
2015-08-24  8:18 ` martin rudalics
2015-08-24 11:08   ` Pip Cet
2015-08-24 12:41     ` martin rudalics
2015-08-24 14:35 ` Eli Zaretskii
2015-08-24 18:06   ` martin rudalics
2015-08-24 18:30     ` Eli Zaretskii
2015-08-25  7:25       ` martin rudalics
2015-08-25 10:34         ` Pip Cet [this message]
2015-08-25 15:19           ` Eli Zaretskii
2015-08-26  7:08           ` martin rudalics
2015-08-25 15:11         ` Eli Zaretskii
2015-08-26  7:09           ` martin rudalics
2015-08-26 15:29             ` Eli Zaretskii
2015-08-27  7:57               ` martin rudalics
2015-08-27 15:29                 ` Eli Zaretskii
2015-08-27 17:05                   ` Pip Cet
2015-08-27 17:59                     ` martin rudalics
2015-08-27 18:04                       ` Pip Cet
2015-08-28  8:03                         ` martin rudalics
2015-08-28  8:19                           ` Pip Cet
2015-08-28  8:45                             ` Pip Cet
2015-08-27 18:35                     ` Eli Zaretskii
2015-08-27 17:58                   ` martin rudalics
2015-08-24 18:13   ` Pip Cet
2015-08-24 19:03     ` Eli Zaretskii
2015-08-25  7:25       ` martin rudalics
2015-08-25 15:12         ` Eli Zaretskii
2015-08-26  7:09           ` martin rudalics
2015-08-26 10:07             ` Pip Cet
2015-08-26 13:01               ` martin rudalics
2015-08-26 16:00                 ` Pip Cet
2015-08-27  7:59                   ` martin rudalics
2015-08-27 15:25                     ` Eli Zaretskii
2015-08-27 16:35                       ` Pip Cet
2015-08-27 17:59                         ` martin rudalics
2015-08-27 18:57                         ` Eli Zaretskii
2015-08-27 20:49                           ` Pip Cet
2015-08-28 10:02                             ` Eli Zaretskii
2015-08-28 12:34                               ` Pip Cet
2015-08-28 13:13                                 ` Eli Zaretskii
2015-08-28 13:26                                   ` Pip Cet
2015-08-26 15:36               ` Eli Zaretskii
2015-08-27  7:58                 ` martin rudalics
2015-08-27 15:24                   ` Eli Zaretskii
2015-08-27 17:58                     ` martin rudalics
2015-08-27 18:39                       ` Eli Zaretskii
2015-08-27 19:00                         ` Eli Zaretskii
2015-08-28  8:04                           ` martin rudalics
2015-08-28  8:47                             ` Eli Zaretskii
2015-08-28 10:51                               ` martin rudalics
2015-08-28 12:46                                 ` Eli Zaretskii
2015-08-28 13:05                                   ` martin rudalics
2015-08-26 15:32             ` Eli Zaretskii
2015-08-27  7:57               ` martin rudalics
2016-02-22 12:59   ` Fix `window-configuration-change-hook' and `window-size-change-functions' martin rudalics
2016-02-23 11:31     ` martin rudalics

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=CAOqdjBeH24f0fn8va-RR95EqDKY_FfkGtAirP3bFVw5TpvgmDQ@mail.gmail.com \
    --to=pipcet@gmail.com \
    --cc=21333@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /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.