Akihiro Sagawa : imm32: Implement ImmDisableIME.
Alexandre Julliard
julliard at winehq.org
Thu Jul 28 09:38:55 CDT 2016
Module: wine
Branch: master
Commit: ba2e025b94fa3705d439803a545129c32e8818af
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ba2e025b94fa3705d439803a545129c32e8818af
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Thu Jul 28 21:33:33 2016 +0900
imm32: Implement ImmDisableIME.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/imm32/imm.c | 36 ++++++++++++++++++++++++++++++------
dlls/imm32/tests/imm32.c | 2 +-
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 3c805dc..d9c9782 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -95,6 +95,7 @@ typedef struct _tagIMMThreadData {
DWORD threadID;
HIMC defaultContext;
HWND hwndDefault;
+ BOOL disableIME;
} IMMThreadData;
static struct list ImmHklList = LIST_INIT(ImmHklList);
@@ -116,6 +117,7 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
0, 0, { (DWORD_PTR)(__FILE__ ": threaddata_cs") }
};
static CRITICAL_SECTION threaddata_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
+static BOOL disable_ime;
#define is_himc_ime_unicode(p) (p->immKbd->imeInfo.fdwProperty & IME_PROP_UNICODE)
#define is_kbd_ime_unicode(p) (p->imeInfo.fdwProperty & IME_PROP_UNICODE)
@@ -225,17 +227,26 @@ static DWORD convert_candidatelist_AtoW(
return ret;
}
-static IMMThreadData *IMM_GetThreadData(HWND hwnd)
+static IMMThreadData *IMM_GetThreadData(HWND hwnd, DWORD thread)
{
IMMThreadData *data;
- DWORD process, thread;
+ DWORD process;
if (hwnd)
{
if (!(thread = GetWindowThreadProcessId(hwnd, &process))) return NULL;
if (process != GetCurrentProcessId()) return NULL;
}
- else thread = GetCurrentThreadId();
+ else if (thread)
+ {
+ HANDLE h = OpenThread(THREAD_QUERY_INFORMATION, FALSE, thread);
+ if (!h) return NULL;
+ process = GetProcessIdOfThread(h);
+ CloseHandle(h);
+ if (process != GetCurrentProcessId()) return NULL;
+ }
+ else
+ thread = GetCurrentThreadId();
EnterCriticalSection(&threaddata_cs);
LIST_FOR_EACH_ENTRY(data, &ImmThreadDataList, IMMThreadData, entry)
@@ -492,7 +503,7 @@ static InputContextData* get_imc_data(HIMC hIMC)
static HIMC get_default_context( HWND hwnd )
{
HIMC ret;
- IMMThreadData* thread_data = IMM_GetThreadData( hwnd );
+ IMMThreadData* thread_data = IMM_GetThreadData( hwnd, 0 );
if (!thread_data) return 0;
@@ -822,7 +833,14 @@ BOOL WINAPI ImmDestroyContext(HIMC hIMC)
*/
BOOL WINAPI ImmDisableIME(DWORD idThread)
{
- FIXME("(%d): stub\n", idThread);
+ if (idThread == (DWORD)-1)
+ disable_ime = TRUE;
+ else {
+ IMMThreadData *thread_data = IMM_GetThreadData(NULL, idThread);
+ if (!thread_data) return FALSE;
+ thread_data->disableIME = TRUE;
+ LeaveCriticalSection(&threaddata_cs);
+ }
return TRUE;
}
@@ -1606,11 +1624,17 @@ BOOL WINAPI ImmGetConversionStatus(
HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
{
HWND ret, new = NULL;
- IMMThreadData* thread_data = IMM_GetThreadData(hWnd);
+ IMMThreadData* thread_data = IMM_GetThreadData(hWnd, 0);
if (!thread_data)
return NULL;
if (thread_data->hwndDefault == NULL && thread_data->threadID == GetCurrentThreadId())
{
+ if (thread_data->disableIME || disable_ime)
+ {
+ TRACE("IME for this thread is disabled\n");
+ LeaveCriticalSection(&threaddata_cs);
+ return NULL;
+ }
/* Do not create the window inside of a critical section */
LeaveCriticalSection(&threaddata_cs);
new = CreateWindowExW( WS_EX_TOOLWINDOW,
diff --git a/dlls/imm32/tests/imm32.c b/dlls/imm32/tests/imm32.c
index e0a0b33..f0f32a7 100644
--- a/dlls/imm32/tests/imm32.c
+++ b/dlls/imm32/tests/imm32.c
@@ -1021,7 +1021,7 @@ static DWORD WINAPI test_default_ime_disabled_cb(void *arg)
CW_USEDEFAULT, CW_USEDEFAULT,
240, 120, NULL, NULL, GetModuleHandleW(NULL), NULL);
default_ime_wnd = ImmGetDefaultIMEWnd(hWnd);
- todo_wine ok(!default_ime_wnd, "Expected no IME windows\n");
+ ok(!default_ime_wnd, "Expected no IME windows\n");
DestroyWindow(hWnd);
return 1;
}
More information about the wine-cvs
mailing list