Skip to content

Commit

Permalink
Migrate to libIME2 and removed the legacy libIME from submodules.
Browse files Browse the repository at this point in the history
  • Loading branch information
PCMan committed Apr 2, 2020
1 parent d4b2e7c commit ac86758
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "jsoncpp"]
path = jsoncpp
url = https://github.com/open-source-parsers/jsoncpp.git
[submodule "libIME"]
path = libIME
url = https://github.com/EasyIME/libIME.git
[submodule "python/input_methods/rime/brise"]
path = python/input_methods/rime/brise
url = https://github.com/rime/brise.git
[submodule "libuv"]
path = libuv
url = https://github.com/EasyIME/libuv.git
[submodule "libIME2"]
path = libIME2
url = https://github.com/EasyIME/libIME2.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ add_definitions(
-D_WIN32_WINNT=0x0600 # 0x0600 is Windows Vista
)

add_subdirectory(${PROJECT_SOURCE_DIR}/libIME)
add_subdirectory(${PROJECT_SOURCE_DIR}/libIME2)

# turn of some unnecessary build options for jsoncpp
# Reference: http://stackoverflow.com/questions/3766740/overriding-a-default-option-value-in-cmake-from-a-parent-cmakelists-txt
Expand Down
2 changes: 1 addition & 1 deletion PIMETextService/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ add_library(PIMETextService SHARED
)

target_link_libraries(PIMETextService
libIME_static
libIME2_static
jsoncpp_lib_static
)
7 changes: 5 additions & 2 deletions PIMETextService/DllEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include <vector>
#include <ShlObj.h>
#include <Shlwapi.h> // for PathIsRelative
#include <VersionHelpers.h> // Provided by Windows SDK >= 8.1

#include <json/json.h>
#include "../libIME/Utils.h"
#include "../libIME2/src/Utils.h"


