Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
・Firefoxで候補一覧ウィンドウや複数補完ウィンドウが一瞬だけ原点座標に表示されてしまう不具合を修正しました。

・LibreOfficeの旧バージョン用の古いコードを削除しました。

・入力モード表示ウィンドウのコンポジションに依存した処理を削除しました。
  • Loading branch information
nathancorvussolis committed Oct 15, 2015
1 parent 3d12ea5 commit ff8aff4
Show file tree
Hide file tree
Showing 23 changed files with 399 additions and 315 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# CorvusSKK ver. 2.0.0
# CorvusSKK ver. 2.0.1

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

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.0.0"
#define TEXTSERVICE_VER L"2.0.1"

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

#endif
6 changes: 3 additions & 3 deletions imcrvcnf/DlgProcDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
hdc = GetDC(hDlg);

hFont = (HFONT)SendMessageW(GetDlgItem(hDlg, IDC_EDIT_FONTNAME), WM_GETFONT, 0, 0);
GetObjectW(hFont, sizeof(LOGFONTW), &lf);
GetObjectW(hFont, sizeof(lf), &lf);
lf.lfHeight = -MulDiv(GetDlgItemInt(hDlg, IDC_EDIT_FONTPOINT, NULL, FALSE), GetDeviceCaps(hdc, LOGPIXELSY), 72);
lf.lfCharSet = SHIFTJIS_CHARSET;

ZeroMemory(&cf, sizeof(cf));
cf.lStructSize = sizeof(CHOOSEFONTW);
cf.lStructSize = sizeof(cf);
cf.hwndOwner = hDlg;
cf.lpLogFont = &lf;
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_NOVERTFONTS | CF_SCREENFONTS | CF_SELECTSCRIPT;
Expand Down Expand Up @@ -274,7 +274,7 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
WriterKey(pXmlWriter, ValueFontName, fontname);

hFont = (HFONT)SendMessageW(GetDlgItem(hDlg, IDC_EDIT_FONTNAME), WM_GETFONT, 0, 0);
GetObjectW(hFont, sizeof(LOGFONTW), &lf);
GetObjectW(hFont, sizeof(lf), &lf);
GetDlgItemTextW(hDlg, IDC_EDIT_FONTPOINT, num, _countof(num));
WriterKey(pXmlWriter, ValueFontSize, num);
_snwprintf_s(num, _TRUNCATE, L"%d", lf.lfWeight);
Expand Down
4 changes: 2 additions & 2 deletions imcrvcnf/DlgProcKana.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
case IDC_BUTTON_LOADKANA:
path[0] = L'\0';
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAMEW);
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hDlg;
ofn.lpstrFile = path;
ofn.nMaxFile = _countof(path);
Expand All @@ -81,7 +81,7 @@ INT_PTR CALLBACK DlgProcKana(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPar
case IDC_BUTTON_SAVEKANA:
path[0] = L'\0';
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAMEW);
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hDlg;
ofn.lpstrFile = path;
ofn.nMaxFile = _countof(path);
Expand Down
10 changes: 5 additions & 5 deletions imcrvcnf/imcrvcnf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
return 0;
}

icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwSize = sizeof(icex);
icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES | ICC_PROGRESS_CLASS;
InitCommonControlsEx(&icex);

Expand Down Expand Up @@ -53,8 +53,8 @@ void CreateProperty()
};
HPROPSHEETPAGE hpsp[_countof(DlgPage)];

ZeroMemory(&psp, sizeof(PROPSHEETPAGEW));
psp.dwSize = sizeof(PROPSHEETPAGEW);
ZeroMemory(&psp, sizeof(psp));
psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_PREMATURE;
psp.hInstance = hInst;

Expand All @@ -65,8 +65,8 @@ void CreateProperty()
hpsp[i] = CreatePropertySheetPageW(&psp);
}

ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
psh.dwSize = sizeof(PROPSHEETHEADERW);
ZeroMemory(&psh, sizeof(psh));
psh.dwSize = sizeof(psh);
psh.dwFlags = PSH_DEFAULT | PSH_NOCONTEXTHELP | PSH_USECALLBACK;
psh.hwndParent = NULL;
psh.hInstance = hInst;
Expand Down
8 changes: 4 additions & 4 deletions imcrvmgr/SearchDictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ std::wstring SearchSKKDic(const std::wstring &searchkey)
std::wstring key, candidate, wsbuf;
WCHAR wbuf[DICBUFSIZE];
long pos, left, mid, right;
int comp;
int cmpkey;
size_t pidx;

_wfopen_s(&fpidx, pathskkidx, RB);
Expand Down Expand Up @@ -118,8 +118,8 @@ std::wstring SearchSKKDic(const std::wstring &searchkey)
fgetws(wbuf, _countof(wbuf), fpdic);
wsbuf = wbuf;

