aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c56
1 files changed, 20 insertions, 36 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index fa2bfec138..1fa31f10b1 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -5530,31 +5530,20 @@ static dict_T *make_win_info_dict(int width, int height, int topline, int topfil
return NULL;
}
-/// Return values of check_window_scroll_resize():
-enum {
- CWSR_SCROLLED = 1, ///< at least one window scrolled
- CWSR_RESIZED = 2, ///< at least one window size changed
-};
-
/// This function is used for three purposes:
-/// 1. Goes over all windows in the current tab page and returns:
-/// 0 no scrolling and no size changes found
-/// CWSR_SCROLLED at least one window scrolled
-/// CWSR_RESIZED at least one window changed size
-/// CWSR_SCROLLED + CWSR_RESIZED both
-/// "size_count" is set to the nr of windows with size changes.
-/// "first_scroll_win" is set to the first window with any relevant changes.
-/// "first_size_win" is set to the first window with size changes.
+/// 1. Goes over all windows in the current tab page and sets:
+/// "size_count" to the nr of windows with size changes.
+/// "first_scroll_win" to the first window with any relevant changes.
+/// "first_size_win" to the first window with size changes.
///
/// 2. When the first three arguments are NULL and "winlist" is not NULL,
/// "winlist" is set to the list of window IDs with size changes.
///
/// 3. When the first three arguments are NULL and "v_event" is not NULL,
/// information about changed windows is added to "v_event".
-static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
- win_T **first_size_win, list_T *winlist, dict_T *v_event)
+static void check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
+ win_T **first_size_win, list_T *winlist, dict_T *v_event)
{
- int result = 0;
// int listidx = 0;
int tot_width = 0;
int tot_height = 0;
@@ -5576,10 +5565,11 @@ static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
continue;
}
- const bool size_changed = wp->w_last_width != wp->w_width
- || wp->w_last_height != wp->w_height;
+ const bool ignore_scroll = event_ignored(EVENT_WINSCROLLED, wp->w_p_eiw);
+ const bool size_changed = !event_ignored(EVENT_WINRESIZED, wp->w_p_eiw)
+ && (wp->w_last_width != wp->w_width
+ || wp->w_last_height != wp->w_height);
if (size_changed) {
- result |= CWSR_RESIZED;
if (winlist != NULL) {
// Add this window to the list of changed windows.
typval_T tv = {
@@ -5597,21 +5587,19 @@ static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
}
// For WinScrolled the first window with a size change is used
// even when it didn't scroll.
- if (*first_scroll_win == NULL) {
+ if (*first_scroll_win == NULL && !ignore_scroll) {
*first_scroll_win = wp;
}
}
}
- const bool scroll_changed = wp->w_last_topline != wp->w_topline
- || wp->w_last_topfill != wp->w_topfill
- || wp->w_last_leftcol != wp->w_leftcol
- || wp->w_last_skipcol != wp->w_skipcol;
- if (scroll_changed) {
- result |= CWSR_SCROLLED;
- if (first_scroll_win != NULL && *first_scroll_win == NULL) {
- *first_scroll_win = wp;
- }
+ const bool scroll_changed = !ignore_scroll
+ && (wp->w_last_topline != wp->w_topline
+ || wp->w_last_topfill != wp->w_topfill
+ || wp->w_last_leftcol != wp->w_leftcol
+ || wp->w_last_skipcol != wp->w_skipcol);
+ if (scroll_changed && first_scroll_win != NULL && *first_scroll_win == NULL) {
+ *first_scroll_win = wp;
}
if ((size_changed || scroll_changed) && v_event != NULL) {
@@ -5655,8 +5643,6 @@ static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
}
}
}
-
- return result;
}
/// Trigger WinScrolled and/or WinResized if any window in the current tab page
@@ -5676,11 +5662,9 @@ void may_trigger_win_scrolled_resized(void)
int size_count = 0;
win_T *first_scroll_win = NULL;
win_T *first_size_win = NULL;
- int cwsr = check_window_scroll_resize(&size_count,
- &first_scroll_win, &first_size_win,
- NULL, NULL);
+ check_window_scroll_resize(&size_count, &first_scroll_win, &first_size_win, NULL, NULL);
bool trigger_resize = do_resize && size_count > 0;
- bool trigger_scroll = do_scroll && cwsr != 0;
+ bool trigger_scroll = do_scroll && first_scroll_win != NULL;
if (!trigger_resize && !trigger_scroll) {
return; // no relevant changes
}