fixes what I was trying to fix for the last checkin

This commit is contained in:
Asad M. Zaman 2004-04-28 02:41:39 +00:00
parent 79a7b7c5da
commit 31ff26b6f4

View File

@ -1126,11 +1126,15 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
case WM_IME_COMPOSITION: case WM_IME_COMPOSITION:
if (ime_aware) { if (ime_aware) {
// If the ime window is not marked as active at this point, we // If the ime window is not marked as active at this point, we
// must be in the process of closing it down (in close_ime), and // must be in the process of closing it down (in close_ime), and
// we don't want to send the current composition string in that // we don't want to send the current composition string in that
// case. But we do need to return 0 to tell windows not to try // case. But we do need to return 0 to tell windows not to try
// to send the composition string through WM_CHAR messages. // to send the composition string through WM_CHAR messages.
if (!_ime_active)
return 0;
HIMC hIMC = ImmGetContext(hwnd); HIMC hIMC = ImmGetContext(hwnd);
nassertr(hIMC != 0, 0); nassertr(hIMC != 0, 0);
@ -1150,24 +1154,22 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
// functions to use. // functions to use.
if (lparam & GCS_RESULTSTR) { if (lparam & GCS_RESULTSTR) {
if (_ime_active) { windisplay_cat.debug() << "GCS_RESULTSTR\n";
windisplay_cat.debug() << "GCS_RESULTSTR\n"; result_size = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR,
result_size = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, ime_result, max_ime_result);
ime_result, max_ime_result);
// Add this string into the text buffer of the application. // Add this string into the text buffer of the application.
// ImmGetCompositionStringW() returns a string, but it's // ImmGetCompositionStringW() returns a string, but it's
// filled in with wstring data: every two characters defines a // filled in with wstring data: every two characters defines a
// 16-bit unicode char. The docs aren't clear on the // 16-bit unicode char. The docs aren't clear on the
// endianness of this. I guess it's safe to assume all Win32 // endianness of this. I guess it's safe to assume all Win32
// machines are little-endian. // machines are little-endian.
for (DWORD i = 0; i < result_size; i += 2) { for (DWORD i = 0; i < result_size; i += 2) {
int result = int result =
((int)(unsigned char)ime_result[i + 1] << 8) | ((int)(unsigned char)ime_result[i + 1] << 8) |
(unsigned char)ime_result[i]; (unsigned char)ime_result[i];
_input_devices[0].keystroke(result); _input_devices[0].keystroke(result);
}
} }
} }
if (lparam & GCS_COMPSTR) { if (lparam & GCS_COMPSTR) {
@ -1204,7 +1206,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
_input_devices[0].candidate(can_t, min(cursor_pos, delta_start), max(cursor_pos, delta_start), cursor_pos); _input_devices[0].candidate(can_t, min(cursor_pos, delta_start), max(cursor_pos, delta_start), cursor_pos);
} }
} else { } else {
if ((lparam & GCS_RESULTSTR) && _ime_active) { if (lparam & GCS_RESULTSTR) {
// On the other hand, ImmGetCompositionStringW() doesn't // On the other hand, ImmGetCompositionStringW() doesn't
// work on Win95 or Win98; for these OS's we must use // work on Win95 or Win98; for these OS's we must use
// ImmGetCompositionStringA(). // ImmGetCompositionStringA().