# HG changeset patch # User Christian Brabandt # Date 1503848704 -7200 # Node ID 519e4e6bbc28e89bde1445d50510b2d06efaabb2 # Parent d0198daf0b9ca0d01d8ce906d14dcdb36588506e patch 8.0.1008: slow updating of terminal window in Motif commit https://github.com/vim/vim/commit/1dccf6351dd37e648b2e15fb9f9f71ceba88d446 Author: Bram Moolenaar Date: Sun Aug 27 17:38:27 2017 +0200 patch 8.0.1008: slow updating of terminal window in Motif Problem: Slow updating of terminal window in Motif. Solution: Add a timeout to the wait-for-character loop. diff --git a/src/gui_x11.c b/src/gui_x11.c --- a/src/gui_x11.c +++ b/src/gui_x11.c @@ -136,20 +136,11 @@ static guicolor_T prev_sp_color = INVALC static XButtonPressedEvent last_mouse_event; #endif -static void gui_x11_timer_cb(XtPointer timed_out, XtIntervalId *interval_id); -static void gui_x11_visibility_cb(Widget w, XtPointer dud, XEvent *event, Boolean *dum); -static void gui_x11_expose_cb(Widget w, XtPointer dud, XEvent *event, Boolean *dum); -static void gui_x11_resize_window_cb(Widget w, XtPointer dud, XEvent *event, Boolean *dum); -static void gui_x11_focus_change_cb(Widget w, XtPointer data, XEvent *event, Boolean *dum); -static void gui_x11_enter_cb(Widget w, XtPointer data, XEvent *event, Boolean *dum); -static void gui_x11_leave_cb(Widget w, XtPointer data, XEvent *event, Boolean *dum); -static void gui_x11_mouse_cb(Widget w, XtPointer data, XEvent *event, Boolean *dum); static void gui_x11_check_copy_area(void); #ifdef FEAT_CLIENTSERVER static void gui_x11_send_event_handler(Widget, XtPointer, XEvent *, Boolean *); #endif static void gui_x11_wm_protocol_handler(Widget, XtPointer, XEvent *, Boolean *); -static void gui_x11_blink_cb(XtPointer timed_out, XtIntervalId *interval_id); static Cursor gui_x11_create_blank_mouse(void); static void draw_curl(int row, int col, int cells); @@ -574,6 +565,25 @@ gui_x11_timer_cb( *((int *)timed_out) = TRUE; } +#ifdef FEAT_JOB_CHANNEL + static void +channel_poll_cb( + XtPointer client_data, + XtIntervalId *interval_id UNUSED) +{ + XtIntervalId *channel_timer = (XtIntervalId *)client_data; + + /* Using an event handler for a channel that may be disconnected does + * not work, it hangs. Instead poll for messages. */ + channel_handle_events(TRUE); + parse_queued_messages(); + + /* repeat */ + *channel_timer = XtAppAddTimeOut(app_context, (long_u)20, + channel_poll_cb, client_data); +} +#endif + static void gui_x11_visibility_cb( Widget w UNUSED, @@ -2698,12 +2708,22 @@ gui_mch_wait_for_chars(long wtime) static int timed_out; XtIntervalId timer = (XtIntervalId)0; XtInputMask desired; +#ifdef FEAT_JOB_CHANNEL + XtIntervalId channel_timer = (XtIntervalId)0; +#endif timed_out = FALSE; if (wtime > 0) timer = XtAppAddTimeOut(app_context, (long_u)wtime, gui_x11_timer_cb, &timed_out); +#ifdef FEAT_JOB_CHANNEL + /* If there is a channel with the keep_open flag we need to poll for input + * on them. */ + if (channel_any_keep_open()) + channel_timer = XtAppAddTimeOut(app_context, (long_u)20, + channel_poll_cb, (XtPointer)&channel_timer); +#endif focus = gui.in_focus; #ifdef ALT_X_INPUT @@ -2755,6 +2775,10 @@ gui_mch_wait_for_chars(long wtime) if (timer != (XtIntervalId)0 && !timed_out) XtRemoveTimeOut(timer); +#ifdef FEAT_JOB_CHANNEL + if (channel_timer != (XtIntervalId)0) + XtRemoveTimeOut(channel_timer); +#endif return retval; } @@ -3087,25 +3111,6 @@ gui_mch_stop_blink(void) blink_state = BLINK_NONE; } -/* - * Start the cursor blinking. If it was already blinking, this restarts the - * waiting time and shows the cursor. - */ - void -gui_mch_start_blink(void) -{ - if (blink_timer != (XtIntervalId)0) - XtRemoveTimeOut(blink_timer); - /* Only switch blinking on if none of the times is zero */ - if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) - { - blink_timer = XtAppAddTimeOut(app_context, blink_waittime, - gui_x11_blink_cb, NULL); - blink_state = BLINK_ON; - gui_update_cursor(TRUE, FALSE); - } -} - static void gui_x11_blink_cb( XtPointer timed_out UNUSED, @@ -3128,6 +3133,25 @@ gui_x11_blink_cb( } /* + * Start the cursor blinking. If it was already blinking, this restarts the + * waiting time and shows the cursor. + */ + void +gui_mch_start_blink(void) +{ + if (blink_timer != (XtIntervalId)0) + XtRemoveTimeOut(blink_timer); + /* Only switch blinking on if none of the times is zero */ + if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus) + { + blink_timer = XtAppAddTimeOut(app_context, blink_waittime, + gui_x11_blink_cb, NULL); + blink_state = BLINK_ON; + gui_update_cursor(TRUE, FALSE); + } +} + +/* * Return the RGB value of a pixel as a long. */ guicolor_T diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1008, +/**/ 1007, /**/ 1006,