5f528de
To: vim-dev@vim.org
5f528de
Subject: Patch 7.2.264
5f528de
Fcc: outbox
5f528de
From: Bram Moolenaar <Bram@moolenaar.net>
5f528de
Mime-Version: 1.0
5f528de
Content-Type: text/plain; charset=UTF-8
5f528de
Content-Transfer-Encoding: 8bit
5f528de
------------
5f528de
5f528de
Patch 7.2.264
5f528de
Problem:    GTK2: When the Vim window is maximized setting 'columns' or
5f528de
	    'lines' doesn't work.
5f528de
Solution:   Unmaximize the window before setting the size. (Vitaly Minko)
5f528de
Files:	    src/gui.c, src/gui_gtk_x11.c, src/proto/gui_gtk_x11.pro
5f528de
5f528de
5f528de
*** ../vim-7.2.263/src/gui.c	2009-07-29 11:10:31.000000000 +0200
5f528de
--- src/gui.c	2009-09-23 16:28:09.000000000 +0200
5f528de
***************
5f528de
*** 1386,1391 ****
5f528de
--- 1386,1395 ----
5f528de
      int		min_height;
5f528de
      int		screen_w;
5f528de
      int		screen_h;
5f528de
+ #ifdef HAVE_GTK2
5f528de
+     int		un_maximize = mustset;
5f528de
+     int         did_adjust = 0;
5f528de
+ #endif
5f528de
  
5f528de
      if (!gui.shell_created)
5f528de
  	return;
5f528de
***************
5f528de
*** 1425,1446 ****
5f528de
  	    if (Columns < MIN_COLUMNS)
5f528de
  		Columns = MIN_COLUMNS;
5f528de
  	    width = Columns * gui.char_width + base_width;
5f528de
  	}
5f528de
  	if ((direction & RESIZE_VERT) && height > screen_h)
5f528de
  	{
5f528de
  	    Rows = (screen_h - base_height) / gui.char_height;
5f528de
  	    check_shellsize();
5f528de
  	    height = Rows * gui.char_height + base_height;
5f528de
  	}
5f528de
      }
5f528de
      gui.num_cols = Columns;
5f528de
      gui.num_rows = Rows;
5f528de
  
5f528de
      min_width = base_width + MIN_COLUMNS * gui.char_width;
5f528de
      min_height = base_height + MIN_LINES * gui.char_height;
5f528de
! # ifdef FEAT_WINDOWS
5f528de
      min_height += tabline_height() * gui.char_height;
5f528de
! # endif
5f528de
  
5f528de
      gui_mch_set_shellsize(width, height, min_width, min_height,
5f528de
  					  base_width, base_height, direction);
5f528de
--- 1429,1475 ----
5f528de
  	    if (Columns < MIN_COLUMNS)
5f528de
  		Columns = MIN_COLUMNS;
5f528de
  	    width = Columns * gui.char_width + base_width;
5f528de
+ #ifdef HAVE_GTK2
5f528de
+ 	    ++did_adjust;
5f528de
+ #endif
5f528de
  	}
5f528de
  	if ((direction & RESIZE_VERT) && height > screen_h)
5f528de
  	{
5f528de
  	    Rows = (screen_h - base_height) / gui.char_height;
5f528de
  	    check_shellsize();
5f528de
  	    height = Rows * gui.char_height + base_height;
5f528de
+ #ifdef HAVE_GTK2
5f528de
+ 	    ++did_adjust;
5f528de
+ #endif
5f528de
  	}
5f528de
+ #ifdef HAVE_GTK2
5f528de
+ 	if (did_adjust == 2 || (width + gui.char_width >= screen_w
5f528de
+ 				     && height + gui.char_height >= screen_h))
5f528de
+ 	    /* don't unmaximize if at maximum size */
5f528de
+ 	    un_maximize = FALSE;
5f528de
+ #endif
5f528de
      }
5f528de
      gui.num_cols = Columns;
5f528de
      gui.num_rows = Rows;
5f528de
  
5f528de
      min_width = base_width + MIN_COLUMNS * gui.char_width;
5f528de
      min_height = base_height + MIN_LINES * gui.char_height;
