imm32: Move default IMM window proc implementation from user32.

This commit is contained in:
Jacek Caban 2022-07-08 00:43:21 +02:00 committed by Alexandre Julliard
parent f6ddd4ca86
commit 7babf75789
5 changed files with 126 additions and 114 deletions

View file

@ -43,6 +43,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(imm);
#define IMM_INIT_MAGIC 0x19650412
BOOL WINAPI User32InitializeImmEntryTable(DWORD);
/* MSIME messages */
static UINT WM_MSIME_SERVICE;
static UINT WM_MSIME_RECONVERTOPTIONS;
static UINT WM_MSIME_MOUSE;
static UINT WM_MSIME_RECONVERTREQUEST;
static UINT WM_MSIME_RECONVERT;
static UINT WM_MSIME_QUERYPOSITION;
static UINT WM_MSIME_DOCUMENTFEED;
typedef struct _tagImmHkl{
struct list entry;
HKL hkl;
@ -534,11 +543,6 @@ static ImmHkl *IMM_GetImmHkl(HKL hkl)
}
#undef LOAD_FUNCPTR
HWND WINAPI __wine_get_ui_window(HKL hkl)
{
ImmHkl *immHkl = IMM_GetImmHkl(hkl);
return immHkl->UIWnd;
}
static void IMM_FreeAllImmHkl(void)
{
@ -3361,3 +3365,106 @@ BOOL WINAPI ImmDisableLegacyIME(void)
FIXME("stub\n");
return TRUE;
}
static HWND get_ui_window(HKL hkl)
{
ImmHkl *immHkl = IMM_GetImmHkl(hkl);
return immHkl->UIWnd;
}
static BOOL is_ime_ui_msg(UINT msg)
{
switch (msg)
{
case WM_IME_STARTCOMPOSITION:
case WM_IME_ENDCOMPOSITION:
case WM_IME_COMPOSITION:
case WM_IME_SETCONTEXT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL:
case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT:
case WM_IME_CHAR:
case WM_IME_REQUEST:
case WM_IME_KEYDOWN:
case WM_IME_KEYUP:
return TRUE;
default:
return msg == WM_MSIME_RECONVERTOPTIONS ||
msg == WM_MSIME_SERVICE ||
msg == WM_MSIME_MOUSE ||
msg == WM_MSIME_RECONVERTREQUEST ||
msg == WM_MSIME_RECONVERT ||
msg == WM_MSIME_QUERYPOSITION ||
msg == WM_MSIME_DOCUMENTFEED;
}
}
static LRESULT ime_internal_msg( WPARAM wparam, LPARAM lparam)
{
HWND hwnd = (HWND)lparam;
HIMC himc;
switch (wparam)
{
case IME_INTERNAL_ACTIVATE:
case IME_INTERNAL_DEACTIVATE:
himc = ImmGetContext(hwnd);
ImmSetActiveContext(hwnd, himc, wparam == IME_INTERNAL_ACTIVATE);
ImmReleaseContext(hwnd, himc);
break;
default:
FIXME("wparam = %Ix\n", wparam);
break;
}
return 0;
}
static void init_messages(void)
{
static BOOL initialized;
if (initialized) return;
WM_MSIME_SERVICE = RegisterWindowMessageW(L"MSIMEService");
WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageW(L"MSIMEReconvertOptions");
WM_MSIME_MOUSE = RegisterWindowMessageW(L"MSIMEMouseOperation");
WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageW(L"MSIMEReconvertRequest");
WM_MSIME_RECONVERT = RegisterWindowMessageW(L"MSIMEReconvert");
WM_MSIME_QUERYPOSITION = RegisterWindowMessageW(L"MSIMEQueryPosition");
WM_MSIME_DOCUMENTFEED = RegisterWindowMessageW(L"MSIMEDocumentFeed");
initialized = TRUE;
}
LRESULT WINAPI __wine_ime_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi)
{
HWND uiwnd;
switch (msg)
{
case WM_CREATE:
init_messages();
return TRUE;
case WM_IME_INTERNAL:
return ime_internal_msg(wparam, lparam);
}
if (is_ime_ui_msg(msg))
{
if ((uiwnd = get_ui_window(NtUserGetKeyboardLayout(0))))
{
if (ansi)
return SendMessageA(uiwnd, msg, wparam, lparam);
else
return SendMessageW(uiwnd, msg, wparam, lparam);
}
return FALSE;
}
if (ansi)
return DefWindowProcA(hwnd, msg, wparam, lparam);
else
return DefWindowProcW(hwnd, msg, wparam, lparam);
}

View file

@ -114,6 +114,6 @@
################################################################
# Wine internal extensions
@ stdcall __wine_get_ui_window(ptr)
@ stdcall __wine_ime_wnd_proc(long long long long long)
@ stdcall __wine_register_window(long)
@ stdcall __wine_unregister_window(long)

View file

