src/video/win32/SDL_win32keyboard.c
changeset 4893 b2e434e0553b
parent 4763 518d1679d2d0
child 4894 ac19d74e2a47
equal deleted inserted replaced
4892:9e1f6d3fb870 4893:b2e434e0553b
   186 WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
   186 WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
   187 {
   187 {
   188 
   188 
   189 }
   189 }
   190 
   190 
       
   191 #ifdef __GNUC__
       
   192 #undef DEFINE_GUID
       
   193 #define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
       
   194 DEFINE_GUID(IID_ITfInputProcessorProfileActivationSink,        0x71C6E74E,0x0F28,0x11D8,0xA8,0x2A,0x00,0x06,0x5B,0x84,0x43,0x5C);
       
   195 DEFINE_GUID(IID_ITfUIElementSink,                              0xEA1EA136,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
       
   196 DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD,                           0x34745C63,0xB2F0,0x4784,0x8B,0x67,0x5E,0x12,0xC8,0x70,0x1A,0x31);
       
   197 DEFINE_GUID(IID_ITfSource,                                     0x4EA48A35,0x60AE,0x446F,0x8F,0xD6,0xE6,0xA8,0xD8,0x24,0x59,0xF7);
       
   198 DEFINE_GUID(IID_ITfUIElementMgr,                               0xEA1EA135,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
       
   199 DEFINE_GUID(IID_ITfReadingInformationUIElement,                0xEA1EA139,0x19DF,0x11D7,0xA6,0xD2,0x00,0x06,0x5B,0x84,0x43,0x5C);
       
   200 DEFINE_GUID(IID_ITfThreadMgr,                                  0xAA80E801,0x2021,0x11D2,0x93,0xE0,0x00,0x60,0xB0,0x67,0xB8,0x6E);
       
   201 DEFINE_GUID(CLSID_TF_ThreadMgr,                                0x529A9E6B,0x6587,0x4F23,0xAB,0x9E,0x9C,0x7D,0x68,0x3E,0x3C,0x50);
       
   202 DEFINE_GUID(IID_ITfThreadMgrEx,                                0x3E90ADE3,0x7594,0x4CB0,0xBB,0x58,0x69,0x62,0x8F,0x5F,0x45,0x8C);
       
   203 #endif
       
   204 
   191 #define LANG_CHT MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
   205 #define LANG_CHT MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL)
   192 #define LANG_CHS MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
   206 #define LANG_CHS MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED)
   193 
   207 
   194 #define MAKEIMEVERSION(major,minor) ((DWORD) (((BYTE)(major) << 24) | ((BYTE)(minor) << 16) ))
   208 #define MAKEIMEVERSION(major,minor) ((DWORD) (((BYTE)(major) << 24) | ((BYTE)(minor) << 16) ))
   195 #define IMEID_VER(id) ((id) & 0xffff0000)
   209 #define IMEID_VER(id) ((id) & 0xffff0000)
   244         return;
   258         return;
   245 
   259 
   246     videodata->ime_hwnd_main = hwnd;
   260     videodata->ime_hwnd_main = hwnd;
   247     if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) {
   261     if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) {
   248         videodata->ime_com_initialized = SDL_TRUE;
   262         videodata->ime_com_initialized = SDL_TRUE;
   249         CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, &videodata->ime_threadmgr);
   263         CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
   250     }
   264     }
   251     videodata->ime_initialized = SDL_TRUE;
   265     videodata->ime_initialized = SDL_TRUE;
   252     videodata->ime_himm32 = LoadLibraryA("imm32.dll");
   266     videodata->ime_himm32 = LoadLibraryA("imm32.dll");
   253     if (!videodata->ime_himm32) {
   267     if (!videodata->ime_himm32) {
   254         videodata->ime_available = SDL_FALSE;
   268         videodata->ime_available = SDL_FALSE;
   299     if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
   313     if (!videodata->ime_initialized || !videodata->ime_hwnd_current)
   300         return;
   314         return;
   301 
   315 
   302     IME_ClearComposition(videodata);
   316     IME_ClearComposition(videodata);
   303     if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
   317     if (videodata->ime_hwnd_current == videodata->ime_hwnd_main)
   304         ImmAssociateContext(videodata->ime_hwnd_current, NULL);
   318         ImmAssociateContext(videodata->ime_hwnd_current, (HIMC)0);
   305 
   319 
   306     videodata->ime_enabled = SDL_FALSE;
   320     videodata->ime_enabled = SDL_FALSE;
   307     UILess_DisableUIUpdates(videodata);
   321     UILess_DisableUIUpdates(videodata);
   308 }
   322 }
   309 
   323 
   340     DWORD id = 0;
   354     DWORD id = 0;
   341     HIMC himc = 0;
   355     HIMC himc = 0;
   342     WCHAR buffer[16];
   356     WCHAR buffer[16];
   343     WCHAR *s = buffer;
   357     WCHAR *s = buffer;
   344     DWORD len = 0;
   358     DWORD len = 0;
   345     DWORD err = 0;
   359     INT err = 0;
   346     BOOL vertical = FALSE;
   360     BOOL vertical = FALSE;
   347     UINT maxuilen = 0;
   361     UINT maxuilen = 0;
   348     static OSVERSIONINFOA osversion = {0};
   362     static OSVERSIONINFOA osversion = {0};
   349     if (videodata->ime_uiless)
   363     if (videodata->ime_uiless)
   350         return;
   364         return;
   947 UILess_SetupSinks(SDL_VideoData *videodata)
   961 UILess_SetupSinks(SDL_VideoData *videodata)
   948 {
   962 {
   949     TfClientId clientid = 0;
   963     TfClientId clientid = 0;
   950     SDL_bool result = SDL_FALSE;
   964     SDL_bool result = SDL_FALSE;
   951     ITfSource *source = 0;
   965     ITfSource *source = 0;
   952     if (FAILED(CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgrEx, &videodata->ime_threadmgrex)))
   966     if (FAILED(CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgrEx, (LPVOID *)&videodata->ime_threadmgrex)))
   953         return SDL_FALSE;
   967         return SDL_FALSE;
   954 
   968 
   955     if (FAILED(videodata->ime_threadmgrex->lpVtbl->ActivateEx(videodata->ime_threadmgrex, &clientid, TF_TMAE_UIELEMENTENABLEDONLY)))
   969     if (FAILED(videodata->ime_threadmgrex->lpVtbl->ActivateEx(videodata->ime_threadmgrex, &clientid, TF_TMAE_UIELEMENTENABLEDONLY)))
   956         return SDL_FALSE;
   970         return SDL_FALSE;
   957 
   971 
   987 
  1001 
   988 static void
  1002 static void
   989 UILess_ReleaseSinks(SDL_VideoData *videodata)
  1003 UILess_ReleaseSinks(SDL_VideoData *videodata)
   990 {
  1004 {
   991     ITfSource *source = 0;
  1005     ITfSource *source = 0;
   992     if (videodata->ime_threadmgrex && SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, &source))) {
  1006     if (videodata->ime_threadmgrex && SUCCEEDED(videodata->ime_threadmgrex->lpVtbl->QueryInterface(videodata->ime_threadmgrex, &IID_ITfSource, (LPVOID *)&source))) {
   993         source->lpVtbl->UnadviseSink(source, videodata->ime_uielemsinkcookie);
  1007         source->lpVtbl->UnadviseSink(source, videodata->ime_uielemsinkcookie);
   994         source->lpVtbl->UnadviseSink(source, videodata->ime_alpnsinkcookie);
  1008         source->lpVtbl->UnadviseSink(source, videodata->ime_alpnsinkcookie);
   995         SAFE_RELEASE(source);
  1009         SAFE_RELEASE(source);
   996         videodata->ime_threadmgrex->lpVtbl->Deactivate(videodata->ime_threadmgrex);
  1010         videodata->ime_threadmgrex->lpVtbl->Deactivate(videodata->ime_threadmgrex);
   997         SAFE_RELEASE(videodata->ime_threadmgrex);
  1011         SAFE_RELEASE(videodata->ime_threadmgrex);