cleanup: ghost Win32 IME

Took out lots of redundant function calls (getters). Also wrapped more
code in WITH_INPUT_IME guards.
This commit is contained in:
Mike Erwin 2015-02-26 18:40:09 -05:00
parent 87dc01e690
commit 7aa91f5fbc
5 changed files with 29 additions and 16 deletions

@ -30,6 +30,7 @@
* \ingroup GHOST
*/
#ifdef WITH_INPUT_IME
#include "GHOST_C-api.h"
#include "GHOST_ImeWin32.h"
@ -515,3 +516,5 @@ void GHOST_ImeWin32::UpdateInfo(HWND window_handle)
eventImeData.target_end = -1;
}
}
#endif // WITH_INPUT_IME

@ -32,6 +32,9 @@
#ifndef __GHOST_IME_H__
#define __GHOST_IME_H__
#ifdef WITH_INPUT_IME
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <string>
@ -398,4 +401,5 @@ private:
bool is_first, is_enable;
};
#endif * __GHOST_IME_H__
#endif // WITH_INPUT_IME
#endif // __GHOST_IME_H__

@ -970,47 +970,51 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
////////////////////////////////////////////////////////////////////////
case WM_IME_SETCONTEXT:
{
window->getImeInput()->SetInputLanguage();
window->getImeInput()->CreateImeWindow(window->getHWND());
window->getImeInput()->CleanupComposition(window->getHWND());
window->getImeInput()->CheckFirst(window->getHWND());
GHOST_ImeWin32 *ime = window->getImeInput();
ime->SetInputLanguage();
ime->CreateImeWindow(hwnd);
ime->CleanupComposition(hwnd);
ime->CheckFirst(hwnd);
break;
}
case WM_IME_STARTCOMPOSITION:
{
GHOST_ImeWin32 *ime = window->getImeInput();
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());
ime->CreateImeWindow(hwnd);
ime->ResetComposition(hwnd);
event = processImeEvent(
GHOST_kEventImeCompositionStart,
window,
&window->getImeInput()->eventImeData);
&ime->eventImeData);
break;
}
case WM_IME_COMPOSITION:
{
GHOST_ImeWin32 *ime = window->getImeInput();
eventHandled = true;
window->getImeInput()->UpdateImeWindow(window->getHWND());
window->getImeInput()->UpdateInfo(window->getHWND());
ime->UpdateImeWindow(hwnd);
ime->UpdateInfo(hwnd);
event = processImeEvent(
GHOST_kEventImeComposition,
window,
&window->getImeInput()->eventImeData);
&ime->eventImeData);
break;
}
case WM_IME_ENDCOMPOSITION:
{
GHOST_ImeWin32 *ime = window->getImeInput();
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());
ime->ResetComposition(hwnd);
ime->DestroyImeWindow(hwnd);
event = processImeEvent(
GHOST_kEventImeCompositionEnd,
window,
&window->getImeInput()->eventImeData);
&ime->eventImeData);
break;
}
#endif /* WITH_INPUT_IME */

@ -305,6 +305,7 @@ protected:
*/
static GHOST_Event *processWindowEvent(GHOST_TEventType type, GHOST_IWindow *window);
#ifdef WITH_INPUT_IME
/**
* Creates a IME event.
* \param type The type of event to create.
@ -313,6 +314,7 @@ protected:
* \return The event created.
*/
static GHOST_Event *processImeEvent(GHOST_TEventType type, GHOST_IWindow *window, GHOST_TEventImeData *data);
#endif // WITH_INPUT_IME
/**
* Handles minimum window size.

@ -1060,12 +1060,12 @@ GHOST_TSuccess GHOST_WindowWin32::endProgressBar()
#ifdef WITH_INPUT_IME
void GHOST_WindowWin32::beginIME(GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TInt32 w, GHOST_TInt32 h, int completed)
{
this->getImeInput()->BeginIME(this->getHWND(), GHOST_Rect(x, y - h , x, y), (bool)completed);
m_imeImput.BeginIME(m_hWnd, GHOST_Rect(x, y - h, x, y), (bool)completed);
}
void GHOST_WindowWin32::endIME()
{
this->getImeInput()->EndIME(this->getHWND());
m_imeImput.EndIME(m_hWnd);
}
#endif /* WITH_INPUT_IME */