@ -38,19 +38,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(win);
BOOL WINAPI ImmSetActiveContext(HWND, HIMC, BOOL);
#define IMM_INIT_MAGIC 0x19650412
static HWND (WINAPI *imm_get_ui_window)(HKL);
static LRESULT (WINAPI *imm_ime_wnd_proc)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi);
BOOL (WINAPI *imm_register_window)(HWND) = NULL;
void (WINAPI *imm_unregister_window)(HWND) = NULL;
/* MSIME messages */
static UINT WM_MSIME_SERVICE;
static UINT WM_MSIME_RECONVERTOPTIONS;
static UINT WM_MSIME_MOUSE;
static UINT WM_MSIME_RECONVERTREQUEST;
static UINT WM_MSIME_RECONVERT;
static UINT WM_MSIME_QUERYPOSITION;
static UINT WM_MSIME_DOCUMENTFEED;
/* USER signal proc flags and codes */
/* See UserSignalProc for comments */
#define USIG_FLAGS_WIN32 0x0001
@ -332,22 +323,14 @@ BOOL WINAPI User32InitializeImmEntryTable(DWORD magic)
if (!imm32 || magic != IMM_INIT_MAGIC)
return FALSE;
if (imm_get_ui_window)
if (imm_ime_wnd_proc)
return TRUE;
WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions");
WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
/* this part is not compatible with native imm32.dll */
imm_get_ui_window = (void*)GetProcAddress(imm32, "__wine_get_ui_window");
imm_ime_wnd_proc = (void*)GetProcAddress(imm32, "__wine_ime_wnd_proc");
imm_register_window = (void*)GetProcAddress(imm32, "__wine_register_window");
imm_unregister_window = (void*)GetProcAddress(imm32, "__wine_unregister_window");
if (!imm_get_ui_window)
if (!imm_ime_wnd_proc)
FIXME("native imm32.dll not supported\n");
return TRUE;
}
@ -561,93 +544,14 @@ const struct builtin_class_descr IME_builtin_class =
0 /* brush */
};
static BOOL is_ime_ui_msg( UINT msg )
{
switch(msg) {
case WM_IME_STARTCOMPOSITION:
case WM_IME_ENDCOMPOSITION:
case WM_IME_COMPOSITION:
case WM_IME_SETCONTEXT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL:
case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT:
case WM_IME_CHAR:
case WM_IME_REQUEST:
case WM_IME_KEYDOWN:
case WM_IME_KEYUP:
return TRUE;
default:
if ((msg == WM_MSIME_RECONVERTOPTIONS) ||
(msg == WM_MSIME_SERVICE) ||
(msg == WM_MSIME_MOUSE) ||
(msg == WM_MSIME_RECONVERTREQUEST) ||
(msg == WM_MSIME_RECONVERT) ||
(msg == WM_MSIME_QUERYPOSITION) ||
(msg == WM_MSIME_DOCUMENTFEED))
return TRUE;
return FALSE;
}
}
static LRESULT ime_internal_msg( WPARAM wParam, LPARAM lParam)
{
HWND hwnd = (HWND)lParam;
HIMC himc;
switch(wParam)
{
case IME_INTERNAL_ACTIVATE:
case IME_INTERNAL_DEACTIVATE:
himc = ImmGetContext(hwnd);
ImmSetActiveContext(hwnd, himc, wParam == IME_INTERNAL_ACTIVATE);
ImmReleaseContext(hwnd, himc);
break;
default:
FIXME("wParam = %Ix\n", wParam);
break;
}
return 0;
}
LRESULT WINAPI ImeWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
HWND uiwnd;
if (msg==WM_CREATE)
return TRUE;
if (msg==WM_IME_INTERNAL)
return ime_internal_msg(wParam, lParam);
if (imm_get_ui_window && is_ime_ui_msg(msg))
{
if ((uiwnd = imm_get_ui_window( NtUserGetKeyboardLayout(0) )))
return SendMessageA(uiwnd, msg, wParam, lParam);
return FALSE;
}
return DefWindowProcA(hwnd, msg, wParam, lParam);
if (!imm_ime_wnd_proc) return DefWindowProcA(hwnd, msg, wParam, lParam);
return imm_ime_wnd_proc( hwnd, msg, wParam, lParam, TRUE );
}
LRESULT WINAPI ImeWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
HWND uiwnd;
if (msg==WM_CREATE)
return TRUE;
if (msg==WM_IME_INTERNAL)
return ime_internal_msg(wParam, lParam);
if (imm_get_ui_window && is_ime_ui_msg(msg))
{
if ((uiwnd = imm_get_ui_window( NtUserGetKeyboardLayout(0) )))
return SendMessageW(uiwnd, msg, wParam, lParam);
return FALSE;
}
return DefWindowProcW(hwnd, msg, wParam, lParam);
if (!imm_ime_wnd_proc) return DefWindowProcW(hwnd, msg, wParam, lParam);
return imm_ime_wnd_proc( hwnd, msg, wParam, lParam, FALSE );
}

View file

@ -134,10 +134,6 @@ static inline BOOL is_broadcast( HWND hwnd )
return hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST;
}
#define WM_IME_INTERNAL 0x287
#define IME_INTERNAL_ACTIVATE 0x17
#define IME_INTERNAL_DEACTIVATE 0x18
/* this is the structure stored in TEB->Win32ClientInfo */
/* no attempt is made to keep the layout compatible with the Windows one */
struct user_thread_info

View file

@ -385,6 +385,11 @@ enum wine_internal_message
WM_WINE_LAST_DRIVER_MSG = 0x80001fff
};
/* internal IME message */
#define WM_IME_INTERNAL 0x287
#define IME_INTERNAL_ACTIVATE 0x17
#define IME_INTERNAL_DEACTIVATE 0x18
/* the various structures that can be sent in messages, in platform-independent layout */
struct packed_CREATESTRUCTW
{