Commit: 7e5cb9474837ea25cbdb8ae36c67faacb74ed317 Author: Harley Acheson Date: Tue Dec 13 18:30:20 2022 -0800 Branches: blender-v3.4-release https://developer.blender.org/rB7e5cb9474837ea25cbdb8ae36c67faacb74ed317
Fix T103119: Allow Win32 Diacritical Composition Allow keyboard layouts which include "dead keys" to enter diacritics by calling MapVirtualKeyW even when not key_down. See D16770 for more details. Differential Revision: https://developer.blender.org/D16770 Reviewed by Campbell Barton =================================================================== M intern/ghost/intern/GHOST_SystemWin32.cpp =================================================================== diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 4d016373fc6..dc350bb58a1 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1195,16 +1195,16 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA const bool ctrl_pressed = has_state && state[VK_CONTROL] & 0x80; const bool alt_pressed = has_state && state[VK_MENU] & 0x80; - if (!key_down) { - /* Pass. */ - } + /* We can be here with !key_down if processing dead keys (diacritics). See T103119. */ + /* No text with control key pressed (Alt can be used to insert special characters though!). */ - else if (ctrl_pressed && !alt_pressed) { + if (ctrl_pressed && !alt_pressed) { /* Pass. */ } /* Don't call #ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical - * composition. */ - else if (MapVirtualKeyW(vk, 2) != 0) { + * composition. XXX: we are not checking return of MapVirtualKeyW for high bit set, which is + * what is supposed to indicate dead keys. But this is working now so approach cautiously. */ + else if (MapVirtualKeyW(vk, MAPVK_VK_TO_CHAR) != 0) { wchar_t utf16[3] = {0}; int r; /* TODO: #ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here). @@ -1219,6 +1219,10 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA utf8_char[0] = '\0'; } } + if (!key_down) { + /* Clear or wm_event_add_ghostevent will warn of unexpected data on key up. */ + utf8_char[0] = '\0'; + } } #ifdef WITH_INPUT_IME _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs