Skip to content

Commit

Permalink
2.1.1
Browse files Browse the repository at this point in the history
・入力モード表示ウィンドウを表示するタイミングを IME ON のときだけでなく IME ON/OFF 変更および IME ON/OFF キー押下のときとしました。
 ・変更後は、IME ON/OFF 変更、入力モード変更、IME ON/OFF キー押下、「*無効*」キー押下のいずれかのときとなります。

・バグとまでは言えないもののいまいちな記述を何箇所か修正しました。
  • Loading branch information
nathancorvussolis committed Oct 31, 2015
1 parent 058bb49 commit 6a57883
Show file tree
Hide file tree
Showing 32 changed files with 137 additions and 79 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# CorvusSKK ver. 2.1.0
# CorvusSKK ver. 2.1.1

Windowsで動作するSKK風のIMEです。

Expand Down Expand Up @@ -222,7 +222,7 @@ SKK辞書のダウンロード機能では HTTP, HTTPS が使用可能です。
| 候補一覧が表示無しのとき候補数を表示する | (<現在の候補の番号>/<候補数>) の形式を追加して表示します。 |
| 候補一覧を縦に表示する | 候補一覧で候補を縦に並べて表示します。 |
| 注釈を表示する | <候補><セミコロン><注釈> の形式で注釈を表示します。<br>「候補一覧」の指定で候補一覧に限定されます。 |
| 入力モードを表示する | キャレットまたは辞書登録ウィンドウ付近に入力モードを表示します。<br>タイミングは、IME ON、入力モード変更、「\*無効\*」キー押下のときです。<br>「没入型」の指定でストアアプリやEdgeなどに限定されます。 |
| 入力モードを表示する | キャレットまたは辞書登録ウィンドウ付近に入力モードを表示します。<br>タイミングは、IME ON/OFF 変更、入力モード変更、IME ON/OFF キー押下、「\*無効\*」キー押下のときです。<br>「没入型」の指定でストアアプリやEdgeなどに限定されます。 |
| ▽▼\*マークを表示する | 大切なものは目に見えないようです。 |
| ローマ字を表示する | 仮名文字のローマ字プレフィックスを表示します。 |

Expand Down
6 changes: 3 additions & 3 deletions common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#define TEXTSERVICE_DESC TEXTSERVICE_NAME L"_DEBUG"
#endif

#define TEXTSERVICE_VER L"2.1.0"
#define TEXTSERVICE_VER L"2.1.1"

//for resource
#define RC_AUTHOR "nathancorvussolis"
#define RC_PRODUCT "CorvusSKK"
#define RC_VERSION "2.1.0"
#define RC_VERSION_D 2,1,0,0
#define RC_VERSION "2.1.1"
#define RC_VERSION_D 2,1,1,0

#endif
2 changes: 1 addition & 1 deletion imcrvcnf/imcrvcnf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void CreateProperty()
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOCONTEXTHELP | PSH_USECALLBACK;
psh.hwndParent = NULL;
psh.hInstance = hInst;
psh.pszCaption = TEXTSERVICE_DESC L" (ver. " TEXTSERVICE_VER L")";
psh.pszCaption = TEXTSERVICE_DESC L" ver. " TEXTSERVICE_VER;
psh.nPages = _countof(psp);
psh.nStartPage = 0;
psh.ppsp = psp;
Expand Down
77 changes: 47 additions & 30 deletions imcrvtip/CandidateWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,16 @@ BOOL CCandidateWindow::_Create(HWND hwndParent, CCandidateWindow *pCandidateWind

if(_hwndParent != NULL)
{
WNDCLASSEXW wc;
wc.cbSize = sizeof(wc);
wc.style = CS_IME | CS_VREDRAW | CS_HREDRAW | CS_DROPSHADOW;
wc.lpfnWndProc = DefWindowProcW;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(LONG_PTR);
wc.hInstance = g_hInst;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = CandidateWindowClass;
wc.hIconSm = NULL;
RegisterClassExW(&wc);

_hwnd = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_NOACTIVATE,
CandidateWindowClass, L"", WS_POPUP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
_hwndParent, NULL, g_hInst, NULL);
_hwndParent, NULL, g_hInst, this);

if(_hwnd == NULL)
{
return FALSE;
}

