Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1985 - 1999, Microsoft Corporation
  3. Module Name:
  4. cmpevcb.cpp
  5. Abstract:
  6. This file implements the CCompartmentEventSinkCallBack Class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #include "private.h"
  12. #include "cmpevcb.h"
  13. #include "cime.h"
  14. #include "immif.h"
  15. #include "korimx.h"
  16. // static
  17. HRESULT
  18. CCompartmentEventSinkCallBack::CompartmentEventSinkCallback(
  19. void* pv,
  20. REFGUID rguid
  21. )
  22. {
  23. DebugMsg(TF_FUNC, "CompartmentEventSinkCallback");
  24. IMTLS *ptls;
  25. HRESULT hr = S_OK;
  26. LANGID langid;
  27. BOOL fOpenChanged;
  28. CCompartmentEventSinkCallBack* _this = (CCompartmentEventSinkCallBack*)pv;
  29. ASSERT(_this);
  30. ImmIfIME* _ImmIfIME = _this->m_pImmIfIME;
  31. ASSERT(_ImmIfIME);
  32. fOpenChanged = _ImmIfIME->IsOpenStatusChanging();
  33. if ((ptls = IMTLS_GetOrAlloc()) == NULL)
  34. return E_FAIL;
  35. ptls->pAImeProfile->GetLangId(&langid);
  36. if ((PRIMARYLANGID(langid) != LANG_KOREAN) && fOpenChanged)
  37. return S_OK;
  38. IMCLock imc(ptls->hIMC);
  39. if (FAILED(hr=imc.GetResult()))
  40. return hr;
  41. if (!fOpenChanged)
  42. {
  43. DWORD fOnOff;
  44. hr = GetCompartmentDWORD(ptls->tim,
  45. GUID_COMPARTMENT_KEYBOARD_OPENCLOSE,
  46. &fOnOff, FALSE);
  47. if (SUCCEEDED(hr)) {
  48. if (!_ImmIfIME->IsRealIme())
  49. {
  50. imc->fOpen = (BOOL) ! ! fOnOff;
  51. SendMessage(imc->hWnd, WM_IME_NOTIFY, IMN_SETOPENSTATUS, 0L);
  52. }
  53. //
  54. // Direct input mode support for Satori.
  55. // When user switch to direct input mode with composition string,
  56. // we want finalize composition string.
  57. //
  58. if (! imc->fOpen) {
  59. CAImeContext* _pAImeContext = imc->m_pAImeContext;
  60. ASSERT(_pAImeContext != NULL);
  61. if (_pAImeContext == NULL)
  62. return E_FAIL;
  63. if (_pAImeContext->m_fStartComposition) {
  64. //
  65. // finalize the composition before letting the world see this keystroke
  66. //
  67. _ImmIfIME->_CompComplete(imc);
  68. }
  69. }
  70. }
  71. }
  72. if ((PRIMARYLANGID(langid) == LANG_KOREAN))
  73. {
  74. DWORD fdwConvMode;
  75. hr = GetCompartmentDWORD(ptls->tim,
  76. GUID_COMPARTMENT_KORIMX_CONVMODE,
  77. &fdwConvMode,
  78. FALSE);
  79. if (SUCCEEDED(hr))
  80. {
  81. switch (fdwConvMode)
  82. {
  83. // Korean TIP ALPHANUMERIC Mode
  84. case KORIMX_ALPHANUMERIC_MODE:
  85. imc->fdwConversion = IME_CMODE_ALPHANUMERIC;
  86. break;
  87. // Korean TIP HANGUL Mode
  88. case KORIMX_HANGUL_MODE:
  89. imc->fdwConversion = IME_CMODE_HANGUL;
  90. break;
  91. // Korean TIP JUNJA Mode
  92. case KORIMX_JUNJA_MODE:
  93. imc->fdwConversion = IME_CMODE_FULLSHAPE;
  94. break;
  95. // Korean TIP HANGUL/JUNJA Mode
  96. case KORIMX_HANGULJUNJA_MODE:
  97. imc->fdwConversion = IME_CMODE_HANGUL | IME_CMODE_FULLSHAPE;
  98. break;
  99. }
  100. }
  101. }
  102. return hr;
  103. }
  104. CCompartmentEventSinkCallBack::CCompartmentEventSinkCallBack(
  105. ImmIfIME* pImmIfIME) : m_pImmIfIME(pImmIfIME),
  106. CCompartmentEventSink(CompartmentEventSinkCallback, NULL)
  107. {
  108. m_pImmIfIME->AddRef();
  109. };
  110. CCompartmentEventSinkCallBack::~CCompartmentEventSinkCallBack(
  111. )
  112. {
  113. m_pImmIfIME->Release();
  114. }