Karsten Hopp 503829
To: vim_dev@googlegroups.com
Karsten Hopp 503829
Subject: Patch 7.3.520
Karsten Hopp 503829
Fcc: outbox
Karsten Hopp 503829
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 503829
Mime-Version: 1.0
Karsten Hopp 503829
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 503829
Content-Transfer-Encoding: 8bit
Karsten Hopp 503829
------------
Karsten Hopp 503829
Karsten Hopp 503829
Patch 7.3.520
Karsten Hopp 503829
Problem:    Gvim starts up slow on Unbuntu 12.04.
Karsten Hopp 503829
Solution:   Move the call to gui_mch_init_check() to after fork(). (Yasuhiro
Karsten Hopp 503829
	    Matsumoto)  Do check $DISPLAY being set.
Karsten Hopp 503829
Files:	    src/gui.c, src/gui_gtk_x11.c, src/proto/gui_gtk_x11.pro
Karsten Hopp 503829
Karsten Hopp 503829
Karsten Hopp 503829
*** ../vim-7.3.519/src/gui.c	2011-10-20 21:27:57.000000000 +0200
Karsten Hopp 503829
--- src/gui.c	2012-05-18 16:53:14.000000000 +0200
Karsten Hopp 503829
***************
Karsten Hopp 503829
*** 270,275 ****
Karsten Hopp 503829
--- 270,281 ----
Karsten Hopp 503829
      }
Karsten Hopp 503829
      /* Child */
Karsten Hopp 503829
  
Karsten Hopp 503829
+ #ifdef FEAT_GUI_GTK
Karsten Hopp 503829
+     /* Call gtk_init_check() here after fork(). See gui_init_check(). */
Karsten Hopp 503829
+     if (gui_mch_init_check() != OK)
Karsten Hopp 503829
+ 	exit(1);
Karsten Hopp 503829
+ #endif
Karsten Hopp 503829
+ 
Karsten Hopp 503829
  # if defined(HAVE_SETSID) || defined(HAVE_SETPGID)
Karsten Hopp 503829
      /*
Karsten Hopp 503829
       * Change our process group.  On some systems/shells a CTRL-C in the
Karsten Hopp 503829
***************
Karsten Hopp 503829
*** 430,436 ****
Karsten Hopp 503829
--- 436,452 ----
Karsten Hopp 503829
  #ifdef ALWAYS_USE_GUI
Karsten Hopp 503829
      result = OK;
Karsten Hopp 503829
  #else
Karsten Hopp 503829
+ # ifdef FEAT_GUI_GTK
Karsten Hopp 503829
+     /*
Karsten Hopp 503829
+      * Note: Don't call gtk_init_check() before fork, it will be called after
Karsten Hopp 503829
+      * the fork. When calling it before fork, it make vim hang for a while.
Karsten Hopp 503829
+      * See gui_do_fork().
Karsten Hopp 503829
+      * Use a simpler check if the GUI window can probably be opened.
Karsten Hopp 503829
+      */
Karsten Hopp 503829
+     result = gui.dofork ? gui_mch_early_init_check() : gui_mch_init_check();
Karsten Hopp 503829
+ # else
Karsten Hopp 503829
      result = gui_mch_init_check();
Karsten Hopp 503829
+ # endif
Karsten Hopp 503829
  #endif
Karsten Hopp 503829
      return result;
Karsten Hopp 503829
  }
Karsten Hopp 503829
*** ../vim-7.3.519/src/gui_gtk_x11.c	2011-10-26 11:36:21.000000000 +0200
Karsten Hopp 503829
--- src/gui_gtk_x11.c	2012-05-18 17:00:45.000000000 +0200
Karsten Hopp 503829
***************
Karsten Hopp 503829
*** 1414,1420 ****
Karsten Hopp 503829
  }
Karsten Hopp 503829
  
Karsten Hopp 503829
  /*
Karsten Hopp 503829
!  * Check if the GUI can be started.  Called before gvimrc is sourced.
Karsten Hopp 503829
   * Return OK or FAIL.
Karsten Hopp 503829
   */
Karsten Hopp 503829
      int
Karsten Hopp 503829
--- 1414,1442 ----
Karsten Hopp 503829
  }
Karsten Hopp 503829
  