WndProcDef = (WNDPROC)GetWindowLongPtrW(_hwnd, GWLP_WNDPROC);
if(WndProcDef != NULL)
{
SetWindowLongPtrW(_hwnd, GWLP_USERDATA, (LONG_PTR)this);
SetWindowLongPtrW(_hwnd, GWLP_WNDPROC, (LONG_PTR)_WindowPreProc);
SetWindowPos(_hwnd, NULL, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
}

hFont = _pTextService->hFont;

if(_pTextService->cx_drawapi && _pTextService->_pD2DFactory != NULL)
Expand Down Expand Up @@ -112,15 +88,55 @@ BOOL CCandidateWindow::_Create(HWND hwndParent, CCandidateWindow *pCandidateWind
return TRUE;
}

BOOL CCandidateWindow::_InitClass()
{
WNDCLASSEXW wcex;

ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(wcex);
wcex.style = CS_VREDRAW | CS_HREDRAW | CS_DROPSHADOW;
wcex.lpfnWndProc = CCandidateWindow::_WindowPreProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = g_hInst;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursorW(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = CandidateWindowClass;
wcex.hIconSm = NULL;

ATOM atom = RegisterClassExW(&wcex);

return (atom != 0);
}

void CCandidateWindow::_UninitClass()
{
UnregisterClassW(CandidateWindowClass, g_hInst);
}

LRESULT CALLBACK CCandidateWindow::_WindowPreProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT ret = 0;
CCandidateWindow *pWindowProc = (CCandidateWindow*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
if(pWindowProc != NULL)
CCandidateWindow *pCandidateWindow = NULL;

switch(uMsg)
{
case WM_NCCREATE:
pCandidateWindow = (CCandidateWindow *)((LPCREATESTRUCTW)lParam)->lpCreateParams;
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pCandidateWindow);
break;
default:
pCandidateWindow = (CCandidateWindow *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
break;
}

if(pCandidateWindow != NULL)
{
ret = pWindowProc->_WindowProc(hWnd, uMsg, wParam, lParam);
return pCandidateWindow->_WindowProc(hWnd, uMsg, wParam, lParam);
}
return ret;

return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}

LRESULT CALLBACK CCandidateWindow::_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Expand All @@ -137,6 +153,7 @@ LRESULT CALLBACK CCandidateWindow::_WindowProc(HWND hWnd, UINT uMsg, WPARAM wPar
default:
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}

return 0;
}

Expand Down
7 changes: 4 additions & 3 deletions imcrvtip/CandidateWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior
STDMETHODIMP Abort();

BOOL _Create(HWND hwndParent, CCandidateWindow *pCandidateWindowParent, DWORD dwUIElementId, UINT depth, BOOL reg, BOOL comp);
static BOOL _InitClass();
static void _UninitClass();
static LRESULT CALLBACK _WindowPreProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void _Destroy();
Expand All @@ -54,6 +56,8 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior
void _UpdateComp();

private:
LONG _cRef;

void _InitList();
void _UpdateUIElement();
void _NextPage();
Expand Down Expand Up @@ -95,8 +99,6 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior
std::vector< UINT > _PageIndex;
std::vector< std::wstring > _CandStr;

LONG _cRef;

CTextService *_pTextService;
CCandidateList *_pCandidateList;
CCandidateWindow *_pCandidateWindow; //
Expand All @@ -109,7 +111,6 @@ class CCandidateWindow : public ITfCandidateListUIElementBehavior
UINT _depth; //深さ

//候補一覧、辞書登録のウィンドウ
WNDPROC WndProcDef;
std::wstring disptext; //表示文字列
HFONT hFont; //フォント

Expand Down
88 changes: 54 additions & 34 deletions imcrvtip/InputModeWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ HRESULT CInputModeWindow::_UnadviseTextLayoutSink()

BOOL CInputModeWindow::_Create(CTextService *pTextService, ITfContext *pContext, BOOL bCandidateWindow, HWND hWnd)
{
WNDCLASSEXW wc;
HDC hdc;
RECT r;
POINT pt = {0, 0};
Expand Down Expand Up @@ -268,43 +267,16 @@ BOOL CInputModeWindow::_Create(CTextService *pTextService, ITfContext *pContext,
}
}

wc.cbSize = sizeof(wc);
wc.style = CS_IME | CS_VREDRAW | CS_HREDRAW | CS_DROPSHADOW;
wc.lpfnWndProc = DefWindowProcW;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(LONG_PTR);
wc.hInstance = g_hInst;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = InputModeWindowClass;
wc.hIconSm = NULL;
RegisterClassExW(&wc);

_hwnd = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_NOACTIVATE,
InputModeWindowClass, L"", WS_POPUP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
_hwndParent, NULL, g_hInst, NULL);
_hwndParent, NULL, g_hInst, this);

if(_hwnd == NULL)
{
return FALSE;
}

