Input Method Editor (IME) support for text buttons

Original patch by @random (D765) with some minor work done by @campbell
and me.

At this place, I'd like call out a number of people who were involved and
deserve a big "Thank you!":
* At the first place @randon who developed and submitted the patch
* The Blendercn community which helped a lot with testing - espacially
* @yuzukyo, @leon_cheung and @kjym3
* @campbellbarton, @mont29 and @sergey for their help and advises during
* review
* @ton who realized the importance of this early on and asked me for
* reviewing

We are still not finished, as this is only the first part of the
implementaion, but there's more to come!
This commit is contained in:
Severin
2014-12-07 00:58:17 +01:00
parent 06515475b9
commit e81d077c85
36 changed files with 602 additions and 9 deletions

View File

@@ -792,6 +792,15 @@ GHOST_Event *GHOST_SystemWin32::processWindowEvent(GHOST_TEventType type, GHOST_
return new GHOST_Event(system->getMilliSeconds(), type, window);
}
#ifdef WITH_INPUT_IME
GHOST_Event *GHOST_SystemWin32::processImeEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TEventImeData *data)
{
GHOST_System *system = (GHOST_System *)getSystem();
return new GHOST_EventIME(system->getMilliSeconds(), type, window, data);
}
#endif
GHOST_TSuccess GHOST_SystemWin32::pushDragDropEvent(
GHOST_TEventType eventType,
GHOST_TDragnDropTypes draggedObjectType,
@@ -904,6 +913,7 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
LRESULT lResult = 0;
GHOST_SystemWin32 *system = ((GHOST_SystemWin32 *)getSystem());
GHOST_EventManager *eventManager = system->getEventManager();
GHOST_ASSERT(system, "GHOST_SystemWin32::s_wndProc(): system not initialized");
if (hwnd) {
@@ -912,8 +922,13 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
switch (msg) {
// we need to check if new key layout has AltGr
case WM_INPUTLANGCHANGE:
{
system->handleKeyboardChange();
#ifdef WITH_INPUT_IME
window->getImeInput()->SetInputLanguage();
#endif
break;
}
////////////////////////////////////////////////////////////////////////
// Keyboard events, processed
////////////////////////////////////////////////////////////////////////
@@ -949,6 +964,56 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
}
break;
}
#ifdef WITH_INPUT_IME
////////////////////////////////////////////////////////////////////////
// IME events, processed, read more in GHOST_IME.h
////////////////////////////////////////////////////////////////////////
case WM_IME_SETCONTEXT:
{
window->getImeInput()->SetInputLanguage();
window->getImeInput()->CreateImeWindow(window->getHWND());
window->getImeInput()->CleanupComposition(window->getHWND());
window->getImeInput()->CheckFirst(window->getHWND());
break;
}
case WM_IME_STARTCOMPOSITION:
{
eventHandled = true;
/* remove input event before start comp event, avoid redundant input */
eventManager->removeTypeEvents(GHOST_kEventKeyDown, window);
window->getImeInput()->CreateImeWindow(window->getHWND());
window->getImeInput()->ResetComposition(window->getHWND());
event = processImeEvent(
GHOST_kEventImeCompositionStart,
window,
&window->getImeInput()->eventImeData);
break;
}
case WM_IME_COMPOSITION:
{
eventHandled = true;
window->getImeInput()->UpdateImeWindow(window->getHWND());
window->getImeInput()->UpdateInfo(window->getHWND());
event = processImeEvent(
GHOST_kEventImeComposition,
window,
&window->getImeInput()->eventImeData);
break;
}
case WM_IME_ENDCOMPOSITION:
{
eventHandled = true;
/* remove input event after end comp event, avoid redundant input */
eventManager->removeTypeEvents(GHOST_kEventKeyDown, window);
window->getImeInput()->ResetComposition(window->getHWND());
window->getImeInput()->DestroyImeWindow(window->getHWND());
event = processImeEvent(
GHOST_kEventImeCompositionEnd,
window,
&window->getImeInput()->eventImeData);
break;
}
#endif /* WITH_INPUT_IME */
////////////////////////////////////////////////////////////////////////
// Keyboard events, ignored
////////////////////////////////////////////////////////////////////////