forked from aniani/vim
patch 7.4.1873
Problem: When a callback adds a timer the GUI doesn't use it until later. (Ramel Eshed) Solution: Return early if a callback adds a timer.
This commit is contained in:
@@ -2022,6 +2022,22 @@ gui_mch_update(void)
|
||||
process_message();
|
||||
}
|
||||
|
||||
static void
|
||||
remove_any_timer(void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
if (s_wait_timer != 0 && !s_timed_out)
|
||||
{
|
||||
KillTimer(NULL, s_wait_timer);
|
||||
|
||||
/* Eat spurious WM_TIMER messages */
|
||||
while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
|
||||
;
|
||||
s_wait_timer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* GUI input routine called by gui_wait_for_chars(). Waits for a character
|
||||
* from the keyboard.
|
||||
@@ -2073,6 +2089,9 @@ gui_mch_wait_for_chars(int wtime)
|
||||
s_need_activate = FALSE;
|
||||
}
|
||||
|
||||
#ifdef FEAT_TIMERS
|
||||
did_add_timer = FALSE;
|
||||
#endif
|
||||
#ifdef MESSAGE_QUEUE
|
||||
/* Check channel while waiting message. */
|
||||
for (;;)
|
||||
@@ -2098,15 +2117,7 @@ gui_mch_wait_for_chars(int wtime)
|
||||
|
||||
if (input_available())
|
||||
{
|
||||
if (s_wait_timer != 0 && !s_timed_out)
|
||||
{
|
||||
KillTimer(NULL, s_wait_timer);
|
||||
|
||||
/* Eat spurious WM_TIMER messages */
|
||||
while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
|
||||
;
|
||||
s_wait_timer = 0;
|
||||
}
|
||||
remove_any_timer();
|
||||
allow_scrollbar = FALSE;
|
||||
|
||||
/* Clear pending mouse button, the release event may have been
|
||||
@@ -2117,6 +2128,15 @@ gui_mch_wait_for_chars(int wtime)
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifdef FEAT_TIMERS
|
||||
if (did_add_timer)
|
||||
{
|
||||
/* Need to recompute the waiting time. */
|
||||
remove_any_timer();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
allow_scrollbar = FALSE;
|
||||
return FAIL;
|
||||
|
Reference in New Issue
Block a user