Karsten Hopp 503829
  /*
Karsten Hopp 503829
!  * Check if the GUI can be started.  Called before gvimrc is sourced and
Karsten Hopp 503829
!  * before fork().
Karsten Hopp 503829
!  * Return OK or FAIL.
Karsten Hopp 503829
!  */
Karsten Hopp 503829
!     int
Karsten Hopp 503829
! gui_mch_early_init_check(void)
Karsten Hopp 503829
! {
Karsten Hopp 503829
!     char_u *p;
Karsten Hopp 503829
! 
Karsten Hopp 503829
!     /* Guess that when $DISPLAY isn't set the GUI can't start. */
Karsten Hopp 503829
!     p = mch_getenv((char_u *)"DISPLAY");
Karsten Hopp 503829
!     if (p == NULL || *p == NUL)
Karsten Hopp 503829
!     {
Karsten Hopp 503829
! 	gui.dying = TRUE;
Karsten Hopp 503829
! 	EMSG(_((char *)e_opendisp));
Karsten Hopp 503829
! 	return FAIL;
Karsten Hopp 503829
!     }
Karsten Hopp 503829
!     return OK;
Karsten Hopp 503829
! }
Karsten Hopp 503829
! 
Karsten Hopp 503829
! /*
Karsten Hopp 503829
!  * Check if the GUI can be started.  Called before gvimrc is sourced but after
Karsten Hopp 503829
!  * fork().
Karsten Hopp 503829
   * Return OK or FAIL.
Karsten Hopp 503829
   */
Karsten Hopp 503829
      int
Karsten Hopp 503829
***************
Karsten Hopp 503829
*** 3050,3056 ****
Karsten Hopp 503829
  
Karsten Hopp 503829
      for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
Karsten Hopp 503829
      {
Karsten Hopp 503829
! 	/* OpenOffice tries to use TARGET_HTML and fails when it doesn't
Karsten Hopp 503829
  	 * return something, instead of trying another target. Therefore only
Karsten Hopp 503829
  	 * offer TARGET_HTML when it works. */
Karsten Hopp 503829
  	if (!clip_html && selection_targets[i].info == TARGET_HTML)
Karsten Hopp 503829
--- 3072,3078 ----
Karsten Hopp 503829
  
Karsten Hopp 503829
      for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
Karsten Hopp 503829
      {
Karsten Hopp 503829
! 	/* OpenOffice tries to use TARGET_HTML and fails when we don't
Karsten Hopp 503829
  	 * return something, instead of trying another target. Therefore only
Karsten Hopp 503829
  	 * offer TARGET_HTML when it works. */
Karsten Hopp 503829
  	if (!clip_html && selection_targets[i].info == TARGET_HTML)
Karsten Hopp 503829
*** ../vim-7.3.519/src/proto/gui_gtk_x11.pro	2011-08-10 17:44:41.000000000 +0200
Karsten Hopp 503829
--- src/proto/gui_gtk_x11.pro	2012-05-18 16:54:28.000000000 +0200
Karsten Hopp 503829
***************
Karsten Hopp 503829
*** 4,9 ****
Karsten Hopp 503829
--- 4,10 ----
Karsten Hopp 503829
  void gui_mch_set_blinking __ARGS((long waittime, long on, long off));
Karsten Hopp 503829
  void gui_mch_stop_blink __ARGS((void));
Karsten Hopp 503829
  void gui_mch_start_blink __ARGS((void));
Karsten Hopp 503829
+ int gui_mch_early_init_check __ARGS((void));
Karsten Hopp 503829
  int gui_mch_init_check __ARGS((void));
Karsten Hopp 503829
  void gui_mch_show_tabline __ARGS((int showit));
Karsten Hopp 503829
  int gui_mch_showing_tabline __ARGS((void));
Karsten Hopp 503829
*** ../vim-7.3.519/src/version.c	2012-05-18 16:35:17.000000000 +0200
Karsten Hopp 503829
--- src/version.c	2012-05-18 16:45:30.000000000 +0200
Karsten Hopp 503829
***************
Karsten Hopp 503829
*** 716,717 ****
Karsten Hopp 503829
--- 716,719 ----
Karsten Hopp 503829
  {   /* Add new patch number below this line */
Karsten Hopp 503829
+ /**/
Karsten Hopp 503829
+     520,
Karsten Hopp 503829
  /**/
Karsten Hopp 503829
Karsten Hopp 503829
-- 
Karsten Hopp 503829
Bad programs can be written in any language.
Karsten Hopp 503829
Karsten Hopp 503829
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 503829
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 503829
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 503829
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///