return 0;
}
+/*
+ * Return TRUE when connection to the X server is desired.
+ */
+ static int
+x_connect_to_server(void)
+{
+ // No point in connecting if we are exiting or dying.
+ if (exiting || v_dying)
+ return FALSE;
+
+#if defined(FEAT_CLIENTSERVER)
+ if (x_force_connect)
+ return TRUE;
+#endif
+ if (x_no_connect)
+ return FALSE;
+
+ /* Check for a match with "exclude:" from 'clipboard'. */
+ if (clip_exclude_prog != NULL)
+ {
+ if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0))
+ return FALSE;
+ }
+ return TRUE;
+}
+
#if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
# if defined(HAVE_SETJMP_H)
/*
static void
may_restore_clipboard(void)
{
- if (xterm_dpy_retry_count > 0)
+ // Only try restoring if we want the connection.
+ if (x_connect_to_server() && xterm_dpy_retry_count > 0)
{
--xterm_dpy_retry_count;
}
#endif
-/*
- * Return TRUE when connection to the X server is desired.
- */
- static int
-x_connect_to_server(void)
-{
-#if defined(FEAT_CLIENTSERVER)
- if (x_force_connect)
- return TRUE;
-#endif
- if (x_no_connect)
- return FALSE;
-
- /* Check for a match with "exclude:" from 'clipboard'. */
- if (clip_exclude_prog != NULL)
- {
- if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0))
- return FALSE;
- }
- return TRUE;
-}
-
/*
* Test if "dpy" and x11_window are valid by getting the window title.
* I don't actually want it yet, so there may be a simpler call to use, but