Patch 8.2.4965
Problem:    GUI: testing mouse move event depends on screen cell size.
Solution:   Multiply the row and column with the screen cell size.
Files:      runtime/doc/testing.txt, src/testing.c, src/testdir/test_gui.vim


*** ../vim-8.2.4964/runtime/doc/testing.txt     2022-04-03 15:46:57.385502610 
+0100
--- runtime/doc/testing.txt     2022-05-16 15:18:24.666016139 +0100
***************
*** 148,156 ****
                    move:       Optional; if used and TRUE then a mouse move
                                event can be generated.
                                Only {args} row: and col: are used and
!                               required; they are interpreted as pixels.
                                Only results in an event when 'mousemoveevent'
                                is set or a popup uses mouse move events.
  
                "scrollbar":
                  Set or drag the left, right or horizontal scrollbar.  Only
--- 154,165 ----
                    move:       Optional; if used and TRUE then a mouse move
                                event can be generated.
                                Only {args} row: and col: are used and
!                               required; they are interpreted as pixels or
!                               screen cells, depending on "cell".
                                Only results in an event when 'mousemoveevent'
                                is set or a popup uses mouse move events.
+                   cell:       Optional: when present and TRUE then "move"
+                               uses screen cells instead of pixel positions
  
                "scrollbar":
                  Set or drag the left, right or horizontal scrollbar.  Only
*** ../vim-8.2.4964/src/testing.c       2022-05-07 12:24:57.943638388 +0100
--- src/testing.c       2022-05-16 15:20:30.897918964 +0100
***************
*** 1386,1392 ****
--- 1386,1400 ----
      col = (int)dict_get_number(args, (char_u *)"col");
  
      if (move)
+     {
+       if (dict_get_bool(args, (char_u *)"cell", FALSE))
+       {
+           // click in the middle of the character cell
+           row = row * gui.char_height + gui.char_height / 2;
+           col = col * gui.char_width + gui.char_width / 2;
+       }
        gui_mouse_moved(col, row);
+     }
      else
      {
        button = (int)dict_get_number(args, (char_u *)"button");
*** ../vim-8.2.4964/src/testdir/test_gui.vim    2022-05-16 13:34:41.178881656 
+0100
--- src/testdir/test_gui.vim    2022-05-16 15:25:59.773661803 +0100
***************
*** 1209,1274 ****
    endif
  endfunc
  
  func Test_gui_mouse_move_event()
    let args = #{move: 1, button: 0, multiclick: 0, modifiers: 0}
  
!   " default, do not generate mouse move events
    set mousemev&
    call assert_false(&mousemev)
  
!   let g:n_event = 0
!   nnoremap <special> <MouseMove> :let g:n_event += 1<CR>
  
    " start at mouse pos (1,1), clear counter
    call PrepareForMouseEvent(args)
!   let g:n_event = 0
  
!   call extend(args, #{row: 30, col: 300})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 100, col: 300})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
    " no events since mousemev off
!   call assert_equal(0, g:n_event)
  
    " turn on mouse events and try the same thing
    set mousemev
    call PrepareForMouseEvent(args)
!   let g:n_event = 0
  
!   call extend(args, #{row: 30, col: 300})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 100, col: 300})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call assert_equal(2, g:n_event)
  
!   " wiggle the mouse around, shouldn't get events
    call PrepareForMouseEvent(args)
!   let g:n_event = 0
  
!   call extend(args, #{row: 1, col: 2})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 2, col: 2})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 2, col: 1})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call PrepareForMouseEvent(args)
!   call assert_equal(0, g:n_event)
  
!   unlet g:n_event
    unmap <MouseMove>
    set mousemev&
  endfunc
--- 1209,1279 ----
    endif
  endfunc
  
+ func MouseWasMoved()
+   let pos = getmousepos()
+   call add(g:eventlist, #{row: pos.screenrow, col: pos.screencol})
+ endfunc
+ 
  func Test_gui_mouse_move_event()
    let args = #{move: 1, button: 0, multiclick: 0, modifiers: 0}
  
!   " by default, does not generate mouse move events
    set mousemev&
    call assert_false(&mousemev)
  
!   let g:eventlist = []
!   nnoremap <special> <silent> <MouseMove> :call MouseWasMoved()<CR>
  
    " start at mouse pos (1,1), clear counter
    call PrepareForMouseEvent(args)
!   let g:eventlist = []
  
!   call extend(args, #{row: 3, col: 30, cell: v:true})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 10, col: 30, cell: v:true})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
    " no events since mousemev off
!   call assert_equal([], g:eventlist)
  
    " turn on mouse events and try the same thing
    set mousemev
    call PrepareForMouseEvent(args)
!   let g:eventlist = []
  
!   call extend(args, #{row: 3, col: 30, cell: v:true})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 10, col: 30, cell: v:true})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call assert_equal([#{row: 4, col: 31}, #{row: 11, col: 31}], g:eventlist)
  
!   " wiggle the mouse around within a screen cell, shouldn't trigger events
!   call extend(args, #{cell: v:false})
    call PrepareForMouseEvent(args)
!   let g:eventlist = []
  
!   call extend(args, #{row: 1, col: 2, cell: v:false})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 2, col: 2, cell: v:false})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call extend(args, #{row: 2, col: 1, cell: v:false})
    call test_gui_event('mouse', args)
    call feedkeys('', 'Lx!')
  
!   call assert_equal([], g:eventlist)
  
!   unlet g:eventlist
    unmap <MouseMove>
    set mousemev&
  endfunc
*** ../vim-8.2.4964/src/version.c       2022-05-16 13:34:41.178881656 +0100
--- src/version.c       2022-05-16 15:13:13.362249913 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4965,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
213. Your kids start referring to you as "that guy in front of the monitor."

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220516142817.A9D4F1C088A%40moolenaar.net.

Raspunde prin e-mail lui