@@ -136,20 +136,11 @@ static guicolor_T prev_sp_color = INVALCOLOR;
136136static XButtonPressedEvent last_mouse_event ;
137137#endif
138138
139- static void gui_x11_timer_cb (XtPointer timed_out , XtIntervalId * interval_id );
140- static void gui_x11_visibility_cb (Widget w , XtPointer dud , XEvent * event , Boolean * dum );
141- static void gui_x11_expose_cb (Widget w , XtPointer dud , XEvent * event , Boolean * dum );
142- static void gui_x11_resize_window_cb (Widget w , XtPointer dud , XEvent * event , Boolean * dum );
143- static void gui_x11_focus_change_cb (Widget w , XtPointer data , XEvent * event , Boolean * dum );
144- static void gui_x11_enter_cb (Widget w , XtPointer data , XEvent * event , Boolean * dum );
145- static void gui_x11_leave_cb (Widget w , XtPointer data , XEvent * event , Boolean * dum );
146- static void gui_x11_mouse_cb (Widget w , XtPointer data , XEvent * event , Boolean * dum );
147139static void gui_x11_check_copy_area (void );
148140#ifdef FEAT_CLIENTSERVER
149141static void gui_x11_send_event_handler (Widget , XtPointer , XEvent * , Boolean * );
150142#endif
151143static void gui_x11_wm_protocol_handler (Widget , XtPointer , XEvent * , Boolean * );
152- static void gui_x11_blink_cb (XtPointer timed_out , XtIntervalId * interval_id );
153144static Cursor gui_x11_create_blank_mouse (void );
154145static void draw_curl (int row , int col , int cells );
155146
@@ -574,6 +565,25 @@ gui_x11_timer_cb(
574565 * ((int * )timed_out ) = TRUE;
575566}
576567
568+ #ifdef FEAT_JOB_CHANNEL
569+ static void
570+ channel_poll_cb (
571+ XtPointer client_data ,
572+ XtIntervalId * interval_id UNUSED )
573+ {
574+ XtIntervalId * channel_timer = (XtIntervalId * )client_data ;
575+
576+ /* Using an event handler for a channel that may be disconnected does
577+ * not work, it hangs. Instead poll for messages. */
578+ channel_handle_events (TRUE);
579+ parse_queued_messages ();
580+
581+ /* repeat */
582+ * channel_timer = XtAppAddTimeOut (app_context , (long_u )20 ,
583+ channel_poll_cb , client_data );
584+ }
585+ #endif
586+
577587 static void
578588gui_x11_visibility_cb (
579589 Widget w UNUSED ,
@@ -2698,12 +2708,22 @@ gui_mch_wait_for_chars(long wtime)
26982708 static int timed_out ;
26992709 XtIntervalId timer = (XtIntervalId )0 ;
27002710 XtInputMask desired ;
2711+ #ifdef FEAT_JOB_CHANNEL
2712+ XtIntervalId channel_timer = (XtIntervalId )0 ;
2713+ #endif
27012714
27022715 timed_out = FALSE;
27032716
27042717 if (wtime > 0 )
27052718 timer = XtAppAddTimeOut (app_context , (long_u )wtime , gui_x11_timer_cb ,
27062719 & timed_out );
2720+ #ifdef FEAT_JOB_CHANNEL
2721+ /* If there is a channel with the keep_open flag we need to poll for input
2722+ * on them. */
2723+ if (channel_any_keep_open ())
2724+ channel_timer = XtAppAddTimeOut (app_context , (long_u )20 ,
2725+ channel_poll_cb , (XtPointer )& channel_timer );
2726+ #endif
27072727
27082728 focus = gui .in_focus ;
27092729#ifdef ALT_X_INPUT
@@ -2755,6 +2775,10 @@ gui_mch_wait_for_chars(long wtime)
27552775
27562776 if (timer != (XtIntervalId )0 && !timed_out )
27572777 XtRemoveTimeOut (timer );
2778+ #ifdef FEAT_JOB_CHANNEL
2779+ if (channel_timer != (XtIntervalId )0 )
2780+ XtRemoveTimeOut (channel_timer );
2781+ #endif
27582782
27592783 return retval ;
27602784}
@@ -3087,25 +3111,6 @@ gui_mch_stop_blink(void)
30873111 blink_state = BLINK_NONE ;
30883112}
30893113
3090- /*
3091- * Start the cursor blinking. If it was already blinking, this restarts the
3092- * waiting time and shows the cursor.
3093- */
3094- void
3095- gui_mch_start_blink (void )
3096- {
3097- if (blink_timer != (XtIntervalId )0 )
3098- XtRemoveTimeOut (blink_timer );
3099- /* Only switch blinking on if none of the times is zero */
3100- if (blink_waittime && blink_ontime && blink_offtime && gui .in_focus )
3101- {
3102- blink_timer = XtAppAddTimeOut (app_context , blink_waittime ,
3103- gui_x11_blink_cb , NULL );
3104- blink_state = BLINK_ON ;
3105- gui_update_cursor (TRUE, FALSE);
3106- }
3107- }
3108-
31093114 static void
31103115gui_x11_blink_cb (
31113116 XtPointer timed_out UNUSED ,
@@ -3127,6 +3132,25 @@ gui_x11_blink_cb(
31273132 }
31283133}
31293134
3135+ /*
3136+ * Start the cursor blinking. If it was already blinking, this restarts the
3137+ * waiting time and shows the cursor.
3138+ */
3139+ void
3140+ gui_mch_start_blink (void )
3141+ {
3142+ if (blink_timer != (XtIntervalId )0 )
3143+ XtRemoveTimeOut (blink_timer );
3144+ /* Only switch blinking on if none of the times is zero */
3145+ if (blink_waittime && blink_ontime && blink_offtime && gui .in_focus )
3146+ {
3147+ blink_timer = XtAppAddTimeOut (app_context , blink_waittime ,
3148+ gui_x11_blink_cb , NULL );
3149+ blink_state = BLINK_ON ;
3150+ gui_update_cursor (TRUE, FALSE);
3151+ }
3152+ }
3153+
31303154/*
31313155 * Return the RGB value of a pixel as a long.
31323156 */
0 commit comments