Blame SOURCES/7.4.523

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.523
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.523
22c937
Problem:    When the X11 server is stopped and restarted, while Vim is kept in
22c937
	    the background, copy/paste no longer works. (Issue 203)
22c937
Solution:   Setup the clipboard again. (Christian Brabandt)
22c937
Files:	    src/os_unix.c
22c937
22c937
22c937
*** ../vim-7.4.522/src/os_unix.c	2014-11-19 16:38:01.520679869 +0100
22c937
--- src/os_unix.c	2014-11-19 18:34:45.505245180 +0100
22c937
***************
22c937
*** 1586,1597 ****
22c937
--- 1586,1600 ----
22c937
   * An X IO Error handler, used to catch terminal errors.
22c937
   */
22c937
  static int x_IOerror_handler __ARGS((Display *dpy));
22c937
+ static void may_restore_clipboard __ARGS((void));
22c937
+ static int xterm_dpy_was_reset = FALSE;
22c937
  
22c937
      static int
22c937
  x_IOerror_handler(dpy)
22c937
      Display *dpy UNUSED;
22c937
  {
22c937
      xterm_dpy = NULL;
22c937
+     xterm_dpy_was_reset = TRUE;
22c937
      x11_window = 0;
22c937
      x11_display = NULL;
22c937
      xterm_Shell = (Widget)0;
22c937
***************
22c937
*** 1602,1607 ****
22c937
--- 1605,1626 ----
22c937
      return 0;  /* avoid the compiler complains about missing return value */
22c937
  # endif
22c937
  }
22c937
+ 
22c937
+ /*
22c937
+  * If the X11 connection was lost try to restore it.
22c937
+  * Helps when the X11 server was stopped and restarted while Vim was inactive
22c937
+  * (e.g. though tmux).
22c937
+  */
22c937
+     static void
22c937
+ may_restore_clipboard()
22c937
+ {
22c937
+     if (xterm_dpy_was_reset)
22c937
+     {
22c937
+ 	xterm_dpy_was_reset = FALSE;
22c937
+ 	setup_term_clip();
22c937
+ 	get_x11_title(FALSE);
22c937
+     }
22c937
+ }
22c937
  #endif
22c937
  
22c937
  /*
22c937
***************
22c937
*** 5274,5279 ****
22c937
--- 5293,5299 ----
22c937
  	}
22c937
  # endif
22c937
  # ifdef FEAT_XCLIPBOARD
22c937
+ 	may_restore_clipboard();
22c937
  	if (xterm_Shell != (Widget)0)
22c937
  	{
22c937
  	    xterm_idx = nfd;
22c937
***************
22c937
*** 5426,5431 ****
22c937
--- 5446,5452 ----
22c937
  	}
22c937
  # endif
22c937
  # ifdef FEAT_XCLIPBOARD
22c937
+ 	may_restore_clipboard();
22c937
  	if (xterm_Shell != (Widget)0)
22c937
  	{
22c937
  	    FD_SET(ConnectionNumber(xterm_dpy), &rfds);
22c937
*** ../vim-7.4.522/src/version.c	2014-11-19 18:03:24.202559721 +0100
22c937
--- src/version.c	2014-11-19 18:48:06.140215792 +0100
22c937
***************
22c937
*** 743,744 ****
22c937
--- 743,746 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     523,
22c937
  /**/
22c937
22c937
-- 
22c937
There is no right or wrong, there is only your personal opinion.
22c937
                 (Bram Moolenaar)
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///