comp = wcsncmp(key.c_str(), wsbuf.c_str(), key.size());
if(comp == 0)
cmpkey = wcsncmp(key.c_str(), wsbuf.c_str(), key.size());
if(cmpkey == 0)
{
if((pidx = wsbuf.find_last_of(L'/')) != std::string::npos)
{
Expand All @@ -136,7 +136,7 @@ std::wstring SearchSKKDic(const std::wstring &searchkey)
}
break;
}
else if(comp > 0)
else if(cmpkey > 0)
{
left = mid + 1;
}
Expand Down
20 changes: 10 additions & 10 deletions imcrvmgr/imcrvmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lua_State *lua;
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
{
MSG msg;
WNDCLASSEXW wcex;
WNDCLASSEXW wc;
HWND hWnd;
WSADATA wsaData;
PSECURITY_DESCRIPTOR psd;
Expand Down Expand Up @@ -64,15 +64,15 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd

hInst = hInstance;

ZeroMemory(&wcex, sizeof(wcex));
wcex.cbSize = sizeof(WNDCLASSEXW);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.hInstance = hInst;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszClassName = DictionaryManagerClass;
RegisterClassExW(&wcex);
ZeroMemory(&wc, sizeof(wc));
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.hInstance = hInst;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszClassName = DictionaryManagerClass;
RegisterClassExW(&wc);

#ifdef _DEBUG
hWnd = CreateWindowW(DictionaryManagerClass, TextServiceDesc,
Expand Down
126 changes: 90 additions & 36 deletions imcrvtip/CandidateList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@
#include "CandidateList.h"
#include "CandidateWindow.h"

class CGetTextExtEditSession : public CEditSessionBase
class CCandidateListGetTextExtEditSession : public CEditSessionBase
{
public:
CGetTextExtEditSession(CTextService *pTextService, ITfContext *pContext, ITfContextView *pContextView, ITfRange *pRange, CCandidateWindow *pCandidateWindow) : CEditSessionBase(pTextService, pContext)
CCandidateListGetTextExtEditSession(CTextService *pTextService, ITfContext *pContext,
ITfContextView *pContextView, ITfRange *pRange, CCandidateWindow *pCandidateWindow) : CEditSessionBase(pTextService, pContext)
{
_pContextView = pContextView;
_pRangeComposition = pRange;
_pCandidateWindow = pCandidateWindow;
_pCandidateWindow->AddRef();
_pRangeComposition = pRange;
_pRangeComposition->AddRef();
_pContextView = pContextView;
_pContextView->AddRef();
}

~CCandidateListGetTextExtEditSession()
{
SafeRelease(&_pCandidateWindow);
SafeRelease(&_pRangeComposition);
SafeRelease(&_pContextView);
}

// ITfEditSession
Expand All @@ -25,6 +36,7 @@ class CGetTextExtEditSession : public CEditSessionBase
{
_pCandidateWindow->_Move(&rc);
}

return S_OK;
}

Expand All @@ -41,8 +53,8 @@ CCandidateList::CCandidateList(CTextService *pTextService)
_cRef = 1;

_pTextService = pTextService;
_pTextService->AddRef();

_hwndParent = NULL;
_pCandidateWindow = NULL;
_pRangeComposition = NULL;
_pContextCandidateWindow = NULL;
Expand All @@ -57,6 +69,8 @@ CCandidateList::~CCandidateList()
{
_EndCandidateList();

SafeRelease(&_pTextService);

DllRelease();
}

Expand Down Expand Up @@ -183,8 +197,8 @@ STDAPI CCandidateList::OnLayoutChange(ITfContext *pContext, TfLayoutCode lcode,
{
try
{
CGetTextExtEditSession *pEditSession =
new CGetTextExtEditSession(_pTextService, pContext, pContextView, _pRangeComposition, _pCandidateWindow);
CCandidateListGetTextExtEditSession *pEditSession =
new CCandidateListGetTextExtEditSession(_pTextService, pContext, pContextView, _pRangeComposition, _pCandidateWindow);
pContext->RequestEditSession(_pTextService->_GetClientId(), pEditSession, TF_ES_SYNC | TF_ES_READ, &hr);
SafeRelease(&pEditSession);
}
Expand All @@ -205,14 +219,57 @@ STDAPI CCandidateList::OnLayoutChange(ITfContext *pContext, TfLayoutCode lcode,
return S_OK;
}

class CCandidateWindowEditSession : public CEditSessionBase
{
public:
CCandidateWindowEditSession(CTextService *pTextService, ITfContext *pContext,
ITfRange *pRange, CCandidateWindow *pCandidateWindow) : CEditSessionBase(pTextService, pContext)
{
_pCandidateWindow = pCandidateWindow;
_pCandidateWindow->AddRef();
_pRangeComposition = pRange;
_pRangeComposition->AddRef();
}

~CCandidateWindowEditSession()
{
SafeRelease(&_pCandidateWindow);
SafeRelease(&_pRangeComposition);
}

// ITfEditSession
STDMETHODIMP DoEditSession(TfEditCookie ec)
{
ITfContextView *pContextView;
if(_pContext->GetActiveView(&pContextView) == S_OK)
{
RECT rc;
BOOL fClipped;
if(pContextView->GetTextExt(ec, _pRangeComposition, &rc, &fClipped) == S_OK)
{
_pCandidateWindow->_Move(&rc);
}

SafeRelease(&pContextView);
}

_pCandidateWindow->_BeginUIElement();
_pCandidateWindow->_Redraw();

return S_OK;
}

private:
ITfRange *_pRangeComposition;
CCandidateWindow *_pCandidateWindow;
};

HRESULT CCandidateList::_StartCandidateList(TfClientId tfClientId, ITfDocumentMgr *pDocumentMgr,
ITfContext *pContext, TfEditCookie ec, ITfRange *pRange, BOOL reg, BOOL comp)
{
HRESULT hr = E_FAIL;
TfEditCookie ecTextStore;
ITfContextView *pContextView;
BOOL fClipped;
RECT rc;
HWND hwnd = NULL;

_EndCandidateList();
Expand All @@ -237,7 +294,6 @@ HRESULT CCandidateList::_StartCandidateList(TfClientId tfClientId, ITfDocumentMg
_pRangeComposition->AddRef();

_ec = ec;

_comp = comp;

if(_AdviseContextKeyEventSink() != S_OK)
Expand All @@ -254,39 +310,44 @@ HRESULT CCandidateList::_StartCandidateList(TfClientId tfClientId, ITfDocumentMg
{
_pCandidateWindow = new CCandidateWindow(_pTextService, this);

if(pContext->GetActiveView(&pContextView) != S_OK)
{
goto exit;
}

if(!_pTextService->_UILessMode && _pCandidateWindow->_CanShowUIElement())
if(pContext->GetActiveView(&pContextView) == S_OK)
{
if(FAILED(pContextView->GetWnd(&hwnd)) || hwnd == NULL)
if(!_pTextService->_UILessMode && _pCandidateWindow->_CanShowUIElement())
{
hwnd = GetFocus();
if(FAILED(pContextView->GetWnd(&hwnd)) || hwnd == NULL)
{
hwnd = GetFocus();
}
}

SafeRelease(&pContextView);
}

_hwndParent = hwnd;
if(_hwndParent)
if(!_pCandidateWindow->_Create(hwnd, NULL, 0, 0, reg, comp))
{
// for LibreOffice, to get position in screen
SendMessageW(_hwndParent, WM_IME_NOTIFY, IMN_OPENCANDIDATE, 1);
goto exit;
}

pContextView->GetTextExt(ec, pRange, &rc, &fClipped);
HRESULT hrSession = E_FAIL;

SafeRelease(&pContextView);
try
{
CCandidateWindowEditSession *pEditSession =
new CCandidateWindowEditSession(_pTextService, _pContextDocument, _pRangeComposition, _pCandidateWindow);
// Asynchronous
pContext->RequestEditSession(ec, pEditSession, TF_ES_ASYNC | TF_ES_READWRITE, &hrSession);
SafeRelease(&pEditSession);
}
catch(...)
{
}

if(!_pCandidateWindow->_Create(hwnd, NULL, 0, 0, reg, comp))
if(hrSession != TF_S_ASYNC)
{
hr = E_FAIL;
goto exit;
}

_pCandidateWindow->_Move(&rc);
_pCandidateWindow->_BeginUIElement();
_pCandidateWindow->_Redraw();

hr = S_OK;
}
catch(...)
Expand Down Expand Up @@ -319,13 +380,6 @@ void CCandidateList::_InvokeSfHandler(BYTE sf)

void CCandidateList::_EndCandidateList()
{
if(_hwndParent)
{
// for LibreOffice, to get position in screen
SendMessageW(_hwndParent, WM_IME_NOTIFY, IMN_CLOSECANDIDATE, 1);
_hwndParent = NULL;
}

if(_pCandidateWindow != NULL)
{
_pCandidateWindow->_EndUIElement();
Expand Down
3 changes: 1 addition & 2 deletions imcrvtip/CandidateList.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ class CCandidateList :
ITfDocumentMgr *_pDocumentMgr;
TfEditCookie _ec;

HWND _hwndParent;
CCandidateWindow *_pCandidateWindow;

BOOL _comp;
BOOL _comp; //複数補完/複数動的補完
};

#endif //CANDIDATELIST_H
Loading

0 comments on commit ff8aff4

Please sign in to comment.