may_trigger_winscrolled(void)
{
    win_T	    *wp = curwin;
    static int	    recursive = FALSE;
    char_u	    winid[NUMBUFLEN];

    if (recursive || !has_winscrolled())
	return;

    if (wp->w_last_topline != wp->w_topline
	    || wp->w_last_leftcol != wp->w_leftcol
	    || wp->w_last_width != wp->w_width
	    || wp->w_last_height != wp->w_height)
    {
	vim_snprintf((char *)winid, sizeof(winid), "%d", wp->w_id);

	recursive = TRUE;
	apply_autocmds(EVENT_WINSCROLLED, winid, winid, FALSE, wp->w_buffer);
	recursive = FALSE;

	// an autocmd may close the window, "wp" may be invalid now
	if (win_valid_any_tab(wp))
	{
	    wp->w_last_topline = wp->w_topline;
	    wp->w_last_leftcol = wp->w_leftcol;
	    wp->w_last_width = wp->w_width;
	    wp->w_last_height = wp->w_height;
	}
    }
}
may_trigger_winscrolled(void)
{
    win_T	    *wp = curwin;
    static int	    recursive = FALSE;
    char_u	    winid[NUMBUFLEN];

    if (recursive || !has_winscrolled())
	return;

    if (wp->w_last_topline != wp->w_topline
	    || wp->w_last_leftcol != wp->w_leftcol
	    || wp->w_last_width != wp->w_width
	    || wp->w_last_height != wp->w_height)
    {
	vim_snprintf((char *)winid, sizeof(winid), "%d", wp->w_id);

	recursive = TRUE;
	apply_autocmds(EVENT_WINSCROLLED, winid, winid, FALSE, wp->w_buffer);
	recursive = FALSE;

	 
	if (win_valid_any_tab(wp))
	{
	    wp->w_last_topline = wp->w_topline;
	    wp->w_last_leftcol = wp->w_leftcol;
	    wp->w_last_width = wp->w_width;
	    wp->w_last_height = wp->w_height;
	}
    }
}