winex11: Register IME classes only when needed.

This commit is contained in:
Alexandre Julliard 2008-05-01 10:56:34 +02:00
parent 64e64d657c
commit 4a37308389
3 changed files with 42 additions and 35 deletions

View File

@ -123,6 +123,42 @@ static BOOL UnlockRealIMC(HIMC hIMC)
return FALSE;
}
static void IME_RegisterClasses(void)
{
static int done;
WNDCLASSW wndClass;
if (done) return;
done = 1;
ZeroMemory(&wndClass, sizeof(WNDCLASSW));
wndClass.style = CS_GLOBALCLASS | CS_IME | CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = IME_WindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 2 * sizeof(LONG);
wndClass.hInstance = x11drv_module;
wndClass.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
wndClass.hIcon = LoadIconW(NULL, (LPWSTR)IDI_APPLICATION);
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1);
wndClass.lpszMenuName = 0;
wndClass.lpszClassName = UI_CLASS_NAME;
RegisterClassW(&wndClass);
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");
}
void IME_UnregisterClasses(void)
{
UnregisterClassW(UI_CLASS_NAME, x11drv_module);
}
static HIMCC ImeCreateBlankCompStr(void)
{
HIMCC rc;
@ -520,6 +556,7 @@ BOOL WINAPI ImeInquire(LPIMEINFO lpIMEInfo, LPWSTR lpszUIClass,
LPCWSTR lpszOption)
{
TRACE("\n");
IME_RegisterClasses();
lpIMEInfo->dwPrivateDataSize = sizeof (IMEPRIVATE);
lpIMEInfo->fdwProperty = IME_PROP_UNICODE | IME_PROP_AT_CARET;
lpIMEInfo->fdwConversionCaps = IME_CMODE_NATIVE;
@ -907,37 +944,6 @@ DWORD WINAPI ImeGetImeMenuItems(HIMC hIMC, DWORD dwFlags, DWORD dwType,
/* Interfaces to XIM and other parts of winex11drv */
void IME_RegisterClasses(HINSTANCE hImeInst)
{
WNDCLASSW wndClass;
ZeroMemory(&wndClass, sizeof(WNDCLASSW));
wndClass.style = CS_GLOBALCLASS | CS_IME | CS_HREDRAW | CS_VREDRAW;
wndClass.lpfnWndProc = (WNDPROC) IME_WindowProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 2 * sizeof(LONG);
wndClass.hInstance = hImeInst;
wndClass.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
wndClass.hIcon = LoadIconW(NULL, (LPWSTR)IDI_APPLICATION);
wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1);
wndClass.lpszMenuName = 0;
wndClass.lpszClassName = UI_CLASS_NAME;
RegisterClassW(&wndClass);
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");
}
void IME_UnregisterClasses(HINSTANCE hImeInst)
{
UnregisterClassW(UI_CLASS_NAME, hImeInst);
}
void IME_SetOpenStatus(BOOL fOpen)
{
LPINPUTCONTEXT lpIMC;

View File

@ -274,8 +274,7 @@ extern Drawable get_glxdrawable(X11DRV_PDEVICE *physDev);
extern BOOL destroy_glxpixmap(Display *display, XID glxpixmap);
/* IME support */
extern void IME_RegisterClasses(HINSTANCE hImeInst);
extern void IME_UnregisterClasses(HINSTANCE hImeInst);
extern void IME_UnregisterClasses(void);
extern void IME_SetOpenStatus(BOOL fOpen);
extern LRESULT IME_SendMessageToSelectedHWND(UINT msg, WPARAM wParam, LPARAM lParam);
extern INT IME_GetCursorPos();
@ -555,6 +554,7 @@ extern int primary_monitor;
extern int copy_default_colors;
extern int alloc_system_colors;
extern int xrender_error_base;
extern HMODULE x11drv_module;
extern BYTE key_state_table[256];
extern POINT cursor_pos;

View File

@ -93,6 +93,7 @@ int copy_default_colors = 128;
int alloc_system_colors = 256;
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
int xrender_error_base = 0;
HMODULE x11drv_module = 0;
static x11drv_error_callback err_callback; /* current callback for error */
static Display *err_callback_display; /* display callback is set for */
@ -582,6 +583,7 @@ static void process_detach(void)
/* cleanup GDI */
X11DRV_GDI_Finalize();
IME_UnregisterClasses();
DeleteCriticalSection( &X11DRV_CritSection );
TlsFree( thread_data_tls_index );
}
@ -674,15 +676,14 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
switch(reason)
{
case DLL_PROCESS_ATTACH:
x11drv_module = hinst;
ret = process_attach();
IME_RegisterClasses(hinst);
break;
case DLL_THREAD_DETACH:
thread_detach();
break;
case DLL_PROCESS_DETACH:
process_detach();
IME_UnregisterClasses(hinst);
break;
}
return ret;