PIME::ImeModule* g_imeModule = NULL;
Expand Down Expand Up @@ -77,8 +79,9 @@ static inline Ime::LangProfileInfo langProfileFromJson(std::wstring file, std::s

STDAPI DllRegisterServer(void) {
int iconIndex = 0; // use classic icon
if(g_imeModule->isWindows8Above())
if(::IsWindows8OrGreater()) {
iconIndex = 1; // use Windows 8 style IME icon
}
std::vector<Ime::LangProfileInfo> langProfiles;
std::wstring dirPath;
for (const auto backendDir: g_imeModule->backendDirs()) {
Expand Down
7 changes: 4 additions & 3 deletions PIMETextService/PIMEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//

#include "PIMEClient.h"
#include "libIME/Utils.h"
#include "libIME2/src/Utils.h"
#include <algorithm>
#include <json/json.h>

Expand All @@ -30,6 +30,7 @@
#include <cctype>
#include <algorithm>
#include <Winnls.h> // for IS_HIGH_SURROGATE() macro for checking UTF16 surrogate pairs
#include <VersionHelpers.h> // Provided by Windows SDK >= 8.1

using namespace std;

Expand Down Expand Up @@ -264,7 +265,7 @@ void Client::updateStatus(Json::Value& msg, Ime::EditSession* session) {
for (auto btn_it = addButtonVal.begin(); btn_it != addButtonVal.end(); ++btn_it) {
const Json::Value& btn = *btn_it;
// FIXME: when to clear the id <=> button map??
Ime::ComPtr<PIME::LangBarButton> langBtn{ PIME::LangBarButton::fromJson(textService_, btn), false };
auto langBtn = Ime::ComPtr<PIME::LangBarButton>::takeover(PIME::LangBarButton::fromJson(textService_, btn));
if (langBtn != nullptr) {
buttons_.emplace(langBtn->id(), langBtn); // insert into the map
textService_->addButton(langBtn);
Expand Down Expand Up @@ -600,7 +601,7 @@ void Client::init() {
Json::Value req;
req["method"] = "init";
req["id"] = guid_.c_str(); // language profile guid
req["isWindows8Above"] = textService_->imeModule()->isWindows8Above();
req["isWindows8Above"] = ::IsWindows8OrGreater();
req["isMetroApp"] = textService_->isMetroApp();
req["isUiLess"] = textService_->isUiLess();
req["isConsole"] = textService_->isConsole();
Expand Down
6 changes: 3 additions & 3 deletions PIMETextService/PIMEClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#ifndef _PIME_CLIENT_H_
#define _PIME_CLIENT_H_
#define NDEBUG
#include <libIME/TextService.h>
#include <libIME/KeyEvent.h>
#include <libIME/EditSession.h>
#include <libIME2/src/TextService.h>
#include <libIME2/src/KeyEvent.h>
#include <libIME2/src/EditSession.h>
#include "PIMELangBarButton.h"

#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion PIMETextService/PIMEImeModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <Shellapi.h>
#include <Shlwapi.h>
#include <json/json.h>
#include "../libIME/Utils.h"
#include "../libIME2/src/Utils.h"

namespace PIME {

Expand Down
2 changes: 1 addition & 1 deletion PIMETextService/PIMEImeModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef NODE_IME_MODULE_H
#define NODE_IME_MODULE_H

#include <LibIME/ImeModule.h>
#include <LibIME2/src/ImeModule.h>
#include <string>
#include <vector>
#include <json/json.h>
Expand Down
2 changes: 1 addition & 1 deletion PIMETextService/PIMELangBarButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "PIMELangBarButton.h"
#include "PIMETextService.h"
#include "libIME/Utils.h"
#include "libIME2/src/Utils.h"

// this is the GUID of the IME mode icon in Windows 8
// the value is not available in older SDK versions, so let's define it ourselves.
Expand Down
2 changes: 1 addition & 1 deletion PIMETextService/PIMELangBarButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#ifndef PIME_LANGUAGE_BAR_BUTTON_H
#define PIME_LANGUAGE_BAR_BUTTON_H

#include <libIME/LangBarButton.h>
#include <libIME2/src/LangBarButton.h>
#include <json/json.h>
#include <string>
#include <unordered_map>
Expand Down
18 changes: 8 additions & 10 deletions PIMETextService/PIMETextService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "PIMETextService.h"
#include <assert.h>
#include <string>
#include <libIME/ComPtr.h>
#include <libIME/Utils.h>
#include <libIME/LangBarButton.h>
#include <libIME2/src/ComPtr.h>
#include <libIME2/src/Utils.h>
#include <libIME2/src/LangBarButton.h>
#include "PIMEImeModule.h"
#include "resource.h"
#include <Shellapi.h>
Expand Down Expand Up @@ -180,10 +180,8 @@ void TextService::onKeyboardStatusChanged(bool opened) {
else { // keyboard is closed
if(isComposing()) {
// end current composition if needed
ITfContext* context = currentContext();
if(context) {
if(auto context = currentContext()) {
endComposition(context);
context->Release();
}
}
if(showingCandidates()) // disable candidate window if it's opened
Expand Down Expand Up @@ -234,7 +232,7 @@ void TextService::createCandidateWindow(Ime::EditSession* session) {
candidateWindow_->Release(); // decrease ref count caused by new

candidateWindow_->setFont(font_);
Ime::ComQIPtr<ITfUIElementMgr> elementMgr = threadMgr();
auto elementMgr = Ime::ComPtr<ITfUIElementMgr>::queryFrom(threadMgr());
if (elementMgr) {
BOOL pbShow = false;
if (validCandidateListElementId_ =
Expand Down Expand Up @@ -287,7 +285,7 @@ void TextService::updateCandidates(Ime::EditSession* session) {
}

if (validCandidateListElementId_) {
Ime::ComQIPtr<ITfUIElementMgr> elementMgr = threadMgr();
auto elementMgr = Ime::ComPtr<ITfUIElementMgr>::queryFrom(threadMgr());
if (elementMgr) {
elementMgr->UpdateUIElement(candidateListElementId_);
}
Expand All @@ -307,7 +305,7 @@ void TextService::updateCandidatesWindow(Ime::EditSession* session) {

void TextService::refreshCandidates() {
if (validCandidateListElementId_) {
Ime::ComQIPtr<ITfUIElementMgr> elementMgr = threadMgr();
auto elementMgr = Ime::ComPtr<ITfUIElementMgr>::queryFrom(threadMgr());
if (elementMgr) {
elementMgr->UpdateUIElement(candidateListElementId_);
}
Expand All @@ -334,7 +332,7 @@ void TextService::showCandidates(Ime::EditSession* session) {
// hide candidate list window
void TextService::hideCandidates() {
if (validCandidateListElementId_) {
Ime::ComQIPtr<ITfUIElementMgr> elementMgr = threadMgr();
auto elementMgr = Ime::ComPtr<ITfUIElementMgr>::queryFrom(threadMgr());
if (elementMgr) {
elementMgr->EndUIElement(candidateListElementId_);
candidateListElementId_ = 0;
Expand Down
10 changes: 5 additions & 5 deletions PIMETextService/PIMETextService.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#ifndef NODE_TEXT_SERVICE_H
#define NODE_TEXT_SERVICE_H

#include <LibIME/TextService.h>
#include <LibIME/CandidateWindow.h>
#include <LibIME/MessageWindow.h>
#include <LibIME/EditSession.h>
#include <LibIME/LangBarButton.h>
#include <LibIME2/src/TextService.h>
#include <LibIME2/src/CandidateWindow.h>
#include <LibIME2/src/MessageWindow.h>
#include <LibIME2/src/EditSession.h>
#include <LibIME2/src/LangBarButton.h>
#include "PIMEImeModule.h"
#include <sys/types.h>
#include "PIMEClient.h"
Expand Down
1 change: 0 additions & 1 deletion libIME
Submodule libIME deleted from f6c29b
1 change: 1 addition & 0 deletions libIME2
Submodule libIME2 added at 0a6e47

0 comments on commit ac86758

Please sign in to comment.