Mercurial > vim
comparison src/gui_w32.c @ 9179:5e18efdad322 v7.4.1873
commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 2 14:30:04 2016 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 02 Jun 2016 14:30:08 +0200 |
parents | 7b1200ea03a1 |
children | 07bc9dc5b3c9 |
comparison
equal
deleted
inserted
replaced
9178:4f47bb74ecb7 | 9179:5e18efdad322 |
---|---|
2020 while (pPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) | 2020 while (pPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) |
2021 && !vim_is_input_buf_full()) | 2021 && !vim_is_input_buf_full()) |
2022 process_message(); | 2022 process_message(); |
2023 } | 2023 } |
2024 | 2024 |
2025 static void | |
2026 remove_any_timer(void) | |
2027 { | |
2028 MSG msg; | |
2029 | |
2030 if (s_wait_timer != 0 && !s_timed_out) | |
2031 { | |
2032 KillTimer(NULL, s_wait_timer); | |
2033 | |
2034 /* Eat spurious WM_TIMER messages */ | |
2035 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) | |
2036 ; | |
2037 s_wait_timer = 0; | |
2038 } | |
2039 } | |
2040 | |
2025 /* | 2041 /* |
2026 * GUI input routine called by gui_wait_for_chars(). Waits for a character | 2042 * GUI input routine called by gui_wait_for_chars(). Waits for a character |
2027 * from the keyboard. | 2043 * from the keyboard. |
2028 * wtime == -1 Wait forever. | 2044 * wtime == -1 Wait forever. |
2029 * wtime == 0 This should never happen. | 2045 * wtime == 0 This should never happen. |
2071 (void)SetActiveWindow(s_hwnd); | 2087 (void)SetActiveWindow(s_hwnd); |
2072 #endif | 2088 #endif |
2073 s_need_activate = FALSE; | 2089 s_need_activate = FALSE; |
2074 } | 2090 } |
2075 | 2091 |
2092 #ifdef FEAT_TIMERS | |
2093 did_add_timer = FALSE; | |
2094 #endif | |
2076 #ifdef MESSAGE_QUEUE | 2095 #ifdef MESSAGE_QUEUE |
2077 /* Check channel while waiting message. */ | 2096 /* Check channel while waiting message. */ |
2078 for (;;) | 2097 for (;;) |
2079 { | 2098 { |
2080 MSG msg; | 2099 MSG msg; |
2096 */ | 2115 */ |
2097 process_message(); | 2116 process_message(); |
2098 | 2117 |
2099 if (input_available()) | 2118 if (input_available()) |
2100 { | 2119 { |
2101 if (s_wait_timer != 0 && !s_timed_out) | 2120 remove_any_timer(); |
2102 { | |
2103 KillTimer(NULL, s_wait_timer); | |
2104 | |
2105 /* Eat spurious WM_TIMER messages */ | |
2106 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE)) | |
2107 ; | |
2108 s_wait_timer = 0; | |
2109 } | |
2110 allow_scrollbar = FALSE; | 2121 allow_scrollbar = FALSE; |
2111 | 2122 |
2112 /* Clear pending mouse button, the release event may have been | 2123 /* Clear pending mouse button, the release event may have been |
2113 * taken by the dialog window. But don't do this when getting | 2124 * taken by the dialog window. But don't do this when getting |
2114 * focus, we need the mouse-up event then. */ | 2125 * focus, we need the mouse-up event then. */ |
2115 if (!s_getting_focus) | 2126 if (!s_getting_focus) |
2116 s_button_pending = -1; | 2127 s_button_pending = -1; |
2117 | 2128 |
2118 return OK; | 2129 return OK; |
2119 } | 2130 } |
2131 | |
2132 #ifdef FEAT_TIMERS | |
2133 if (did_add_timer) | |
2134 { | |
2135 /* Need to recompute the waiting time. */ | |
2136 remove_any_timer(); | |
2137 break; | |
2138 } | |
2139 #endif | |
2120 } | 2140 } |
2121 allow_scrollbar = FALSE; | 2141 allow_scrollbar = FALSE; |
2122 return FAIL; | 2142 return FAIL; |
2123 } | 2143 } |
2124 | 2144 |