Karsten Hopp 0cc05d
To: vim-dev@vim.org
Karsten Hopp 0cc05d
Subject: Patch 7.1.168 (extra)
Karsten Hopp 0cc05d
Fcc: outbox
Karsten Hopp 0cc05d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 0cc05d
Mime-Version: 1.0
Karsten Hopp 0cc05d
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 0cc05d
Content-Transfer-Encoding: 8bit
Karsten Hopp 0cc05d
------------
Karsten Hopp 0cc05d
Karsten Hopp 0cc05d
Patch 7.1.168 (extra)
Karsten Hopp 0cc05d
Problem:    Win32 GUI: Since patch 7.1.095, when the Vim window does not have
Karsten Hopp 0cc05d
	    focus, clicking in it doesn't position the cursor. (Juergen
Karsten Hopp 0cc05d
	    Kraemer)
Karsten Hopp 0cc05d
Solution:   Don't reset s_button_pending just after receiving focus.
Karsten Hopp 0cc05d
Files:	    src/gui_w48.c
Karsten Hopp 0cc05d
Karsten Hopp 0cc05d
Karsten Hopp 0cc05d
*** ../vim-7.1.167/src/gui_w48.c	Tue Nov 20 17:21:28 2007
Karsten Hopp 0cc05d
--- src/gui_w48.c	Mon Dec  3 22:13:16 2007
Karsten Hopp 0cc05d
***************
Karsten Hopp 0cc05d
*** 290,295 ****
Karsten Hopp 0cc05d
--- 290,300 ----
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
  /* Local variables */
Karsten Hopp 0cc05d
  static int		s_button_pending = -1;
Karsten Hopp 0cc05d
+ 
Karsten Hopp 0cc05d
+ /* s_getting_focus is set when we got focus but didn't see mouse-up event yet,
Karsten Hopp 0cc05d
+  * so don't reset s_button_pending. */
Karsten Hopp 0cc05d
+ static int		s_getting_focus = FALSE;
Karsten Hopp 0cc05d
+ 
Karsten Hopp 0cc05d
  static int		s_x_pending;
Karsten Hopp 0cc05d
  static int		s_y_pending;
Karsten Hopp 0cc05d
  static UINT		s_kFlags_pending;
Karsten Hopp 0cc05d
***************
Karsten Hopp 0cc05d
*** 671,676 ****
Karsten Hopp 0cc05d
--- 676,683 ----
Karsten Hopp 0cc05d
  {
Karsten Hopp 0cc05d
      int vim_modifiers = 0x0;
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
+     s_getting_focus = FALSE;
Karsten Hopp 0cc05d
+ 
Karsten Hopp 0cc05d
      if (keyFlags & MK_SHIFT)
Karsten Hopp 0cc05d
  	vim_modifiers |= MOUSE_SHIFT;
Karsten Hopp 0cc05d
      if (keyFlags & MK_CONTROL)
Karsten Hopp 0cc05d
***************
Karsten Hopp 0cc05d
*** 792,797 ****
Karsten Hopp 0cc05d
--- 799,805 ----
Karsten Hopp 0cc05d
  {
Karsten Hopp 0cc05d
      int button;
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
+     s_getting_focus = FALSE;
Karsten Hopp 0cc05d
      if (s_button_pending > -1)
Karsten Hopp 0cc05d
      {
Karsten Hopp 0cc05d
  	/* Delayed action for mouse down event */
Karsten Hopp 0cc05d
***************
Karsten Hopp 0cc05d
*** 1951,1958 ****
Karsten Hopp 0cc05d
  	    allow_scrollbar = FALSE;
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
  	    /* Clear pending mouse button, the release event may have been
Karsten Hopp 0cc05d
! 	     * taken by the dialog window. */
Karsten Hopp 0cc05d
! 	    s_button_pending = -1;
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
  	    return OK;
Karsten Hopp 0cc05d
  	}
Karsten Hopp 0cc05d
--- 1959,1968 ----
Karsten Hopp 0cc05d
  	    allow_scrollbar = FALSE;
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
  	    /* Clear pending mouse button, the release event may have been
Karsten Hopp 0cc05d
! 	     * taken by the dialog window.  But don't do this when getting
Karsten Hopp 0cc05d
! 	     * focus, we need the mouse-up event then. */
Karsten Hopp 0cc05d
! 	    if (!s_getting_focus)
Karsten Hopp 0cc05d
! 		s_button_pending = -1;
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
  	    return OK;
Karsten Hopp 0cc05d
  	}
Karsten Hopp 0cc05d
***************
Karsten Hopp 0cc05d
*** 2702,2707 ****
Karsten Hopp 0cc05d
--- 2712,2718 ----
Karsten Hopp 0cc05d
      HWND hwndOldFocus)
Karsten Hopp 0cc05d
  {
Karsten Hopp 0cc05d
      gui_focus_change(TRUE);
Karsten Hopp 0cc05d
+     s_getting_focus = TRUE;
Karsten Hopp 0cc05d
      (void)MyWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0);
Karsten Hopp 0cc05d
  }
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
***************
Karsten Hopp 0cc05d
*** 2711,2716 ****
Karsten Hopp 0cc05d
--- 2722,2728 ----
Karsten Hopp 0cc05d
      HWND hwndNewFocus)
Karsten Hopp 0cc05d
  {
Karsten Hopp 0cc05d
      gui_focus_change(FALSE);
Karsten Hopp 0cc05d
+     s_getting_focus = FALSE;
Karsten Hopp 0cc05d
      (void)MyWindowProc(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0);
Karsten Hopp 0cc05d
  }
Karsten Hopp 0cc05d
  
Karsten Hopp 0cc05d
*** ../vim-7.1.167/src/version.c	Mon Dec  3 21:31:56 2007
Karsten Hopp 0cc05d
--- src/version.c	Mon Dec  3 22:16:32 2007
Karsten Hopp 0cc05d
***************
Karsten Hopp 0cc05d
*** 668,669 ****
Karsten Hopp 0cc05d
--- 668,671 ----
Karsten Hopp 0cc05d
  {   /* Add new patch number below this line */
Karsten Hopp 0cc05d
+ /**/
Karsten Hopp 0cc05d
+     168,
Karsten Hopp 0cc05d
  /**/
Karsten Hopp 0cc05d
Karsten Hopp 0cc05d
-- 
Karsten Hopp 0cc05d
Rule #1: Don't give somebody a tool that he's going to hurt himself with.
Karsten Hopp 0cc05d
Karsten Hopp 0cc05d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 0cc05d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 0cc05d
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 0cc05d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///