Skip to content

Commit 7b45b06

Browse files
committed
updated for version 7.4.523
Problem: When the X11 server is stopped and restarted, while Vim is kept in the background, copy/paste no longer works. (Issue 203) Solution: Setup the clipboard again. (Christian Brabandt)
1 parent a2d2092 commit 7b45b06

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/os_unix.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,12 +1586,15 @@ x_IOerror_check(dpy)
15861586
* An X IO Error handler, used to catch terminal errors.
15871587
*/
15881588
static int x_IOerror_handler __ARGS((Display *dpy));
1589+
static void may_restore_clipboard __ARGS((void));
1590+
static int xterm_dpy_was_reset = FALSE;
15891591

15901592
static int
15911593
x_IOerror_handler(dpy)
15921594
Display *dpy UNUSED;
15931595
{
15941596
xterm_dpy = NULL;
1597+
xterm_dpy_was_reset = TRUE;
15951598
x11_window = 0;
15961599
x11_display = NULL;
15971600
xterm_Shell = (Widget)0;
@@ -1602,6 +1605,22 @@ x_IOerror_handler(dpy)
16021605
return 0; /* avoid the compiler complains about missing return value */
16031606
# endif
16041607
}
1608+
1609+
/*
1610+
* If the X11 connection was lost try to restore it.
1611+
* Helps when the X11 server was stopped and restarted while Vim was inactive
1612+
* (e.g. though tmux).
1613+
*/
1614+
static void
1615+
may_restore_clipboard()
1616+
{
1617+
if (xterm_dpy_was_reset)
1618+
{
1619+
xterm_dpy_was_reset = FALSE;
1620+
setup_term_clip();
1621+
get_x11_title(FALSE);
1622+
}
1623+
}
16051624
#endif
16061625

16071626
/*
@@ -5274,6 +5293,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
52745293
}
52755294
# endif
52765295
# ifdef FEAT_XCLIPBOARD
5296+
may_restore_clipboard();
52775297
if (xterm_Shell != (Widget)0)
52785298
{
52795299
xterm_idx = nfd;
@@ -5426,6 +5446,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
54265446
}
54275447
# endif
54285448
# ifdef FEAT_XCLIPBOARD
5449+
may_restore_clipboard();
54295450
if (xterm_Shell != (Widget)0)
54305451
{
54315452
FD_SET(ConnectionNumber(xterm_dpy), &rfds);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
523,
744746
/**/
745747
522,
746748
/**/

0 commit comments

Comments
 (0)