imm32: Do not let ImmDestroyContext destroy any default contexts.
This commit is contained in:
parent
e28fc1177a
commit
f3967902c5
|
@ -77,6 +77,7 @@ typedef struct tagInputContextData
|
||||||
|
|
||||||
ImmHkl *immKbd;
|
ImmHkl *immKbd;
|
||||||
UINT lastVK;
|
UINT lastVK;
|
||||||
|
BOOL threadDefault;
|
||||||
DWORD magic;
|
DWORD magic;
|
||||||
} InputContextData;
|
} InputContextData;
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ static CRITICAL_SECTION threaddata_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||||
#define is_kbd_ime_unicode(p) (p->imeInfo.fdwProperty & IME_PROP_UNICODE)
|
#define is_kbd_ime_unicode(p) (p->imeInfo.fdwProperty & IME_PROP_UNICODE)
|
||||||
|
|
||||||
static BOOL IMM_DestroyContext(HIMC hIMC);
|
static BOOL IMM_DestroyContext(HIMC hIMC);
|
||||||
|
static InputContextData* get_imc_data(HIMC hIMC);
|
||||||
|
|
||||||
static inline WCHAR *strdupAtoW( const char *str )
|
static inline WCHAR *strdupAtoW( const char *str )
|
||||||
{
|
{
|
||||||
|
@ -244,6 +246,16 @@ static IMMThreadData* IMM_GetThreadData(DWORD id)
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL IMM_IsDefaultContext(HIMC imc)
|
||||||
|
{
|
||||||
|
InputContextData *data = get_imc_data(imc);
|
||||||
|
|
||||||
|
if (!data)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return data->threadDefault;
|
||||||
|
}
|
||||||
|
|
||||||
static void IMM_FreeThreadData(void)
|
static void IMM_FreeThreadData(void)
|
||||||
{
|
{
|
||||||
IMMThreadData *data;
|
IMMThreadData *data;
|
||||||
|
@ -478,6 +490,8 @@ static IMMThreadData* IMM_GetInitializedThreadData(void)
|
||||||
HIMC defaultContext;
|
HIMC defaultContext;
|
||||||
LeaveCriticalSection(&threaddata_cs);
|
LeaveCriticalSection(&threaddata_cs);
|
||||||
defaultContext = ImmCreateContext();
|
defaultContext = ImmCreateContext();
|
||||||
|
if (defaultContext)
|
||||||
|
((InputContextData*)defaultContext)->threadDefault = TRUE;
|
||||||
thread_data = IMM_GetThreadData(0);
|
thread_data = IMM_GetThreadData(0);
|
||||||
if (!thread_data)
|
if (!thread_data)
|
||||||
{
|
{
|
||||||
|
@ -780,11 +794,7 @@ static BOOL IMM_DestroyContext(HIMC hIMC)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI ImmDestroyContext(HIMC hIMC)
|
BOOL WINAPI ImmDestroyContext(HIMC hIMC)
|
||||||
{
|
{
|
||||||
IMMThreadData* thread_data = IMM_GetThreadData(0);
|
if (!IMM_IsDefaultContext(hIMC))
|
||||||
HIMC defaultContext = thread_data->defaultContext;
|
|
||||||
LeaveCriticalSection(&threaddata_cs);
|
|
||||||
|
|
||||||
if (hIMC != defaultContext)
|
|
||||||
return IMM_DestroyContext(hIMC);
|
return IMM_DestroyContext(hIMC);
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue