Karsten Hopp 2f6f86
To: vim_dev@googlegroups.com
Karsten Hopp 2f6f86
Subject: Patch 7.3.393
Karsten Hopp 2f6f86
Fcc: outbox
Karsten Hopp 2f6f86
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 2f6f86
Mime-Version: 1.0
Karsten Hopp 2f6f86
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 2f6f86
Content-Transfer-Encoding: 8bit
Karsten Hopp 2f6f86
------------
Karsten Hopp 2f6f86
Karsten Hopp 2f6f86
Patch 7.3.393
Karsten Hopp 2f6f86
Problem:    Win32: When resizing Vim it is always moved to the primary monitor
Karsten Hopp 2f6f86
	    if the secondary monitor is on the left.
Karsten Hopp 2f6f86
Solution:   Use the nearest monitor. (Yukihiro Nakadaira)
Karsten Hopp 2f6f86
Files:	    src/gui_w32.c
Karsten Hopp 2f6f86
Karsten Hopp 2f6f86
Karsten Hopp 2f6f86
*** ../vim-7.3.392/src/gui_w32.c	2011-12-15 21:51:32.000000000 +0100
Karsten Hopp 2f6f86
--- src/gui_w32.c	2012-01-04 20:25:58.000000000 +0100
Karsten Hopp 2f6f86
***************
Karsten Hopp 2f6f86
*** 1661,1669 ****
Karsten Hopp 2f6f86
  {
Karsten Hopp 2f6f86
      RECT	workarea_rect;
Karsten Hopp 2f6f86
      int		win_width, win_height;
Karsten Hopp 2f6f86
-     int		win_xpos, win_ypos;
Karsten Hopp 2f6f86
      WINDOWPLACEMENT wndpl;
Karsten Hopp 2f6f86
-     int		workarea_left;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
      /* Try to keep window completely on screen. */
Karsten Hopp 2f6f86
      /* Get position of the screen work area.  This is the part that is not
Karsten Hopp 2f6f86
--- 1661,1667 ----
Karsten Hopp 2f6f86
***************
Karsten Hopp 2f6f86
*** 1685,1693 ****
Karsten Hopp 2f6f86
  	GetWindowPlacement(s_hwnd, &wndpl);
Karsten Hopp 2f6f86
      }
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
-     win_xpos = wndpl.rcNormalPosition.left;
Karsten Hopp 2f6f86
-     win_ypos = wndpl.rcNormalPosition.top;
Karsten Hopp 2f6f86
- 
Karsten Hopp 2f6f86
      /* compute the size of the outside of the window */
Karsten Hopp 2f6f86
      win_width = width + GetSystemMetrics(SM_CXFRAME) * 2;
Karsten Hopp 2f6f86
      win_height = height + GetSystemMetrics(SM_CYFRAME) * 2
Karsten Hopp 2f6f86
--- 1683,1688 ----
Karsten Hopp 2f6f86
***************
Karsten Hopp 2f6f86
*** 1697,1732 ****
Karsten Hopp 2f6f86
  #endif
Karsten Hopp 2f6f86
  			;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     /* There is an inconsistency when using two monitors and Vim is on the
Karsten Hopp 2f6f86
!      * second (right) one: win_xpos will be the offset from the workarea of
Karsten Hopp 2f6f86
!      * the left monitor.  While with one monitor it's the offset from the
Karsten Hopp 2f6f86
!      * workarea (including a possible taskbar on the left).  Detect the second
Karsten Hopp 2f6f86
!      * monitor by checking for the left offset to be quite big. */
Karsten Hopp 2f6f86
!     if (workarea_rect.left > 300)
Karsten Hopp 2f6f86
! 	workarea_left = 0;
Karsten Hopp 2f6f86
!     else
Karsten Hopp 2f6f86
! 	workarea_left = workarea_rect.left;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     /* If the window is going off the screen, move it on to the screen.
Karsten Hopp 2f6f86
!      * win_xpos and win_ypos are relative to the workarea. */
Karsten Hopp 2f6f86
      if ((direction & RESIZE_HOR)
Karsten Hopp 2f6f86
! 	    && workarea_left + win_xpos + win_width > workarea_rect.right)
Karsten Hopp 2f6f86
! 	win_xpos = workarea_rect.right - win_width - workarea_left;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     if ((direction & RESIZE_HOR) && win_xpos < 0)
Karsten Hopp 2f6f86
! 	win_xpos = 0;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
      if ((direction & RESIZE_VERT)
Karsten Hopp 2f6f86
! 	  && workarea_rect.top + win_ypos + win_height > workarea_rect.bottom)
Karsten Hopp 2f6f86
! 	win_ypos = workarea_rect.bottom - win_height - workarea_rect.top;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     if ((direction & RESIZE_VERT) && win_ypos < 0)
Karsten Hopp 2f6f86
! 	win_ypos = 0;
Karsten Hopp 2f6f86
! 
Karsten Hopp 2f6f86
!     wndpl.rcNormalPosition.left = win_xpos;
Karsten Hopp 2f6f86
!     wndpl.rcNormalPosition.right = win_xpos + win_width;
Karsten Hopp 2f6f86
!     wndpl.rcNormalPosition.top = win_ypos;
Karsten Hopp 2f6f86
!     wndpl.rcNormalPosition.bottom = win_ypos + win_height;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
      /* set window position - we should use SetWindowPlacement rather than
Karsten Hopp 2f6f86
       * SetWindowPos as the MSDN docs say the coord systems returned by
Karsten Hopp 2f6f86
--- 1692,1723 ----
Karsten Hopp 2f6f86
  #endif
Karsten Hopp 2f6f86
  			;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     /* The following should take care of keeping Vim on the same monitor, no
Karsten Hopp 2f6f86
!      * matter if the secondary monitor is left or right of the primary
Karsten Hopp 2f6f86
!      * monitor. */
Karsten Hopp 2f6f86
!     wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + win_width;
Karsten Hopp 2f6f86
!     wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + win_height;
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     /* If the window is going off the screen, move it on to the screen. */
Karsten Hopp 2f6f86
      if ((direction & RESIZE_HOR)
Karsten Hopp 2f6f86
! 	    && wndpl.rcNormalPosition.right > workarea_rect.right)
Karsten Hopp 2f6f86
! 	OffsetRect(&wndpl.rcNormalPosition,
Karsten Hopp 2f6f86
! 		workarea_rect.right - wndpl.rcNormalPosition.right, 0);
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     if ((direction & RESIZE_HOR)
Karsten Hopp 2f6f86
! 	    && wndpl.rcNormalPosition.left < workarea_rect.left)
Karsten Hopp 2f6f86
! 	OffsetRect(&wndpl.rcNormalPosition,
Karsten Hopp 2f6f86
! 		workarea_rect.left - wndpl.rcNormalPosition.left, 0);
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
      if ((direction & RESIZE_VERT)
Karsten Hopp 2f6f86
! 	    && wndpl.rcNormalPosition.bottom > workarea_rect.bottom)
Karsten Hopp 2f6f86
! 	OffsetRect(&wndpl.rcNormalPosition,
Karsten Hopp 2f6f86
! 		0, workarea_rect.bottom - wndpl.rcNormalPosition.bottom);
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
!     if ((direction & RESIZE_VERT)
Karsten Hopp 2f6f86
! 	    && wndpl.rcNormalPosition.top < workarea_rect.top)
Karsten Hopp 2f6f86
! 	OffsetRect(&wndpl.rcNormalPosition,
Karsten Hopp 2f6f86
! 		0, workarea_rect.top - wndpl.rcNormalPosition.top);
Karsten Hopp 2f6f86
  
Karsten Hopp 2f6f86
      /* set window position - we should use SetWindowPlacement rather than
Karsten Hopp 2f6f86
       * SetWindowPos as the MSDN docs say the coord systems returned by
Karsten Hopp 2f6f86
*** ../vim-7.3.392/src/version.c	2012-01-04 19:34:32.000000000 +0100
Karsten Hopp 2f6f86
--- src/version.c	2012-01-04 20:28:57.000000000 +0100
Karsten Hopp 2f6f86
***************
Karsten Hopp 2f6f86
*** 716,717 ****
Karsten Hopp 2f6f86
--- 716,719 ----
Karsten Hopp 2f6f86
  {   /* Add new patch number below this line */
Karsten Hopp 2f6f86
+ /**/
Karsten Hopp 2f6f86
+     393,
Karsten Hopp 2f6f86
  /**/
Karsten Hopp 2f6f86
Karsten Hopp 2f6f86
-- 
Karsten Hopp 2f6f86
I wonder, do vegetarians eat fruit bats?
Karsten Hopp 2f6f86
Karsten Hopp 2f6f86
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 2f6f86
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 2f6f86
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 2f6f86
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///