winemac: Use the ImeProcessKey driver entry to process IME input.

This commit is contained in:
Rémi Bernon 2023-05-02 12:14:19 +02:00 committed by Alexandre Julliard
parent c7dc10b192
commit f185dc1701
7 changed files with 22 additions and 143 deletions

View file

@ -302,6 +302,7 @@ static const struct user_driver_funcs macdrv_funcs =
.pUpdateClipboard = macdrv_UpdateClipboard, .pUpdateClipboard = macdrv_UpdateClipboard,
.pUpdateLayeredWindow = macdrv_UpdateLayeredWindow, .pUpdateLayeredWindow = macdrv_UpdateLayeredWindow,
.pVkKeyScanEx = macdrv_VkKeyScanEx, .pVkKeyScanEx = macdrv_VkKeyScanEx,
.pImeProcessKey = macdrv_ImeProcessKey,
.pNotifyIMEStatus = macdrv_NotifyIMEStatus, .pNotifyIMEStatus = macdrv_NotifyIMEStatus,
.pWindowMessage = macdrv_WindowMessage, .pWindowMessage = macdrv_WindowMessage,
.pWindowPosChanged = macdrv_WindowPosChanged, .pWindowPosChanged = macdrv_WindowPosChanged,

View file

@ -121,18 +121,6 @@ static BOOL UnlockRealIMC(HIMC hIMC)
return FALSE; return FALSE;
} }
static HIMCC ImeCreateBlankCompStr(void)
{
HIMCC rc;
LPCOMPOSITIONSTRING ptr;
rc = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
ptr = ImmLockIMCC(rc);
memset(ptr, 0, sizeof(COMPOSITIONSTRING));
ptr->dwSize = sizeof(COMPOSITIONSTRING);
ImmUnlockIMCC(rc);
return rc;
}
static int updateField(DWORD origLen, DWORD origOffset, DWORD currentOffset, static int updateField(DWORD origLen, DWORD origOffset, DWORD currentOffset,
LPBYTE target, LPBYTE source, DWORD* lenParam, LPBYTE target, LPBYTE source, DWORD* lenParam,
DWORD* offsetParam, BOOL wchars) DWORD* offsetParam, BOOL wchars)
@ -515,59 +503,6 @@ static void UpdateDataInDefaultIMEWindow(INPUTCONTEXT *lpIMC, HWND hwnd, BOOL sh
ImmUnlockIMCC(lpIMC->hCompStr); ImmUnlockIMCC(lpIMC->hCompStr);
} }
BOOL WINAPI ImeProcessKey(HIMC hIMC, UINT vKey, LPARAM lKeyData, const LPBYTE lpbKeyState)
{
struct process_text_input_params params =
{
.himc = (UINT_PTR)hIMC, .vkey = LOWORD(vKey), .scan = HIWORD(lKeyData),
.repeat = !!(lKeyData >> 30), .key_state = lpbKeyState,
};
LPINPUTCONTEXT lpIMC;
BOOL inIME;
UINT ret;
TRACE("hIMC %p vKey 0x%04x lKeyData 0x%08Ix lpbKeyState %p\n", hIMC, vKey, lKeyData, lpbKeyState);
switch (vKey)
{
case VK_SHIFT:
case VK_CONTROL:
case VK_CAPITAL:
case VK_MENU:
return FALSE;
}
inIME = MACDRV_CALL(ime_using_input_method, NULL);
lpIMC = LockRealIMC(hIMC);
if (lpIMC)
{
LPIMEPRIVATE myPrivate;
HWND hwnd = input_context_get_ui_hwnd( lpIMC );
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
if (inIME && !myPrivate->bInternalState)
ImmSetOpenStatus(RealIMC(FROM_MACDRV), TRUE);
else if (!inIME && myPrivate->bInternalState)
{
ShowWindow( hwnd, SW_HIDE );
ImmDestroyIMCC(lpIMC->hCompStr);
lpIMC->hCompStr = ImeCreateBlankCompStr();
ImmSetOpenStatus(RealIMC(FROM_MACDRV), FALSE);
}
myPrivate->bInternalState = inIME;
ImmUnlockIMCC(lpIMC->hPrivate);
}
UnlockRealIMC(hIMC);
if (!inIME) return FALSE;
TRACE( "Processing Mac 0x%04x\n", vKey );
ret = MACDRV_CALL( ime_process_text_input, &params );
return ret != 0;
}
BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect) BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect)
{ {
LPINPUTCONTEXT lpIMC; LPINPUTCONTEXT lpIMC;
@ -612,39 +547,16 @@ BOOL WINAPI ImeSelect(HIMC hIMC, BOOL fSelect)
UINT WINAPI ImeToAsciiEx(UINT uVKey, UINT uScanCode, const LPBYTE lpbKeyState, UINT WINAPI ImeToAsciiEx(UINT uVKey, UINT uScanCode, const LPBYTE lpbKeyState,
TRANSMSGLIST *lpdwTransKey, UINT fuState, HIMC hIMC) TRANSMSGLIST *lpdwTransKey, UINT fuState, HIMC hIMC)
{ {
UINT vkey;
LPINPUTCONTEXT lpIMC; LPINPUTCONTEXT lpIMC;
LPIMEPRIVATE myPrivate;
HWND hwnd;
TRACE("uVKey 0x%04x uScanCode 0x%04x fuState %u hIMC %p\n", uVKey, uScanCode, fuState, hIMC); TRACE("uVKey 0x%04x uScanCode 0x%04x fuState %u hIMC %p\n", uVKey, uScanCode, fuState, hIMC);
vkey = LOWORD(uVKey);
if (vkey == VK_KANA || vkey == VK_KANJI || vkey == VK_MENU)
{
TRACE("Skipping metakey\n");
return 0;
}
lpIMC = LockRealIMC(hIMC);
hwnd = input_context_get_ui_hwnd( lpIMC );
myPrivate = ImmLockIMCC(lpIMC->hPrivate);
if (!myPrivate->bInternalState)
{
ImmUnlockIMCC(lpIMC->hPrivate);
UnlockRealIMC(hIMC);
return 0;
}
ImmUnlockIMCC(lpIMC->hPrivate);
UnlockRealIMC(hIMC);
/* trigger the pending client_func_ime_set_text call */ /* trigger the pending client_func_ime_set_text call */
MACDRV_CALL(ime_get_text_input, NULL); MACDRV_CALL(ime_get_text_input, NULL);
if ((lpIMC = LockRealIMC(hIMC))) if ((lpIMC = LockRealIMC(hIMC)))
{ {
HWND hwnd = input_context_get_ui_hwnd( lpIMC );
UpdateDataInDefaultIMEWindow( lpIMC, hwnd, FALSE ); UpdateDataInDefaultIMEWindow( lpIMC, hwnd, FALSE );
UnlockRealIMC(hIMC); UnlockRealIMC(hIMC);
} }

View file

@ -1188,19 +1188,29 @@ void macdrv_hotkey_press(const macdrv_event *event)
/*********************************************************************** /***********************************************************************
* macdrv_process_text_input * ImeProcessKey (MACDRV.@)
*/ */
NTSTATUS macdrv_ime_process_text_input(void *arg) UINT macdrv_ImeProcessKey(HIMC himc, UINT wparam, UINT lparam, const BYTE *key_state)
{ {
struct process_text_input_params *params = arg;
struct macdrv_thread_data *thread_data = macdrv_thread_data(); struct macdrv_thread_data *thread_data = macdrv_thread_data();
void *himc = UlongToHandle(params->himc); WORD scan = HIWORD(lparam) & 0x1ff, vkey = LOWORD(wparam);
const BYTE *key_state = params->key_state; BOOL repeat = !!(lparam >> 30), pressed = !(lparam >> 31);
unsigned int flags; unsigned int flags;
int keyc, done = 0; int keyc, done = 0;
TRACE("vkey 0x%04x scan 0x%04x repeat %u himc %p\n", params->vkey, params->scan, TRACE("himc %p, scan %#x, vkey %#x, repeat %u, pressed %u\n",
params->repeat, himc); himc, scan, vkey, repeat, pressed);
if (!macdrv_using_input_method()) return 0;
switch (vkey)
{
case VK_SHIFT:
case VK_CONTROL:
case VK_CAPITAL:
case VK_MENU:
return 0;
}
flags = thread_data->last_modifiers; flags = thread_data->last_modifiers;
if (key_state[VK_SHIFT] & 0x80) if (key_state[VK_SHIFT] & 0x80)
@ -1222,14 +1232,13 @@ NTSTATUS macdrv_ime_process_text_input(void *arg)
/* Find the Mac keycode corresponding to the scan code */ /* Find the Mac keycode corresponding to the scan code */
for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++) for (keyc = 0; keyc < ARRAY_SIZE(thread_data->keyc2vkey); keyc++)
if (thread_data->keyc2vkey[keyc] == params->vkey) break; if (thread_data->keyc2vkey[keyc] == vkey) break;
if (keyc >= ARRAY_SIZE(thread_data->keyc2vkey)) return 0; if (keyc >= ARRAY_SIZE(thread_data->keyc2vkey)) return 0;
TRACE("flags 0x%08x keyc 0x%04x\n", flags, keyc); TRACE("flags 0x%08x keyc 0x%04x\n", flags, keyc);
macdrv_send_text_input_event(((params->scan & 0x8000) == 0), flags, params->repeat, keyc, macdrv_send_text_input_event(pressed, flags, repeat, keyc, himc, &done);
himc, &done);
while (!done) NtUserMsgWaitForMultipleObjectsEx(0, NULL, INFINITE, QS_POSTMESSAGE | QS_SENDMESSAGE, 0); while (!done) NtUserMsgWaitForMultipleObjectsEx(0, NULL, INFINITE, QS_POSTMESSAGE | QS_SENDMESSAGE, 0);
return done > 0; return done > 0;

View file

@ -162,6 +162,7 @@ extern void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags
extern BOOL macdrv_RegisterHotKey(HWND hwnd, UINT mod_flags, UINT vkey) DECLSPEC_HIDDEN; extern BOOL macdrv_RegisterHotKey(HWND hwnd, UINT mod_flags, UINT vkey) DECLSPEC_HIDDEN;
extern void macdrv_UnregisterHotKey(HWND hwnd, UINT modifiers, UINT vkey) DECLSPEC_HIDDEN; extern void macdrv_UnregisterHotKey(HWND hwnd, UINT modifiers, UINT vkey) DECLSPEC_HIDDEN;
extern SHORT macdrv_VkKeyScanEx(WCHAR wChar, HKL hkl) DECLSPEC_HIDDEN; extern SHORT macdrv_VkKeyScanEx(WCHAR wChar, HKL hkl) DECLSPEC_HIDDEN;
extern UINT macdrv_ImeProcessKey(HIMC himc, UINT wparam, UINT lparam, const BYTE *state) DECLSPEC_HIDDEN;
extern UINT macdrv_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl) DECLSPEC_HIDDEN; extern UINT macdrv_MapVirtualKeyEx(UINT wCode, UINT wMapType, HKL hkl) DECLSPEC_HIDDEN;
extern INT macdrv_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState, extern INT macdrv_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState,
LPWSTR bufW, int bufW_size, UINT flags, HKL hkl) DECLSPEC_HIDDEN; LPWSTR bufW, int bufW_size, UINT flags, HKL hkl) DECLSPEC_HIDDEN;
@ -277,7 +278,6 @@ extern CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP
extern NTSTATUS macdrv_dnd_have_format(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_dnd_have_format(void *arg) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_dnd_release(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_dnd_release(void *arg) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_dnd_retain(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_dnd_retain(void *arg) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_ime_process_text_input(void *arg) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_ime_get_text_input(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_ime_get_text_input(void *arg) DECLSPEC_HIDDEN;
extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN;

View file

@ -607,12 +607,6 @@ NTSTATUS macdrv_client_func(enum macdrv_client_funcs id, const void *params, ULO
} }
static NTSTATUS macdrv_ime_using_input_method(void *arg)
{
return macdrv_using_input_method();
}
static NTSTATUS macdrv_quit_result(void *arg) static NTSTATUS macdrv_quit_result(void *arg)
{ {
struct quit_result_params *params = arg; struct quit_result_params *params = arg;
@ -628,9 +622,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
macdrv_dnd_have_format, macdrv_dnd_have_format,
macdrv_dnd_release, macdrv_dnd_release,
macdrv_dnd_retain, macdrv_dnd_retain,
macdrv_ime_process_text_input,
macdrv_ime_get_text_input, macdrv_ime_get_text_input,
macdrv_ime_using_input_method,
macdrv_init, macdrv_init,
macdrv_notify_icon, macdrv_notify_icon,
macdrv_quit_result, macdrv_quit_result,
@ -658,26 +650,6 @@ static NTSTATUS wow64_dnd_get_data(void *arg)
return macdrv_dnd_get_data(&params); return macdrv_dnd_get_data(&params);
} }
static NTSTATUS wow64_ime_process_text_input(void *arg)
{
struct
{
UINT himc;
UINT vkey;
UINT scan;
UINT repeat;
ULONG key_state;
} *params32 = arg;
struct process_text_input_params params;
params.himc = params32->himc;
params.vkey = params32->vkey;
params.scan = params32->scan;
params.repeat = params32->repeat;
params.key_state = UlongToPtr(params32->key_state);
return macdrv_ime_process_text_input(&params);
}
static NTSTATUS wow64_init(void *arg) static NTSTATUS wow64_init(void *arg)
{ {
struct struct
@ -752,9 +724,7 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
macdrv_dnd_have_format, macdrv_dnd_have_format,
macdrv_dnd_release, macdrv_dnd_release,
macdrv_dnd_retain, macdrv_dnd_retain,
wow64_ime_process_text_input,
macdrv_ime_get_text_input, macdrv_ime_get_text_input,
macdrv_ime_using_input_method,
wow64_init, wow64_init,
wow64_notify_icon, wow64_notify_icon,
macdrv_quit_result, macdrv_quit_result,

View file

@ -26,9 +26,7 @@
unix_dnd_have_format, unix_dnd_have_format,
unix_dnd_release, unix_dnd_release,
unix_dnd_retain, unix_dnd_retain,
unix_ime_process_text_input,
unix_ime_get_text_input, unix_ime_get_text_input,
unix_ime_using_input_method,
unix_init, unix_init,
unix_notify_icon, unix_notify_icon,
unix_quit_result, unix_quit_result,
@ -60,16 +58,6 @@
UINT format; UINT format;
}; };
/* macdrv_ime_process_text_input params */
struct process_text_input_params
{
UINT himc;
UINT vkey;
UINT scan;
UINT repeat;
const BYTE *key_state;
};
/* macdrv_init params */ /* macdrv_init params */
struct localized_string struct localized_string
{ {

View file

@ -2,6 +2,5 @@
@ cdecl wine_notify_icon(long ptr) @ cdecl wine_notify_icon(long ptr)
# IME # IME
@ stdcall ImeProcessKey(long long long ptr)
@ stdcall ImeSelect(long long) @ stdcall ImeSelect(long long)
@ stdcall ImeToAsciiEx(long long ptr ptr long long) @ stdcall ImeToAsciiEx(long long ptr ptr long long)