• Martin Rudalics's avatar
    Fix `window-configuration-change-hook' and `window-size-change-functions' · 8e7712c7
    Martin Rudalics authored
    (1) Run `window-configuration-change-hook' if and only if at least
    one window was deleted or created or shows another buffer since
    last redisplay.
    
    (2) Run `window-size-change-functions' if and only if at least
    one window changed its size since last redisplay (in a few cases
    `window-size-change-functions' will also run when no window
    changed its size).
    
    (3) Provide two functions `window-pixel-height-before-size-change'
    and `window-pixel-width-before-size-change' that allow to easily
    detect which window changed size.
    
    * src/frame.h (struct frame): New boolean member
    window_configuration_changed.
    (FRAME_WINDOW_SIZES_CHANGED): Remove macro.
    (FRAME_WINDOW_CONFIGURATION_CHANGED): New macro.
    * src/frame.c (adjust_frame_size): Don't run
    `window-configuration-change-hook'.
    * src/window.h (struct window): New fields
    pixel_width_before_size_change and pixel_height_before_size_change.
    (WINDOW_INTERNAL_P): New macro.
    * src/window.c (Fwindow_pixel_width_before_size_change)
    (Fwindow_pixel_height_before_size_change): New functions.
    (Fdelete_other_windows_internal, Fwindow_resize_apply)
    (resize_frame_windows, Fsplit_window_internal)
    (Fdelete_window_internal, grow_mini_window)
    (shrink_mini_window, Fresize_mini_window_internal): Don't call
    FRAME_WINDOW_SIZES_CHANGED.
    (window_size_changed, window_set_before_size_change_sizes)
    (run_window_size_change_functions): New functions.
    (make_window): Initialize pixel_width_before_size_change and
    pixel_height_before_size_change.
    (Fdelete_window_internal): Don't call
    run_window_configuration_change_hook.
    (struct saved_window): Add pixel_height_before_size_change and
    pixel_width_before_size_change.
    (Fset_window_configuration): Try to identify window configuration
    changes correctly so run_window_configuration_change_hook and
    run_window_size_change_functions run only if configuration and size
    really changed.
    (save_window_save): Set the pixel_height_before_size_change and
    pixel_width_before_size_change fields.
    (Vwindow_size_change_functions): Move here definiton from xdisp.c.
    * src/xdisp.c (prepare_menu_bars, redisplay_internal): Call
    run_window_size_change_functions.
    (Vwindow_size_change_functions): Move definition to window.c.
    * src/xfns.c (x_set_menu_bar_lines): Don't call
    run_window_configuration_change_hook.
    * doc/lispref/windows.texi (Window Sizes): Document new
    functions `window-pixel-height-before-size-change' and
    `window-pixel-width-before-size-change'.
    (Window Configurations): Mention that this may trigger
    execution of `window-size-change-functions' although no window
    changed size.
    (Window Hooks): Update descriptions of `window-size-change-functions'
    and `window-configuration-change-hook'.
    8e7712c7
frame.c 165 KB