WndProcDef = (WNDPROC)GetWindowLongPtrW(_hwnd, GWLP_WNDPROC);
if(WndProcDef != 0)
{
SetWindowLongPtrW(_hwnd, GWLP_USERDATA, (LONG_PTR)this);
SetWindowLongPtrW(_hwnd, GWLP_WNDPROC, (LONG_PTR)_WindowPreProc);
SetWindowPos(_hwnd, NULL, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
if(!_bCandidateWindow)
{
SetTimer(_hwnd, INPUTMODE_TIMER_ID, INPUTMODE_TIMEOUT_MSEC, NULL);
}
}

hdc = GetDC(NULL);
_size = MulDiv(16, GetDeviceCaps(hdc, LOGPIXELSY), 96);
ReleaseDC(NULL, hdc);
Expand All @@ -323,15 +295,55 @@ BOOL CInputModeWindow::_Create(CTextService *pTextService, ITfContext *pContext,
return TRUE;
}

BOOL CInputModeWindow::_InitClass()
{
WNDCLASSEXW wcex;

ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(wcex);
wcex.style = CS_VREDRAW | CS_HREDRAW | CS_DROPSHADOW;
wcex.lpfnWndProc = CInputModeWindow::_WindowPreProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = g_hInst;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursorW(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = InputModeWindowClass;
wcex.hIconSm = NULL;

ATOM atom = RegisterClassExW(&wcex);

return (atom != 0);
}

void CInputModeWindow::_UninitClass()
{
UnregisterClassW(InputModeWindowClass, g_hInst);
}

LRESULT CALLBACK CInputModeWindow::_WindowPreProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT ret = 0;
CInputModeWindow *pWindowProc = (CInputModeWindow*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
if(pWindowProc != NULL)
CInputModeWindow *pInputModeWindow = NULL;

switch(uMsg)
{
case WM_NCCREATE:
pInputModeWindow = (CInputModeWindow *)((LPCREATESTRUCTW)lParam)->lpCreateParams;
SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)pInputModeWindow);
break;
default:
pInputModeWindow = (CInputModeWindow *)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
break;
}

if(pInputModeWindow != NULL)
{
ret = pWindowProc->_WindowProc(hWnd, uMsg, wParam, lParam);
return pInputModeWindow->_WindowProc(hWnd, uMsg, wParam, lParam);
}
return ret;

return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}

LRESULT CALLBACK CInputModeWindow::_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Expand All @@ -348,6 +360,12 @@ LRESULT CALLBACK CInputModeWindow::_WindowProc(HWND hWnd, UINT uMsg, WPARAM wPar

switch(uMsg)
{
case WM_CREATE:
if(!_bCandidateWindow)
{
SetTimer(hWnd, INPUTMODE_TIMER_ID, INPUTMODE_TIMEOUT_MSEC, NULL);
}
break;
case WM_TIMER:
if(wParam == INPUTMODE_TIMER_ID)
{
Expand Down Expand Up @@ -400,6 +418,7 @@ LRESULT CALLBACK CInputModeWindow::_WindowProc(HWND hWnd, UINT uMsg, WPARAM wPar
default:
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
}

return 0;
}

Expand Down Expand Up @@ -503,6 +522,7 @@ void CTextService::_StartInputModeWindow()
{
switch(inputmode)
{
case im_default:
case im_hiragana:
case im_katakana:
case im_katakana_ank:
Expand Down
3 changes: 2 additions & 1 deletion imcrvtip/InputModeWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class CInputModeWindow : public ITfTextLayoutSink

BOOL _Create(CTextService *pTextService, ITfContext *pContext, BOOL bCandidateWindow, HWND hWnd);
void _Destroy();
static BOOL _InitClass();
static void _UninitClass();
static LRESULT CALLBACK _WindowPreProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

Expand All @@ -45,7 +47,6 @@ class CInputModeWindow : public ITfTextLayoutSink
CTextService *_pTextService;
HWND _hwndParent;
HWND _hwnd;
WNDPROC WndProcDef;
BOOL _bCandidateWindow;

int _size;
Expand Down
8 changes: 8 additions & 0 deletions imcrvtip/KeyEventSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ STDAPI CTextService::OnPreservedKey(ITfContext *pic, REFGUID rguid, BOOL *pfEate

_SetKeyboardOpen(TRUE);
}
else
{
_UpdateLanguageBar();
}

*pfEaten = TRUE;
}
Expand All @@ -208,6 +212,10 @@ STDAPI CTextService::OnPreservedKey(ITfContext *pic, REFGUID rguid, BOOL *pfEate

_SetKeyboardOpen(FALSE);
}
else
{
_UpdateLanguageBar();
}

*pfEaten = TRUE;
}
Expand Down
4 changes: 4 additions & 0 deletions imcrvtip/LanguageBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ void CTextService::_UpdateLanguageBar(BOOL showinputmode)
{
_StartInputModeWindow();
}
else
{
_EndInputModeWindow();
}
}

void CTextService::_GetIcon(HICON *phIcon)
Expand Down
Loading

0 comments on commit 6a57883

Please sign in to comment.