Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RimeWithWeasel/RimeWithWeasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef enum { COLOR_ABGR = 0, COLOR_ARGB, COLOR_RGBA } ColorFormat;
#define TRIMHEAD_REGEX std::regex("0x", std::regex::icase)
#endif
using namespace weasel;
static bool hide_ime_mode_icon = false;

static RimeApi* rime_api;
WeaselSessionId _GenerateNewWeaselSessionId(SessionStatusMap sm, DWORD pid) {
Expand Down Expand Up @@ -888,6 +889,8 @@ bool RimeWithWeaselHandler::_Respond(WeaselSessionId ipc_id, EatLine eat) {

// style
if (!session_status.__synced) {
messages.push_back(std::string("config.hide_ime_mode_icon=") +
std::to_string((int)hide_ime_mode_icon) + "\n");
std::wstringstream ss;
boost::archive::text_woarchive oa(ss);
oa << session_status.style;
Expand Down Expand Up @@ -1112,6 +1115,7 @@ static void _UpdateUIStyle(RimeConfig* config, UI* ui, bool initialize) {
_RimeGetIntStr(config, "style/font_point", style.font_point);
if (style.font_point <= 0)
style.font_point = 12;
_RimeGetBool(config, "hide_ime_mode_icon", initialize, hide_ime_mode_icon);
_RimeGetIntStr(config, "style/label_font_point", style.label_font_point,
"style/font_point", 0, _abs);
_RimeGetIntStr(config, "style/comment_font_point", style.comment_font_point,
Expand Down
6 changes: 6 additions & 0 deletions WeaselIPC/Configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ void Configurator::Store(Deserializer::KeyType const& key,
bool bool_value = (!value.empty() && value != L"0");
if (key[1] == L"inline_preedit") {
m_pTarget->p_config->inline_preedit = bool_value;
return;
}

if (key[1] == L"hide_ime_mode_icon") {
m_pTarget->p_config->hide_ime_mode_icon = bool_value;
return;
}
}
5 changes: 5 additions & 0 deletions WeaselTSF/EditSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ STDAPI WeaselTSF::DoEditSession(TfEditCookie ec) {

bool ok = m_client.GetResponseData(std::ref(parser));

if (config.hide_ime_mode_icon != _config.hide_ime_mode_icon) {
_config = config;
_UninitLanguageBar();
_InitLanguageBar();
}
_UpdateLanguageBar(_status);

if (ok) {
Expand Down
8 changes: 5 additions & 3 deletions WeaselTSF/LanguageBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,18 @@ BOOL WeaselTSF::_InitLanguageBar() {
if (_pThreadMgr->QueryInterface(&pLangBarItemMgr) != S_OK)
return FALSE;

if ((_pLangBarButton = new CLangBarItemButton(this, GUID_LBI_INPUTMODE,
_cand->style())) == NULL)
const GUID langBarGuid =
_config.hide_ime_mode_icon ? GUID_NULL : GUID_LBI_INPUTMODE;
if ((_pLangBarButton =
new CLangBarItemButton(this, langBarGuid, _cand->style())) == NULL)
return FALSE;

if (pLangBarItemMgr->AddItem(_pLangBarButton) != S_OK) {
_pLangBarButton = NULL;
return FALSE;
}

_pLangBarButton->Show(TRUE);
_pLangBarButton->Show(!_config.hide_ime_mode_icon);
fRet = TRUE;

return fRet;
Expand Down
14 changes: 13 additions & 1 deletion WeaselTSF/WeaselTSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ STDAPI WeaselTSF::Deactivate() {
return S_OK;
}

static void fake_key() {
INPUT inputs[2];
inputs[0].type = INPUT_KEYBOARD;
inputs[0].ki = {VK_SELECT, 0, 0, 0, 0};
inputs[1].type = INPUT_KEYBOARD;
inputs[1].ki = {VK_SELECT, 0, KEYEVENTF_KEYUP, 0, 0};
::SendInput(sizeof(inputs) / sizeof(INPUT), inputs, sizeof(INPUT));
}

STDAPI WeaselTSF::ActivateEx(ITfThreadMgr* pThreadMgr,
TfClientId tfClientId,
DWORD dwFlags) {
Expand Down Expand Up @@ -148,6 +157,7 @@ STDAPI WeaselTSF::ActivateEx(ITfThreadMgr* pThreadMgr,
if (!_InitPreservedKey())
goto ExitError;

fake_key();
if (!_InitLanguageBar())
goto ExitError;

Expand Down Expand Up @@ -175,10 +185,12 @@ STDMETHODIMP WeaselTSF::OnSetThreadFocus() {
_isToOpenClose = (_ToggleImeOnOpenClose == L"yes");
if (m_client.Echo()) {
m_client.ProcessKeyEvent(0);
weasel::ResponseParser parser(NULL, NULL, &_status, NULL, &_cand->style());
weasel::ResponseParser parser(NULL, NULL, &_status, &_config,
&_cand->style());
bool ok = m_client.GetResponseData(std::ref(parser));
if (ok)
_UpdateLanguageBar(_status);
_ShowLanguageBar(!_config.hide_ime_mode_icon);
}
return S_OK;
}
Expand Down
1 change: 1 addition & 0 deletions WeaselTSF/WeaselTSF.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class WeaselTSF : public ITfTextInputProcessorEx,

/* IME status */
weasel::Status _status;
weasel::Config _config;

// guidatom for the display attibute.
TfGuidAtom _gaDisplayAttributeInput;
Expand Down
15 changes: 13 additions & 2 deletions include/WeaselIPCData.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,15 @@ struct Status {

// 用於向前端告知設置信息
struct Config {
Config() : inline_preedit(false) {}
void reset() { inline_preedit = false; }
Config() : inline_preedit(false), hide_ime_mode_icon(false) {}
void reset() {
inline_preedit = false;
hide_ime_mode_icon = false;
}
// inline preedit switch
bool inline_preedit;
// hide tsf mode icon switch
bool hide_ime_mode_icon;
};

struct UIStyle {
Expand Down Expand Up @@ -532,5 +538,10 @@ void serialize(Archive& ar, weasel::TextRange& s, const unsigned int version) {
ar & s.end;
ar & s.cursor;
}
template <typename Archive>
void serialize(Archive& ar, weasel::Config& s, const unsigned int version) {
ar & s.inline_preedit;
ar & s.hide_ime_mode_icon;
}
} // namespace serialization
} // namespace boost
Loading