mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
experiment with win98 support for ime
This commit is contained in:
parent
d3bdef9083
commit
672a29655c
@ -44,6 +44,12 @@ bool bResponsive_minimized_fullscreen_window = config_wgldisplay.GetBool("respon
|
|||||||
// will crab out WireGL.
|
// will crab out WireGL.
|
||||||
bool support_wiregl = config_wgldisplay.GetBool("support-wiregl", false);
|
bool support_wiregl = config_wgldisplay.GetBool("support-wiregl", false);
|
||||||
|
|
||||||
|
// For now, set this true to use the IME correctly on Win2000, or
|
||||||
|
// false on Win98. This is temporary; once we have been able to
|
||||||
|
// verify that this distinction is actually necessary, we can replace
|
||||||
|
// this config variable with an actual OS detection.
|
||||||
|
bool ime_composition_w = config_wgldisplay.GetBool("ime-composition-w", true);
|
||||||
|
|
||||||
extern void AtExitFn(void);
|
extern void AtExitFn(void);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -37,6 +37,7 @@ extern bool gl_sync_video;
|
|||||||
extern int gl_forced_pixfmt;
|
extern int gl_forced_pixfmt;
|
||||||
extern bool bResponsive_minimized_fullscreen_window;
|
extern bool bResponsive_minimized_fullscreen_window;
|
||||||
extern bool support_wiregl;
|
extern bool support_wiregl;
|
||||||
|
extern bool ime_composition_w;
|
||||||
|
|
||||||
extern EXPCL_PANDAGL void init_libwgldisplay();
|
extern EXPCL_PANDAGL void init_libwgldisplay();
|
||||||
|
|
||||||
|
@ -519,6 +519,20 @@ void wglGraphicsWindow::config() {
|
|||||||
ImmReleaseContext(_mwindow, hIMC);
|
ImmReleaseContext(_mwindow, hIMC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check the version of the OS we are running. If we are running
|
||||||
|
// win2000, we must use ImmGetCompositionStringW() to report the
|
||||||
|
// characters returned by the IME, since WM_CHAR and
|
||||||
|
// ImmGetCompositionStringA() both just return question marks.
|
||||||
|
// However, this function doesn't work for Win98; on this OS, we
|
||||||
|
// have to use ImmGetCompositionStringA() instead, which returns an
|
||||||
|
// encoded string in shift-jis (which we then have to decode).
|
||||||
|
|
||||||
|
// For now, this is user-configurable, to allow testing of this code
|
||||||
|
// on both OS's. After we verify that truth of the above claim, we
|
||||||
|
// should base this decision on GetVersionEx() or maybe
|
||||||
|
// VerifyVersionInfo().
|
||||||
|
_ime_composition_w = ime_composition_w;
|
||||||
|
|
||||||
hwnd_pandawin_map[_mwindow] = this;
|
hwnd_pandawin_map[_mwindow] = this;
|
||||||
global_wglwinptr = NULL; // get rid of any reference to this obj
|
global_wglwinptr = NULL; // get rid of any reference to this obj
|
||||||
|
|
||||||
@ -1662,14 +1676,16 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
static const int max_ime_result = 128;
|
static const int max_ime_result = 128;
|
||||||
static char ime_result[max_ime_result];
|
static char ime_result[max_ime_result];
|
||||||
|
|
||||||
// There's a rumor that ImmGetCompositionStringW() doesn't
|
if (_ime_composition_w) {
|
||||||
// work for Win95 or Win98; for these OS's we must use
|
// Since ImmGetCompositionStringA() doesn't seem to work
|
||||||
// ImmGetCompositionStringA(). How does this affect the
|
// for Win2000 (it always returns question mark
|
||||||
// returning of multibyte characters?
|
// characters), we have to use ImmGetCompositionStringW()
|
||||||
|
// on this OS. This is actually the easier of the two
|
||||||
|
// functions to use.
|
||||||
|
|
||||||
DWORD result_size =
|
DWORD result_size =
|
||||||
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR,
|
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR,
|
||||||
ime_result, max_ime_result);
|
ime_result, max_ime_result);
|
||||||
ImmReleaseContext(hwnd, hIMC);
|
|
||||||
|
|
||||||
// Add this string into the text buffer of the application.
|
// Add this string into the text buffer of the application.
|
||||||
|
|
||||||
@ -1684,6 +1700,35 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
|||||||
(unsigned char)ime_result[i];
|
(unsigned char)ime_result[i];
|
||||||
_input_devices[0].keystroke(result);
|
_input_devices[0].keystroke(result);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// On the other hand, ImmGetCompositionStringW() doesn't
|
||||||
|
// work on Win95 or Win98; for these OS's we must use
|
||||||
|
// ImmGetCompositionStringA().
|
||||||
|
DWORD result_size =
|
||||||
|
ImmGetCompositionStringA(hIMC, GCS_RESULTSTR,
|
||||||
|
ime_result, max_ime_result);
|
||||||
|
|
||||||
|
// ImmGetCompositionStringA() returned an encoded ANSI
|
||||||
|
// string, which we now have to map to wide-character
|
||||||
|
// Unicode.
|
||||||
|
static const int max_wide_result = 128;
|
||||||
|
static wchar_t wide_result[max_wide_result];
|
||||||
|
|
||||||
|
int wide_size =
|
||||||
|
MultiByteToWideChar(CP_ACP, 0,
|
||||||
|
ime_result, result_size,
|
||||||
|
wide_result, max_wide_result);
|
||||||
|
if (wide_size == 0) {
|
||||||
|
PrintErrorMessage(LAST_ERROR);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < wide_size; i++) {
|
||||||
|
_input_devices[0].keystroke(wide_result[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImmReleaseContext(hwnd, hIMC);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -131,6 +131,7 @@ private:
|
|||||||
bool _mouse_passive_motion_enabled;
|
bool _mouse_passive_motion_enabled;
|
||||||
bool _mouse_entry_enabled;
|
bool _mouse_entry_enabled;
|
||||||
bool _ime_open;
|
bool _ime_open;
|
||||||
|
bool _ime_composition_w;
|
||||||
|
|
||||||
// vars for frames/sec meter
|
// vars for frames/sec meter
|
||||||
DWORD _start_time;
|
DWORD _start_time;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user