patch 8.0.0396: 'balloonexpr' only works synchronously

Problem:    'balloonexpr' only works synchronously.
Solution:   Add balloon_show(). (Jusufadis Bakamovic, closes #1449)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index a470ff9..70b90ad 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -58,6 +58,9 @@
 static void f_atan(typval_T *argvars, typval_T *rettv);
 static void f_atan2(typval_T *argvars, typval_T *rettv);
 #endif
+#ifdef FEAT_BEVAL
+static void f_balloon_show(typval_T *argvars, typval_T *rettv);
+#endif
 static void f_browse(typval_T *argvars, typval_T *rettv);
 static void f_browsedir(typval_T *argvars, typval_T *rettv);
 static void f_bufexists(typval_T *argvars, typval_T *rettv);
@@ -484,6 +487,9 @@
     {"atan",		1, 1, f_atan},
     {"atan2",		2, 2, f_atan2},
 #endif
+#ifdef FEAT_BEVAL
+    {"balloon_show",	1, 1, f_balloon_show},
+#endif
     {"browse",		4, 4, f_browse},
     {"browsedir",	2, 2, f_browsedir},
     {"bufexists",	1, 1, f_bufexists},
@@ -1363,6 +1369,17 @@
 #endif
 
 /*
+ * "balloon_show()" function
+ */
+#ifdef FEAT_BEVAL
+    static void
+f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
+{
+    gui_mch_post_balloon(balloonEval, get_tv_string_chk(&argvars[0]));
+}
+#endif
+
+/*
  * "browse(save, title, initdir, default)" function
  */
     static void
diff --git a/src/os_unix.c b/src/os_unix.c
index 48359d3..6220044 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -467,6 +467,12 @@
 	if ((wait_time < 0 || wait_time > 100L) && channel_any_readahead())
 	    wait_time = 10L;
 #endif
+#ifdef FEAT_BEVAL
+	if (p_beval && wait_time > 100L)
+	    /* The 'balloonexpr' may indirectly invoke a callback while waiting
+	     * for a character, need to check often. */
+	    wait_time = 100L;
+#endif
 
 	/*
 	 * We want to be interrupted by the winch signal
diff --git a/src/os_win32.c b/src/os_win32.c
index adbb199..a304842 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -1467,6 +1467,12 @@
 		    dwWaitTime = 10;
 	    }
 #endif
+#ifdef FEAT_BEVAL
+	    if (p_beval && dwWaitTime > 100)
+		/* The 'balloonexpr' may indirectly invoke a callback while
+		 * waiting for a character, need to check often. */
+		dwWaitTime = 100;
+#endif
 #ifdef FEAT_MZSCHEME
 	    if (mzthreads_allowed() && p_mzq > 0
 				    && (msec < 0 || (long)dwWaitTime > p_mzq))
diff --git a/src/version.c b/src/version.c
index 796162b..0c9731d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    396,
+/**/
     395,
 /**/
     394,