summaryrefslogtreecommitdiffstats
path: root/src/gui.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-07-29 17:35:23 +0200
committerBram Moolenaar <Bram@vim.org>2018-07-29 17:35:23 +0200
commit92d147be959e689f8f58fd5d138a31835e160289 (patch)
tree5ba25e99d246153860ba91d9fc7629b67801d993 /src/gui.c
parentfda95e75721fb221495c69e493ec2761b5d85123 (diff)
patch 8.1.0228: dropping files is ignored while Vim is busyv8.1.0228
Problem: Dropping files is ignored while Vim is busy. Solution: Postpone the effect of dropping files until it's safe.
Diffstat (limited to 'src/gui.c')
-rw-r--r--src/gui.c70
1 files changed, 39 insertions, 31 deletions
diff --git a/src/gui.c b/src/gui.c
index 15adb1f1df..82ca09dd27 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -5383,10 +5383,7 @@ gui_do_findrepl(
#endif
-#if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \
- || defined(FEAT_GUI_MSWIN) \
- || defined(FEAT_GUI_MAC) \
- || defined(PROTO)
+#if defined(HAVE_DROP_FILE) || defined(PROTO)
static void gui_wingoto_xy(int x, int y);
@@ -5409,6 +5406,42 @@ gui_wingoto_xy(int x, int y)
}
/*
+ * Function passed to handle_drop() for the actions to be done after the
+ * argument list has been updated.
+ */
+ static void
+drop_callback(void *cookie)
+{
+ char_u *p = cookie;
+
+ /* If Shift held down, change to first file's directory. If the first
+ * item is a directory, change to that directory (and let the explorer
+ * plugin show the contents). */
+ if (p != NULL)
+ {
+ if (mch_isdir(p))
+ {
+ if (mch_chdir((char *)p) == 0)
+ shorten_fnames(TRUE);
+ }
+ else if (vim_chdirfile(p, "drop") == OK)
+ shorten_fnames(TRUE);
+ vim_free(p);
+ }
+
+ /* Update the screen display */
+ update_screen(NOT_VALID);
+# ifdef FEAT_MENU
+ gui_update_menus(0);
+# endif
+#ifdef FEAT_TITLE
+ maketitle();
+#endif
+ setcursor();
+ out_flush_cursor(FALSE, FALSE);
+}
+
+/*
* Process file drop. Mouse cursor position, key modifiers, name of files
* and count of files are given. Argument "fnames[count]" has full pathnames
* of dropped files, they will be freed in this function, and caller can't use
@@ -5488,33 +5521,8 @@ gui_handle_drop(
vim_free(fnames);
}
else
- handle_drop(count, fnames, (modifiers & MOUSE_CTRL) != 0);
-
- /* If Shift held down, change to first file's directory. If the first
- * item is a directory, change to that directory (and let the explorer
- * plugin show the contents). */
- if (p != NULL)
- {
- if (mch_isdir(p))
- {
- if (mch_chdir((char *)p) == 0)
- shorten_fnames(TRUE);
- }
- else if (vim_chdirfile(p, "drop") == OK)
- shorten_fnames(TRUE);
- vim_free(p);
- }
-
- /* Update the screen display */
- update_screen(NOT_VALID);
-# ifdef FEAT_MENU
- gui_update_menus(0);
-# endif
-#ifdef FEAT_TITLE
- maketitle();
-#endif
- setcursor();
- out_flush_cursor(FALSE, FALSE);
+ handle_drop(count, fnames, (modifiers & MOUSE_CTRL) != 0,
+ drop_callback, (void *)p);
}
entered = FALSE;