From 32c7d5d3522e43af2a5cffcd5f824f6a956b2ec8 Mon Sep 17 00:00:00 2001 From: pionere Date: Tue, 18 Jan 2022 17:44:51 +0100 Subject: [PATCH] cleanup IME_UpdateInputLocale - do not store the HKL in a static variable - always set the ime_candvertical value in case the HKL is changed --- src/video/windows/SDL_windowskeyboard.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index c1237d50b..c68fe105d 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -712,26 +712,13 @@ IME_SetWindow(SDL_VideoData* videodata, HWND hwnd) static void IME_UpdateInputLocale(SDL_VideoData *videodata) { - static HKL hklprev = 0; - videodata->ime_hkl = GetKeyboardLayout(0); - if (hklprev == videodata->ime_hkl) + HKL hklnext = GetKeyboardLayout(0); + + if (hklnext == videodata->ime_hkl) return; - hklprev = videodata->ime_hkl; - switch (PRIMLANG()) { - case LANG_CHINESE: - videodata->ime_candvertical = SDL_TRUE; - if (SUBLANG() == SUBLANG_CHINESE_SIMPLIFIED) - videodata->ime_candvertical = SDL_FALSE; - - break; - case LANG_JAPANESE: - videodata->ime_candvertical = SDL_TRUE; - break; - case LANG_KOREAN: - videodata->ime_candvertical = SDL_FALSE; - break; - } + videodata->ime_hkl = hklnext; + videodata->ime_candvertical = (PRIMLANG() == LANG_KOREAN || LANG() == LANG_CHS) ? SDL_FALSE : SDL_TRUE; } static void