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: Wed, 26 Aug 2015 10:07:28 +0000 [thread overview]
Message-ID: <CAOqdjBdPoH3EHRrjZ1-zguZMP=w7W8_biOM6qa_bLy0pAwMKbw@mail.gmail.com> (raw)
In-Reply-To: <55DD663C.4040504@gmx.at>
[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]
On Wed, Aug 26, 2015 at 7:09 AM, martin rudalics <rudalics@gmx.at> wrote:
>> So an alternative that doesn't need any hook is
>> simply to recompute the coordinates every time they are needed. It's
>> not like this calculation is expensive, is it?
>
> Correct.
I disagree, if I understand correctly. The coordinates might be passed
to another program, for example, and then we simply don't know when
that program decides to use them, so we still need a way to update our
(and its) idea of what the window size and position is, in my opinion.
> So ‘window-size-change-functions’ is dispensable.
Iff we keep/fix pre-redisplay-function, I agree. I had, wrongly,
assumed that pre-redisplay-function is run many times per redisplay
call, but that appears to be incorrect. The huge majority of
redisplays call it just once, and that makes the overhead negligible.
So what's the way forward, assuming my paperwork ever gets here?
- document window-size-change-functions aren't called for mini-window resizes
- document window-configuration-change-hook isn't called for
mini-window resizes
- document set-window-configuration doesn't call
window-size-change-functions if nothing changed
- fix set_window_configuration not to set the window size change flag
unless there was an actual size change
- wishlist item: call pre-redisplay-function between
grow/shrink_mini_window and the actual X repaint, rather than before.
- mark window-size-change-functions as obsolete and see whether
anyone complains?
> OTOH for the person who
> writes the function on the hook it might hardly matter whether some
> window size really changed. The more important case might be to not
> miss one single case where the size really changes.
Precisely.
[-- Attachment #2: 0001-Document-and-fix-behavior-of-window-pre-redisplay-ho.patch --]
[-- Type: text/x-patch, Size: 7522 bytes --]
From bf0c0615392b7f796c23690e10620e21a5926ad4 Mon Sep 17 00:00:00 2001
From: Philip <pipcet@gmail.com>
Date: Wed, 26 Aug 2015 09:34:12 +0000
Subject: [PATCH] Document and fix behavior of window/pre-redisplay hooks.
* xdisp.c (redisplay_internal): Call `pre-redisplay-function'
after resizing mini-windows rather than before.
* window.c (Fset_window_configuration): Only set the window size
change flag if a window actually changed size.
* windows.texi (Window Configurations): Document
`window-size-change-functions' isn't called for mini-window
resizes.
(Window Hooks): Likewise, likewise for
`window-configuration-change-hook'.
---
doc/lispref/windows.texi | 34 ++++++++++++++++------------------
src/window.c | 8 +++++++-
src/xdisp.c | 46 +++++++++++++++++++++++++---------------------
3 files changed, 48 insertions(+), 40 deletions(-)
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 4656938..bb9a5d2 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -3971,11 +3971,7 @@ was created for.
The argument @var{configuration} must be a value that was previously
returned by @code{current-window-configuration}. The configuration is
restored in the frame from which @var{configuration} was made, whether
-that frame is selected or not. This always counts as a window size
-change and triggers execution of the @code{window-size-change-functions}
-(@pxref{Window Hooks}), because @code{set-window-configuration} doesn't
-know how to tell whether the new configuration actually differs from the
-old one.
+that frame is selected or not.
If the frame from which @var{configuration} was saved is dead, all this
function does is restore the three variables @code{window-min-height},
@@ -4010,8 +4006,8 @@ windows might be opened in other frames (@pxref{Choosing Window}), and
configuration on the current frame.
Do not use this macro in @code{window-size-change-functions}; exiting
-the macro triggers execution of @code{window-size-change-functions},
-leading to an endless loop.
+the macro can trigger execution of
+@code{window-size-change-functions}, leading to an endless loop.
@end defmac
@defun window-configuration-p object
@@ -4262,10 +4258,9 @@ work.
@end defvar
@defvar window-size-change-functions
-This variable holds a list of functions to be called if the size of any
-window changes for any reason. The functions are called just once per
-redisplay, and just once for each frame on which size changes have
-occurred.
+This variable holds a list of functions to be called if the size of
+any window changes. The functions are called just once per redisplay,
+and just once for each frame on which size changes have occurred.
Each function receives the frame as its sole argument. There is no
direct way to find out which windows on that frame have changed size, or
@@ -4275,20 +4270,23 @@ present sizes and the previous sizes.
Creating or deleting windows counts as a size change, and therefore
causes these functions to be called. Changing the frame size also
-counts, because it changes the sizes of the existing windows.
+counts, because it changes the sizes of the existing windows. When
+the minibuffer or echo area grows or shrinks, these functions are not
+called.
You may use @code{save-selected-window} in these functions
(@pxref{Selecting Windows}). However, do not use
@code{save-window-excursion} (@pxref{Window Configurations}); exiting
-that macro counts as a size change, which would cause these functions
-to be called over and over.
+that macro can count as a size change, which would cause these
+functions to be called over and over.
@end defvar
@defvar window-configuration-change-hook
-A normal hook that is run every time you change the window configuration
-of an existing frame. This includes splitting or deleting windows,
-changing the sizes of windows, or displaying a different buffer in a
-window.
+A normal hook that is run every time you change the window
+configuration of an existing frame. This includes splitting or
+deleting windows, changing the sizes of windows, or displaying a
+different buffer in a window. However, this hook is not run for a size
+change that is solely due to a resized minibuffer or echo area.
The buffer-local part of this hook is run once for each window on the
affected frame, with the relevant window selected and its buffer
diff --git a/src/window.c b/src/window.c
index 863a792..be1693c 100644
--- a/src/window.c
+++ b/src/window.c
@@ -6072,7 +6072,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
@@ -6124,6 +6123,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);
diff --git a/src/xdisp.c b/src/xdisp.c
index 8be7497..97fc0d8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11566,27 +11566,6 @@ prepare_menu_bars (void)
tooltip_frame = Qnil;
#endif
- if (FUNCTIONP (Vpre_redisplay_function))
- {
- Lisp_Object windows = all_windows ? Qt : Qnil;
- if (all_windows && some_windows)
- {
- Lisp_Object ws = window_list ();
- for (windows = Qnil; CONSP (ws); ws = XCDR (ws))
- {
- Lisp_Object this = XCAR (ws);
- struct window *w = XWINDOW (this);
- if (w->redisplay
- || XFRAME (w->frame)->redisplay
- || XBUFFER (w->contents)->text->redisplay)
- {
- windows = Fcons (this, windows);
- }
- }
- }
- safe__call1 (true, Vpre_redisplay_function, windows);
- }
-
/* Update all frame titles based on their buffer names, etc. We do
this before the menu bars so that the buffer-menu will show the
up-to-date frame titles. */
@@ -13514,6 +13493,31 @@ redisplay_internal (void)
clear_garbaged_frames ();
}
+ if (FUNCTIONP (Vpre_redisplay_function))
+ {
+ bool all_windows = windows_or_buffers_changed || update_mode_lines;
+ bool some_windows = REDISPLAY_SOME_P ();
+ Lisp_Object windows = all_windows ? Qt : Qnil;
+
+ if (all_windows && some_windows)
+ {
+ Lisp_Object ws = window_list ();
+ for (windows = Qnil; CONSP (ws); ws = XCDR (ws))
+ {
+ Lisp_Object this = XCAR (ws);
+ struct window *w = XWINDOW (this);
+ if (w->redisplay
+ || XFRAME (w->frame)->redisplay
+ || XBUFFER (w->contents)->text->redisplay)
+ {
+ windows = Fcons (this, windows);
+ }
+ }
+ }
+ safe__call1 (true, Vpre_redisplay_function, windows);
+ }
+
+
if (windows_or_buffers_changed && !update_mode_lines)
/* Code that sets windows_or_buffers_changed doesn't distinguish whether
only the windows's contents needs to be refreshed, or whether the
--
2.5.0
next prev parent reply other threads:[~2015-08-26 10:07 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
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 [this message]
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='CAOqdjBdPoH3EHRrjZ1-zguZMP=w7W8_biOM6qa_bLy0pAwMKbw@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.