3832 COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
3833 ImmSetCompositionWindow(hIMC, &cf);
3834 ImmReleaseContext(hwnd, hIMC);
3835 }
3836
3837 void AwtComponent::OpenCandidateWindow(int x, int y)
3838 {
3839 UINT bits = 1;
3840 POINT p = {0, 0}; // upper left corner of the client area
3841 HWND hWnd = GetHWnd();
3842 HWND hTop = GetTopLevelParentForWindow(hWnd);
3843 ::ClientToScreen(hTop, &p);
3844 if (!m_bitsCandType) {
3845 SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
3846 return;
3847 }
3848 for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
3849 if ( m_bitsCandType & bits )
3850 SetCandidateWindow(iCandType, x - p.x, y - p.y);
3851 }
3852 if (m_bitsCandType != 0) {
3853 // REMIND: is there any chance GetProxyFocusOwner() returns NULL here?
3854 ::DefWindowProc(ImmGetHWnd(),
3855 WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType);
3856 }
3857 }
3858
3859 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
3860 {
3861 HWND hwnd = ImmGetHWnd();
3862 HIMC hIMC = ImmGetContext(hwnd);
3863 CANDIDATEFORM cf;
3864 cf.dwIndex = iCandType;
3865 cf.dwStyle = CFS_POINT;
3866 cf.ptCurrentPos.x = x;
3867 cf.ptCurrentPos.y = y;
3868
3869 ImmSetCandidateWindow(hIMC, &cf);
3870 ImmReleaseContext(hwnd, hIMC);
3871 }
3872
3873 MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
3874 {
3875 // If the Windows input context is disabled, do not let Windows
3876 // display any UIs.
3877 HWND hwnd = ImmGetHWnd();
3878 HIMC hIMC = ImmGetContext(hwnd);
3879 if (hIMC == NULL) {
3880 *lplParam = 0;
3881 return mrDoDefault;
3882 }
3883 ImmReleaseContext(hwnd, hIMC);
3884
3885 if (fSet) {
3886 LPARAM lParam = *lplParam;
3887 if (!m_useNativeCompWindow) {
3888 // stop to draw native composing window.
3889 *lplParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
3890 }
3891 }
3892 return mrDoDefault;
3893 }
3894
3895 MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType)
3896 {
3897 if (!m_useNativeCompWindow) {
3898 if (subMsg == IMN_OPENCANDIDATE) {
3899 m_bitsCandType = bitsCandType;
3900 InquireCandidatePosition();
3901 } else if (subMsg == IMN_OPENSTATUSWINDOW ||
3902 subMsg == WM_IME_STARTCOMPOSITION) {
3903 m_bitsCandType = 0;
3904 InquireCandidatePosition();
3905 } else if (subMsg == IMN_SETCANDIDATEPOS) {
3906 InquireCandidatePosition();
3907 }
3908 return mrConsume;
3909 }
3910 return mrDoDefault;
3911 }
3912
3913 MsgRouting AwtComponent::WmImeStartComposition()
3914 {
3915 if (m_useNativeCompWindow) {
3916 RECT rc;
3917 ::GetClientRect(GetHWnd(), &rc);
3918 SetCompositionWindow(rc);
3919 return mrDoDefault;
3920 } else
3921 return mrConsume;
3922 }
3923
3924 MsgRouting AwtComponent::WmImeEndComposition()
3925 {
3926 if (m_useNativeCompWindow) return mrDoDefault;
3927
3928 SendInputMethodEvent(
|
3832 COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
3833 ImmSetCompositionWindow(hIMC, &cf);
3834 ImmReleaseContext(hwnd, hIMC);
3835 }
3836
3837 void AwtComponent::OpenCandidateWindow(int x, int y)
3838 {
3839 UINT bits = 1;
3840 POINT p = {0, 0}; // upper left corner of the client area
3841 HWND hWnd = GetHWnd();
3842 HWND hTop = GetTopLevelParentForWindow(hWnd);
3843 ::ClientToScreen(hTop, &p);
3844 if (!m_bitsCandType) {
3845 SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
3846 return;
3847 }
3848 for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
3849 if ( m_bitsCandType & bits )
3850 SetCandidateWindow(iCandType, x - p.x, y - p.y);
3851 }
3852 }
3853
3854 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
3855 {
3856 HWND hwnd = ImmGetHWnd();
3857 HIMC hIMC = ImmGetContext(hwnd);
3858 if (hIMC) {
3859 CANDIDATEFORM cf;
3860 cf.dwStyle = CFS_POINT;
3861 ImmGetCandidateWindow(hIMC, 0, &cf);
3862 if (x != cf.ptCurrentPos.x || y != cf.ptCurrentPos.y) {
3863 cf.dwIndex = iCandType;
3864 cf.dwStyle = CFS_POINT;
3865 cf.ptCurrentPos.x = x;
3866 cf.ptCurrentPos.y = y;
3867 cf.rcArea.left = cf.rcArea.top = cf.rcArea.right = cf.rcArea.bottom = 0;
3868 ImmSetCandidateWindow(hIMC, &cf);
3869 }
3870 COMPOSITIONFORM cfr;
3871 cfr.dwStyle = CFS_POINT;
3872 ImmGetCompositionWindow(hIMC, &cfr);
3873 if (x != cfr.ptCurrentPos.x || y != cfr.ptCurrentPos.y) {
3874 cfr.dwStyle = CFS_POINT;
3875 cfr.ptCurrentPos.x = x;
3876 cfr.ptCurrentPos.y = y;
3877 cf.rcArea.left = cf.rcArea.top = cf.rcArea.right = cf.rcArea.bottom = 0;
3878 ImmSetCompositionWindow(hIMC, &cfr);
3879 }
3880 ImmReleaseContext(hwnd, hIMC);
3881 }
3882 }
3883
3884 MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
3885 {
3886 // If the Windows input context is disabled, do not let Windows
3887 // display any UIs.
3888 HWND hwnd = ImmGetHWnd();
3889 HIMC hIMC = ImmGetContext(hwnd);
3890 if (hIMC == NULL) {
3891 *lplParam = 0;
3892 return mrDoDefault;
3893 }
3894 ImmReleaseContext(hwnd, hIMC);
3895
3896 if (fSet) {
3897 LPARAM lParam = *lplParam;
3898 if (!m_useNativeCompWindow) {
3899 // stop to draw native composing window.
3900 *lplParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
3901 }
3902 }
3903 return mrDoDefault;
3904 }
3905
3906 MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType)
3907 {
3908 if (!m_useNativeCompWindow) {
3909 if (subMsg == IMN_OPENCANDIDATE || subMsg == IMN_CHANGECANDIDATE) {
3910 m_bitsCandType = bitsCandType;
3911 InquireCandidatePosition();
3912 } else if (subMsg == IMN_OPENSTATUSWINDOW ||
3913 subMsg == WM_IME_STARTCOMPOSITION ||
3914 subMsg == IMN_SETCANDIDATEPOS) {
3915 InquireCandidatePosition();
3916 }
3917 }
3918 return mrDoDefault;
3919 }
3920
3921 MsgRouting AwtComponent::WmImeStartComposition()
3922 {
3923 if (m_useNativeCompWindow) {
3924 RECT rc;
3925 ::GetClientRect(GetHWnd(), &rc);
3926 SetCompositionWindow(rc);
3927 return mrDoDefault;
3928 } else
3929 return mrConsume;
3930 }
3931
3932 MsgRouting AwtComponent::WmImeEndComposition()
3933 {
3934 if (m_useNativeCompWindow) return mrDoDefault;
3935
3936 SendInputMethodEvent(
|