5f528de
! #ifdef FEAT_WINDOWS
5f528de
      min_height += tabline_height() * gui.char_height;
5f528de
! #endif
5f528de
! 
5f528de
! #ifdef HAVE_GTK2
5f528de
!     if (un_maximize)
5f528de
!     {
5f528de
! 	/* If the window size is smaller than the screen unmaximize the
5f528de
! 	 * window, otherwise resizing won't work. */
5f528de
! 	gui_mch_get_screen_dimensions(&screen_w, &screen_h);
5f528de
! 	if ((width + gui.char_width < screen_w
5f528de
! 				   || height + gui.char_height * 2 < screen_h)
5f528de
! 		&& gui_mch_maximized())
5f528de
! 	    gui_mch_unmaximize();
5f528de
!     }
5f528de
! #endif
5f528de
  
5f528de
      gui_mch_set_shellsize(width, height, min_width, min_height,
5f528de
  					  base_width, base_height, direction);
5f528de
*** ../vim-7.2.263/src/gui_gtk_x11.c	2009-09-23 17:35:17.000000000 +0200
5f528de
--- src/gui_gtk_x11.c	2009-09-23 15:43:52.000000000 +0200
5f528de
***************
5f528de
*** 4376,4381 ****
5f528de
--- 4376,4404 ----
5f528de
  #endif
5f528de
  #endif /* HAVE_GTK2 */
5f528de
  
5f528de
+ #if defined(HAVE_GTK2) || defined(PROTO)
5f528de
+ /*
5f528de
+  * Return TRUE if the main window is maximized.
5f528de
+  */
5f528de
+     int
5f528de
+ gui_mch_maximized()
5f528de
+ {
5f528de
+     return (gui.mainwin != NULL && gui.mainwin->window != NULL
5f528de
+ 	    && (gdk_window_get_state(gui.mainwin->window)
5f528de
+ 					       & GDK_WINDOW_STATE_MAXIMIZED));
5f528de
+ }
5f528de
+ 
5f528de
+ /*
5f528de
+  * Unmaximize the main window
5f528de
+  */
5f528de
+     void
5f528de
+ gui_mch_unmaximize()
5f528de
+ {
5f528de
+     if (gui.mainwin != NULL)
5f528de
+ 	gtk_window_unmaximize(GTK_WINDOW(gui.mainwin));
5f528de
+ }
5f528de
+ #endif
5f528de
+ 
5f528de
  /*
5f528de
   * Set the windows size.
5f528de
   */
5f528de
*** ../vim-7.2.263/src/proto/gui_gtk_x11.pro	2007-05-05 19:18:54.000000000 +0200
5f528de
--- src/proto/gui_gtk_x11.pro	2009-09-23 15:43:45.000000000 +0200
5f528de
***************
5f528de
*** 16,21 ****
5f528de
--- 16,23 ----
5f528de
  void gui_mch_exit __ARGS((int rc));
5f528de
  int gui_mch_get_winpos __ARGS((int *x, int *y));
5f528de
  void gui_mch_set_winpos __ARGS((int x, int y));
5f528de
+ int gui_mch_maximized __ARGS((void));
5f528de
+ void gui_mch_unmaximize __ARGS((void));
5f528de
  void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction));
5f528de
  void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h));
5f528de
  void gui_mch_settitle __ARGS((char_u *title, char_u *icon));
5f528de
*** ../vim-7.2.263/src/version.c	2009-09-23 17:35:17.000000000 +0200
5f528de
--- src/version.c	2009-09-23 18:12:21.000000000 +0200
5f528de
***************
5f528de
*** 678,679 ****
5f528de
--- 678,681 ----
5f528de
  {   /* Add new patch number below this line */
5f528de
+ /**/
5f528de
+     264,
5f528de
  /**/
5f528de
5f528de
-- 
5f528de
hundred-and-one symptoms of being an internet addict:
5f528de
268. You get up in the morning and go online before getting your coffee.
5f528de
5f528de
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
5f528de
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
5f528de
\\\        download, build and distribute -- http://www.A-A-P.org        ///
5f528de
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///