From 5f71d0ad2483dfb366aff4a069246fd95b1a7793 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Tue, 22 Oct 2019 21:43:40 +0200 Subject: [PATCH] Fix bug that prevented the user to type accents correctly on some keyboard layouts. Fix #86 --- native/libwinbridge/bridge.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/native/libwinbridge/bridge.cpp b/native/libwinbridge/bridge.cpp index dfe6108..f7fa9e7 100644 --- a/native/libwinbridge/bridge.cpp +++ b/native/libwinbridge/bridge.cpp @@ -243,7 +243,12 @@ LRESULT CALLBACK window_procedure(HWND window, unsigned int msg, WPARAM wp, LPAR if (GetKeyboardState(lpKeyState.data())) { // Convert the virtual key to an unicode char std::array buffer; - int result = ToUnicodeEx(raw->data.keyboard.VKey, raw->data.keyboard.MakeCode, lpKeyState.data(), buffer.data(), buffer.size(), 0, currentKeyboardLayout); + + // This flag is needed to avoid chaning the keyboard state for some layouts. + // Refer to issue: https://github.com/federico-terzi/espanso/issues/86 + UINT flags = 1 << 2; + + int result = ToUnicodeEx(raw->data.keyboard.VKey, raw->data.keyboard.MakeCode, lpKeyState.data(), buffer.data(), buffer.size(), flags, currentKeyboardLayout); //std::cout << result << " " << buffer[0] << " " << raw->data.keyboard.VKey << std::endl;