GetKeyboardLayout() is also tested manually on Windows 10 with Korean, Chinese, and Japanese IME activated.
-- v2: win32u: Don't set the high word of keyboard layout to 0xe001 in CJK locales. user32/tests: Test keyboard layout in CJK locales.
From: Zhiyi Zhang zzhang@codeweavers.com
Also tested manually on Windows 10 with Korean, Chinese, and Japanese IME activated. --- dlls/user32/tests/input.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 12fa459205a..b954293b5a3 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -5420,6 +5420,33 @@ static void test_input_desktop( char **argv ) ok_ret( 1, SetCursorPos( pos.x, pos.y ) ); }
+static void test_keyboard_layout(void) +{ + const CHAR *layout_name; + LANGID lang_id; + HKL hkl; + + /* Test that the high word of the keyboard layout in CJK locale is the same as the low word, + * even when IME is on */ + lang_id = PRIMARYLANGID(GetUserDefaultLCID()); + if (lang_id == LANG_CHINESE || lang_id == LANG_JAPANESE || lang_id == LANG_KOREAN) + { + hkl = GetKeyboardLayout(0); + todo_wine + ok(HIWORD(hkl) == LOWORD(hkl), "Got unexpected hkl %p.\n", hkl); + + if (lang_id == LANG_CHINESE) + layout_name = "00000804"; + else if (lang_id == LANG_JAPANESE) + layout_name = "00000411"; + else if (lang_id == LANG_KOREAN) + layout_name = "00000412"; + hkl = LoadKeyboardLayoutA(layout_name, 0); + todo_wine + ok(HIWORD(hkl) == LOWORD(hkl), "Got unexpected hkl %p.\n", hkl); + } +} + START_TEST(input) { char **argv; @@ -5454,6 +5481,7 @@ START_TEST(input) test_ToUnicode(); test_ToAscii(); test_get_async_key_state(); + test_keyboard_layout(); test_keyboard_layout_name(); test_ActivateKeyboardLayout( argv ); test_key_names();
From: Zhiyi Zhang zzhang@codeweavers.com
The high word of the keyboard layout in CJK locale on Vista+ is the same as the low word, even when IME is on according to tests in user32 and manual tests on Windows 10.
Fix Super Robo Wars 30 (SteamID: 898750) crash on start when CJK locales are used. --- dlls/user32/input.c | 15 +-------------- dlls/user32/tests/input.c | 2 -- dlls/win32u/input.c | 15 +-------------- 3 files changed, 2 insertions(+), 30 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 8f3cd8acae7..1fff29c7f87 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -38,7 +38,6 @@ WINE_DECLARE_DEBUG_CHANNEL(keyboard); static HKL get_locale_kbd_layout(void) { ULONG_PTR layout; - LANGID langid;
/* FIXME: * @@ -52,19 +51,7 @@ static HKL get_locale_kbd_layout(void) */
layout = GetUserDefaultLCID(); - - /* - * Microsoft Office expects this value to be something specific - * for Japanese and Korean Windows with an IME the value is 0xe001 - * We should probably check to see if an IME exists and if so then - * set this word properly. - */ - langid = PRIMARYLANGID( LANGIDFROMLCID( layout ) ); - if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN) - layout = MAKELONG( layout, 0xe001 ); /* IME */ - else - layout = MAKELONG( layout, layout ); - + layout = MAKELONG( layout, layout ); return (HKL)layout; }
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index b954293b5a3..32bae76bf6e 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -5432,7 +5432,6 @@ static void test_keyboard_layout(void) if (lang_id == LANG_CHINESE || lang_id == LANG_JAPANESE || lang_id == LANG_KOREAN) { hkl = GetKeyboardLayout(0); - todo_wine ok(HIWORD(hkl) == LOWORD(hkl), "Got unexpected hkl %p.\n", hkl);
if (lang_id == LANG_CHINESE) @@ -5442,7 +5441,6 @@ static void test_keyboard_layout(void) else if (lang_id == LANG_KOREAN) layout_name = "00000412"; hkl = LoadKeyboardLayoutA(layout_name, 0); - todo_wine ok(HIWORD(hkl) == LOWORD(hkl), "Got unexpected hkl %p.\n", hkl); } } diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index 3ee46f0bfcf..248bfa1daa4 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -913,7 +913,6 @@ DWORD get_input_state(void) static HKL get_locale_kbd_layout(void) { LCID layout; - LANGID langid;
/* FIXME: * @@ -927,19 +926,7 @@ static HKL get_locale_kbd_layout(void) */
NtQueryDefaultLocale( TRUE, &layout ); - - /* - * Microsoft Office expects this value to be something specific - * for Japanese and Korean Windows with an IME the value is 0xe001 - * We should probably check to see if an IME exists and if so then - * set this word properly. - */ - langid = PRIMARYLANGID( LANGIDFROMLCID( layout ) ); - if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN) - layout = MAKELONG( layout, 0xe001 ); /* IME */ - else - layout = MAKELONG( layout, layout ); - + layout = MAKELONG( layout, layout ); return ULongToHandle( layout ); }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=142218
Your paranoid android.
=== w10pro64_ar (64 bit report) ===
user32: input.c:3657: Test failed: 04010c01 / f0201009: WaitForSingleObject returned 0x102 input.c:3680: Test failed: 04010c01 / f0201009: got change_hkl 0000000000000000 input.c:3685: Test failed: 04010c01 / f0201009: got tmp_layout FFFFFFFFF0201009
=== debian11 (32 bit zh:CN report) ===
user32: input.c:555: Test failed: peek: lmenu_vkey_peeked: 1: 2: got msg WM_SYSCHAR, wparam 0x66, lparam 0x20020001 input.c:555: Test failed: peek: shift_vkey: 1: 2: got msg WM_CHAR, wparam 0x46, lparam 0x20001 input.c:555: Test failed: receive: lmenu_vkey: 1: 2: got msg WM_SYSCHAR, wparam 0x66, lparam 0x20020001 input.c:555: Test failed: receive: lmenu_vkey: 1: 3: got msg WM_SYSCOMMAND, wparam 0xf100, lparam 0x66 input.c:555: Test failed: receive: shift_vkey: 1: 2: got msg WM_CHAR, wparam 0x46, lparam 0x20001
v2: Remove 0xe001 regardless of OS version. Remove 0xe001 in the get_locale_kbd_layout() in user32 as well.
This merge request was approved by Rémi Bernon.
Wait, so are we just going to break Office?
I know that modern Windows often breaks things that worked in older Windows, but that doesn't mean we should do the same thing. Rather the opposite, I think, since in some cases Wine is not just free software, but the *only* way to run programs.
That hack is 20 years old and it was done in a completely different environment without much justification. We now have better support for IME, which is the only thing that set 0xE000 as high HKL bits, and if Office truly breaks for anyone, which I doubt it will, we can then fix that properly.
Can we please at least *test* it first, and if it's actually broken then fix that *first*?
The hack was introduced by b0c2e54 back in 2003. The comment about Microsoft Office doesn't go into detail about what breaks exactly. Anyway, I tested Word, PowerPoint, and Excel with Office 97, 2000 and 2003. They all work correctly with this MR applied using an XP prefix and a Chinese IME. For what it's worth, I do prefer keeping the 0xe001 on XP and lower, just to be on the safe side.
Thanks for testing it. I understand that it might feel safer to keep things like that but imo this is the only opportunity we have to get rid of these hacks that nobody knows why they are here for anymore and if they even were truly needed.