Mercurial > vim
comparison src/gui_gtk_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 | fc69eed19ba7 |
children | bb86514cad15 |
comparison
equal
deleted
inserted
replaced
9178:4f47bb74ecb7 | 9179:5e18efdad322 |
---|---|
6533 * or FAIL otherwise. | 6533 * or FAIL otherwise. |
6534 */ | 6534 */ |
6535 int | 6535 int |
6536 gui_mch_wait_for_chars(long wtime) | 6536 gui_mch_wait_for_chars(long wtime) |
6537 { | 6537 { |
6538 int focus; | 6538 int focus; |
6539 guint timer; | 6539 guint timer; |
6540 static int timed_out; | 6540 static int timed_out; |
6541 int retval = FAIL; | |
6541 | 6542 |
6542 timed_out = FALSE; | 6543 timed_out = FALSE; |
6543 | 6544 |
6544 /* this timeout makes sure that we will return if no characters arrived in | 6545 /* this timeout makes sure that we will return if no characters arrived in |
6545 * time */ | 6546 * time */ |
6546 | |
6547 if (wtime > 0) | 6547 if (wtime > 0) |
6548 #if GTK_CHECK_VERSION(3,0,0) | 6548 #if GTK_CHECK_VERSION(3,0,0) |
6549 timer = g_timeout_add((guint)wtime, input_timer_cb, &timed_out); | 6549 timer = g_timeout_add((guint)wtime, input_timer_cb, &timed_out); |
6550 #else | 6550 #else |
6551 timer = gtk_timeout_add((guint32)wtime, input_timer_cb, &timed_out); | 6551 timer = gtk_timeout_add((guint32)wtime, input_timer_cb, &timed_out); |
6566 gui_mch_stop_blink(); | 6566 gui_mch_stop_blink(); |
6567 focus = gui.in_focus; | 6567 focus = gui.in_focus; |
6568 } | 6568 } |
6569 | 6569 |
6570 #ifdef MESSAGE_QUEUE | 6570 #ifdef MESSAGE_QUEUE |
6571 # ifdef FEAT_TIMERS | |
6572 did_add_timer = FALSE; | |
6573 # endif | |
6571 parse_queued_messages(); | 6574 parse_queued_messages(); |
6575 # ifdef FEAT_TIMERS | |
6576 if (did_add_timer) | |
6577 /* Need to recompute the waiting time. */ | |
6578 goto theend; | |
6579 # endif | |
6572 #endif | 6580 #endif |
6573 | 6581 |
6574 /* | 6582 /* |
6575 * Loop in GTK+ processing until a timeout or input occurs. | 6583 * Loop in GTK+ processing until a timeout or input occurs. |
6576 * Skip this if input is available anyway (can happen in rare | 6584 * Skip this if input is available anyway (can happen in rare |
6580 g_main_context_iteration(NULL, TRUE); | 6588 g_main_context_iteration(NULL, TRUE); |
6581 | 6589 |
6582 /* Got char, return immediately */ | 6590 /* Got char, return immediately */ |
6583 if (input_available()) | 6591 if (input_available()) |
6584 { | 6592 { |
6585 if (timer != 0 && !timed_out) | 6593 retval = OK; |
6586 #if GTK_CHECK_VERSION(3,0,0) | 6594 goto theend; |
6587 g_source_remove(timer); | |
6588 #else | |
6589 gtk_timeout_remove(timer); | |
6590 #endif | |
6591 return OK; | |
6592 } | 6595 } |
6593 } while (wtime < 0 || !timed_out); | 6596 } while (wtime < 0 || !timed_out); |
6594 | 6597 |
6595 /* | 6598 /* |
6596 * Flush all eventually pending (drawing) events. | 6599 * Flush all eventually pending (drawing) events. |
6597 */ | 6600 */ |
6598 gui_mch_update(); | 6601 gui_mch_update(); |
6599 | 6602 |
6600 return FAIL; | 6603 theend: |
6604 if (timer != 0 && !timed_out) | |
6605 #if GTK_CHECK_VERSION(3,0,0) | |
6606 g_source_remove(timer); | |
6607 #else | |
6608 gtk_timeout_remove(timer); | |
6609 #endif | |
6610 | |
6611 return retval; | |
6601 } | 6612 } |
6602 | 6613 |
6603 | 6614 |
6604 /**************************************************************************** | 6615 /**************************************************************************** |
6605 * Output drawing routines. | 6616 * Output drawing routines. |