Patch 8.0.1008
Problem:    Slow updating of terminal window in Motif.
Solution:   Add a timeout to the wait-for-character loop.
Files:      src/gui_x11.c


*** ../vim-8.0.1007/src/gui_x11.c       2017-07-24 20:15:25.551360752 +0200
--- src/gui_x11.c       2017-08-27 17:33:08.066830903 +0200
***************
*** 136,155 ****
  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);
  
--- 136,146 ----
***************
*** 574,579 ****
--- 565,589 ----
      *((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,2709 ****
--- 2708,2729 ----
      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,2760 ****
--- 2775,2784 ----
  
      if (timer != (XtIntervalId)0 && !timed_out)
        XtRemoveTimeOut(timer);
+ #ifdef FEAT_JOB_CHANNEL
+     if (channel_timer != (XtIntervalId)0)
+       XtRemoveTimeOut(channel_timer);
+ #endif
  
      return retval;
  }
***************
*** 3087,3111 ****
      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,
--- 3111,3116 ----
***************
*** 3127,3132 ****
--- 3132,3156 ----
      }
  }
  
+ /*
+  * 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.
   */
*** ../vim-8.0.1007/src/version.c       2017-08-27 16:53:57.786032946 +0200
--- src/version.c       2017-08-27 17:37:08.409271732 +0200
***************
*** 771,772 ****
--- 771,774 ----
  {   /* Add new patch number below this line */
+ /**/
+     1008,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
16. Have your coworkers address you by your wrestling name, Rock Hard Kim.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui