Patch 8.2.4843 (after 8.2.4807)
Problem:    Win32 GUI: Treating CTRL + ALT as AltGr is not backwards
            compatible. (Axel Bender)
Solution:   Make a difference between left and right menu keys.
            (closes #10308)
Files:      src/gui_w32.c


*** ../vim-8.2.4842/src/gui_w32.c       2022-04-24 15:46:38.768342012 +0100
--- src/gui_w32.c       2022-04-28 19:48:55.746391964 +0100
***************
*** 827,839 ****
        modifiers |= MOD_MASK_CTRL;
      if (GetKeyState(VK_SHIFT) & 0x8000)
        modifiers |= MOD_MASK_SHIFT;
!     if (GetKeyState(VK_MENU) & 0x8000)
!       modifiers |= MOD_MASK_ALT;
!     // Windows handles Ctrl + Alt as AltGr, in that case no modifier is 
actually
      // pressed.
!     if ((modifiers & (MOD_MASK_CTRL | MOD_MASK_ALT)) ==
!           (MOD_MASK_CTRL | MOD_MASK_ALT))
!       modifiers &= ~(MOD_MASK_CTRL | MOD_MASK_ALT);
  
      return modifiers;
  }
--- 827,839 ----
        modifiers |= MOD_MASK_CTRL;
      if (GetKeyState(VK_SHIFT) & 0x8000)
        modifiers |= MOD_MASK_SHIFT;
!     // Windows handles Ctrl + Alt as AltGr and vice-versa. We can distinguish
!     // the two cases by checking whether the left or the right Alt key is
      // pressed.
!     if (GetKeyState(VK_LMENU) & 0x8000)
!       modifiers |= MOD_MASK_ALT;
!     if ((modifiers & MOD_MASK_CTRL) && (GetKeyState(VK_RMENU) & 0x8000))
!       modifiers &= ~MOD_MASK_CTRL;
  
      return modifiers;
  }
***************
*** 955,961 ****
        vim_modifiers |= MOUSE_SHIFT;
      if (keyFlags & MK_CONTROL)
        vim_modifiers |= MOUSE_CTRL;
!     if (GetKeyState(VK_MENU) & 0x8000)
        vim_modifiers |= MOUSE_ALT;
  
      gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers);
--- 955,961 ----
        vim_modifiers |= MOUSE_SHIFT;
      if (keyFlags & MK_CONTROL)
        vim_modifiers |= MOUSE_CTRL;
!     if (GetKeyState(VK_LMENU) & 0x8000)
        vim_modifiers |= MOUSE_ALT;
  
      gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers);
***************
*** 1722,1729 ****
      int i;
  
      for (i = 0; special_keys[i].vim_code1 != NUL; i++)
!       if (name[0] == special_keys[i].vim_code0 &&
!                                        name[1] == special_keys[i].vim_code1)
            return OK;
      return FAIL;
  }
--- 1722,1729 ----
      int i;
  
      for (i = 0; special_keys[i].vim_code1 != NUL; i++)
!       if (name[0] == special_keys[i].vim_code0
!                                      && name[1] == special_keys[i].vim_code1)
            return OK;
      return FAIL;
  }
***************
*** 1972,1978 ****
        {
            // ignore VK_SPACE when ALT key pressed: system menu
            if (special_keys[i].key_sym == vk
!                   && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000)))
            {
                /*
                 * Behave as expected if we have a dead key and the special key
--- 1972,1978 ----
        {
            // ignore VK_SPACE when ALT key pressed: system menu
            if (special_keys[i].key_sym == vk
!                   && (vk != VK_SPACE || !(GetKeyState(VK_LMENU) & 0x8000)))
            {
                /*
                 * Behave as expected if we have a dead key and the special key
***************
*** 2051,2058 ****
            if (GetKeyState(VK_CAPITAL) & 0x0001)
                keyboard_state[VK_CAPITAL] = 0x01;
            // Alt-Gr is synthesized as Alt + Ctrl.
!           if ((GetKeyState(VK_MENU) & 0x8000) &&
!                   (GetKeyState(VK_CONTROL) & 0x8000))
            {
                keyboard_state[VK_MENU] = 0x80;
                keyboard_state[VK_CONTROL] = 0x80;
--- 2051,2058 ----
            if (GetKeyState(VK_CAPITAL) & 0x0001)
                keyboard_state[VK_CAPITAL] = 0x01;
            // Alt-Gr is synthesized as Alt + Ctrl.
!           if ((GetKeyState(VK_RMENU) & 0x8000)
!                                        && (GetKeyState(VK_CONTROL) & 0x8000))
            {
                keyboard_state[VK_MENU] = 0x80;
                keyboard_state[VK_CONTROL] = 0x80;
*** ../vim-8.2.4842/src/version.c       2022-04-28 19:09:00.047208614 +0100
--- src/version.c       2022-04-28 19:47:37.362365516 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4843,
  /**/

-- 
>From "know your smileys":
¯\_(ツ)_/¯   Shrug

 /// 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/20220428185152.BF2961C05B5%40moolenaar.net.

Raspunde prin e-mail lui