Mercurial > vim
comparison src/gui_x11.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 | 74b15ed0a259 |
children | bb86514cad15 |
comparison
equal
deleted
inserted
replaced
9178:4f47bb74ecb7 | 9179:5e18efdad322 |
---|---|
2366 if (!colortable) | 2366 if (!colortable) |
2367 return FAIL; /* out of memory */ | 2367 return FAIL; /* out of memory */ |
2368 | 2368 |
2369 for (i = 0; i < cmap_size; i++) | 2369 for (i = 0; i < cmap_size; i++) |
2370 colortable[i].pixel = (unsigned long)i; | 2370 colortable[i].pixel = (unsigned long)i; |
2371 XQueryColors (gui.dpy, colormap, colortable, cmap_size); | 2371 XQueryColors(gui.dpy, colormap, colortable, cmap_size); |
2372 | 2372 |
2373 /* | 2373 /* |
2374 * Find the color that best approximates the desired one, then | 2374 * Find the color that best approximates the desired one, then |
2375 * try to allocate that color. If that fails, it must mean that | 2375 * try to allocate that color. If that fails, it must mean that |
2376 * the color was read-write (so we can't use it, since it's owner | 2376 * the color was read-write (so we can't use it, since it's owner |
2790 * or FAIL otherwise. | 2790 * or FAIL otherwise. |
2791 */ | 2791 */ |
2792 int | 2792 int |
2793 gui_mch_wait_for_chars(long wtime) | 2793 gui_mch_wait_for_chars(long wtime) |
2794 { | 2794 { |
2795 int focus; | 2795 int focus; |
2796 int retval = FAIL; | |
2796 | 2797 |
2797 /* | 2798 /* |
2798 * Make this static, in case gui_x11_timer_cb is called after leaving | 2799 * Make this static, in case gui_x11_timer_cb is called after leaving |
2799 * this function (otherwise a random value on the stack may be changed). | 2800 * this function (otherwise a random value on the stack may be changed). |
2800 */ | 2801 */ |
2826 gui_mch_stop_blink(); | 2827 gui_mch_stop_blink(); |
2827 focus = gui.in_focus; | 2828 focus = gui.in_focus; |
2828 } | 2829 } |
2829 | 2830 |
2830 #ifdef MESSAGE_QUEUE | 2831 #ifdef MESSAGE_QUEUE |
2832 # ifdef FEAT_TIMERS | |
2833 did_add_timer = FALSE; | |
2834 # endif | |
2831 parse_queued_messages(); | 2835 parse_queued_messages(); |
2836 # ifdef FEAT_TIMERS | |
2837 if (did_add_timer) | |
2838 /* Need to recompute the waiting time. */ | |
2839 break; | |
2840 # endif | |
2832 #endif | 2841 #endif |
2833 | 2842 |
2834 /* | 2843 /* |
2835 * Don't use gui_mch_update() because then we will spin-lock until a | 2844 * Don't use gui_mch_update() because then we will spin-lock until a |
2836 * char arrives, instead we use XtAppProcessEvent() to hang until an | 2845 * char arrives, instead we use XtAppProcessEvent() to hang until an |
2841 */ | 2850 */ |
2842 XtAppProcessEvent(app_context, desired); | 2851 XtAppProcessEvent(app_context, desired); |
2843 | 2852 |
2844 if (input_available()) | 2853 if (input_available()) |
2845 { | 2854 { |
2846 if (timer != (XtIntervalId)0 && !timed_out) | 2855 retval = OK; |
2847 XtRemoveTimeOut(timer); | 2856 break; |
2848 return OK; | |
2849 } | 2857 } |
2850 } | 2858 } |
2851 return FAIL; | 2859 |
2860 if (timer != (XtIntervalId)0 && !timed_out) | |
2861 XtRemoveTimeOut(timer); | |
2862 | |
2863 return retval; | |
2852 } | 2864 } |
2853 | 2865 |
2854 /* | 2866 /* |
2855 * Output routines. | 2867 * Output routines. |
2856 */ | 2868 */ |