diff --git a/.github/workflows/commit-ci.yml b/.github/workflows/commit-ci.yml index de342f75a..fa0677319 100644 --- a/.github/workflows/commit-ci.yml +++ b/.github/workflows/commit-ci.yml @@ -15,7 +15,7 @@ on: jobs: build: - runs-on: windows-2022 + runs-on: windows-2019 env: librime_build: 'submodule' boost_version: 1.84.0 @@ -36,7 +36,7 @@ jobs: - name: Configure build environment shell: bash run: | - cp env.vs2022.bat env.bat + cp env.vs2019.bat env.bat librime_id=$(git submodule foreach --quiet 'if [ $name == "librime" ]; then echo `git rev-parse HEAD`; fi') echo "librime_id is $librime_id" echo "librime_id=$librime_id" >> $GITHUB_ENV @@ -69,7 +69,7 @@ jobs: with: path: | librime - key: ${{ runner.os }}-librime-${{ env.librime_id }} + key: ${{ runner.os }}-librime-${{ env.librime_id }}-dual # build librime if not cached - name: Build librime @@ -89,9 +89,11 @@ jobs: if: ${{ env.librime_build == 'submodule' && steps.cache-librime.outputs.cache-hit == 'true' }} shell: bash run: | - cp ./librime/dist/lib/rime* ./lib/ - cp ./librime/dist/lib/rime.dll ./output/ - cp ./librime/dist/include/*.h ./include/ + cp ./librime/dist_x64/lib/rime* ./lib64/ + cp ./librime/dist_x64/lib/rime.dll ./output/ + cp ./librime/dist_x64/include/*.h ./include/ + cp ./librime/dist_Win32/lib/rime* ./lib/ + cp ./librime/dist_Win32/lib/rime.dll ./output/Win32/ - name: Build Weasel id: build_weasel diff --git a/.github/workflows/release-ci.yml b/.github/workflows/release-ci.yml index 09056a572..f07b20631 100644 --- a/.github/workflows/release-ci.yml +++ b/.github/workflows/release-ci.yml @@ -12,7 +12,7 @@ jobs: build-and-release: permissions: contents: write - runs-on: windows-2022 + runs-on: windows-2019 env: librime_build: submodule boost_version: 1.84.0 @@ -26,7 +26,7 @@ jobs: - name: Configure build environment shell: bash run: | - cp env.vs2022.bat env.bat + cp env.vs2019.bat env.bat librime_id=$(git submodule foreach --quiet 'if [ $name == "librime" ]; then echo `git rev-parse HEAD`; fi') echo "librime_id is $librime_id" echo "librime_id=$librime_id" >> $GITHUB_ENV @@ -66,7 +66,7 @@ jobs: with: path: | librime - key: ${{ runner.os }}-librime-${{ env.librime_id }} + key: ${{ runner.os }}-librime-${{ env.librime_id }}-dual # build librime if not cached for nightly build and not stable release - name: Build librime @@ -86,12 +86,26 @@ jobs: if: ${{ github.ref == 'refs/heads/master' && env.librime_build == 'submodule' && steps.cache-librime.outputs.cache-hit == 'true' }} shell: bash run: | - cp ./librime/dist/lib/rime* ./lib/ - cp ./librime/dist/lib/rime.dll ./output/ - cp ./librime/dist/include/*.h ./include/ + cp ./librime/dist_x64/lib/rime* ./lib64/ + cp ./librime/dist_x64/lib/rime.dll ./output/ + cp ./librime/dist_x64/include/*.h ./include/ + cp ./librime/dist_Win32/lib/rime* ./lib/ + cp ./librime/dist_Win32/lib/rime.dll ./output/Win32/ - - name: Build Weasel + - name: Build Weasel Release id: build_weasel + if: startsWith(github.ref, 'refs/tags/') + shell: bash + env: + RELEASE_BUILD: 1 + run: | + ./build.bat data + ./build.bat hant arm64 + ./build.bat installer + + - name: Build Weasel Nightly + id: build_weasel_nightly + if: github.ref == 'refs/heads/master' shell: bash run: | ./build.bat data diff --git a/RimeWithWeasel/RimeWithWeasel.cpp b/RimeWithWeasel/RimeWithWeasel.cpp index 4a7be0f42..ac34d4a8d 100644 --- a/RimeWithWeasel/RimeWithWeasel.cpp +++ b/RimeWithWeasel/RimeWithWeasel.cpp @@ -28,6 +28,12 @@ typedef enum { COLOR_ABGR = 0, COLOR_ARGB, COLOR_RGBA } ColorFormat; #endif using namespace weasel; +WeaselSessionId _GenerateNewWeaselSessionId(SessionStatusMap sm, DWORD pid) { + if (sm.empty()) + return (WeaselSessionId)(pid + 1); + return (WeaselSessionId)(sm.rbegin()->first + 1); +} + int expand_ibus_modifier(int m) { return (m & 0xff) | ((m & 0xff00) << 16); } @@ -40,6 +46,15 @@ RimeWithWeaselHandler::RimeWithWeaselHandler(UI* ui) m_global_ascii_mode(false), m_show_notifications_time(1200), _UpdateUICallback(NULL) { + m_pid = GetCurrentProcessId(); + uint16_t msbit = 0; + for (auto i = 31; i >= 0; i--) { + if (m_pid & (1 << i)) { + msbit = i; + break; + } + } + m_pid = (m_pid << (31 - msbit)); _Setup(); } @@ -49,14 +64,14 @@ RimeWithWeaselHandler::~RimeWithWeaselHandler() { m_app_options.clear(); } -bool addsession = false; +bool add_session = false; void _UpdateUIStyle(RimeConfig* config, UI* ui, bool initialize); bool _UpdateUIStyleColor(RimeConfig* config, UIStyle& style, std::string color = ""); void _LoadAppOptions(RimeConfig* config, AppOptionsByAppName& app_options); -void _RefreshTrayIcon(const UINT session_id, +void _RefreshTrayIcon(const RimeSessionId session_id, const std::function _UpdateUICallback) { // Dangerous, don't touch static char app_name[50]; @@ -138,23 +153,23 @@ void RimeWithWeaselHandler::Finalize() { RimeFinalize(); } -UINT RimeWithWeaselHandler::FindSession(UINT session_id) { +DWORD RimeWithWeaselHandler::FindSession(WeaselSessionId ipc_id) { if (m_disabled) return 0; - Bool found = RimeFindSession(session_id); - DLOG(INFO) << "Find session: session_id = " << session_id + Bool found = RimeFindSession(to_session_id(ipc_id)); + DLOG(INFO) << "Find session: session_id = " << to_session_id(ipc_id) << ", found = " << found; - return found ? session_id : 0; + return found ? (ipc_id) : 0; } -UINT RimeWithWeaselHandler::AddSession(LPWSTR buffer, EatLine eat) { +DWORD RimeWithWeaselHandler::AddSession(LPWSTR buffer, EatLine eat) { if (m_disabled) { DLOG(INFO) << "Trying to resume service."; EndMaintenance(); if (m_disabled) return 0; } - UINT session_id = (UINT)RimeCreateSession(); + RimeSessionId session_id = (RimeSessionId)RimeCreateSession(); if (m_global_ascii_mode) { for (const auto& pair : m_session_status_map) { if (pair.first) { @@ -164,45 +179,49 @@ UINT RimeWithWeaselHandler::AddSession(LPWSTR buffer, EatLine eat) { } } } - DLOG(INFO) << "Add session: created session_id = " << session_id; - _ReadClientInfo(session_id, buffer); - m_session_status_map[session_id] = SessionStatus(); - m_session_status_map[session_id].style = m_base_style; + WeaselSessionId ipc_id = + _GenerateNewWeaselSessionId(m_session_status_map, m_pid); + DLOG(INFO) << "Add session: created session_id = " << session_id + << ", ipc_id = " << ipc_id; + SessionStatus& session_status = new_session_status(ipc_id); + session_status.style = m_base_style; + session_status.session_id = session_id; + _ReadClientInfo(ipc_id, buffer); RIME_STRUCT(RimeStatus, status); if (RimeGetStatus(session_id, &status)) { std::string schema_id = status.schema_id; m_last_schema_id = schema_id; - _LoadSchemaSpecificSettings(session_id, schema_id); - _LoadAppInlinePreeditSet(session_id, true); - _UpdateInlinePreeditStatus(session_id); + _LoadSchemaSpecificSettings(ipc_id, schema_id); + _LoadAppInlinePreeditSet(ipc_id, true); + _UpdateInlinePreeditStatus(ipc_id); _RefreshTrayIcon(session_id, _UpdateUICallback); - m_session_status_map[session_id].status = status; - m_session_status_map[session_id].__synced = false; + session_status.status = status; + session_status.__synced = false; RimeFreeStatus(&status); } - m_ui->style() = m_session_status_map[session_id].style; + m_ui->style() = session_status.style; // show session's welcome message :-) if any if (eat) { - _Respond(session_id, eat); + _Respond(ipc_id, eat); } - addsession = true; - _UpdateUI(session_id); - addsession = false; - m_active_session = session_id; - return session_id; + add_session = true; + _UpdateUI(ipc_id); + add_session = false; + m_active_session = ipc_id; + return ipc_id; } -UINT RimeWithWeaselHandler::RemoveSession(UINT session_id) { +DWORD RimeWithWeaselHandler::RemoveSession(WeaselSessionId ipc_id) { if (m_ui) m_ui->Hide(); if (m_disabled) return 0; - DLOG(INFO) << "Remove session: session_id = " << session_id; + DLOG(INFO) << "Remove session: session_id = " << to_session_id(ipc_id); // TODO: force committing? otherwise current composition would be lost - RimeDestroySession(session_id); - m_session_status_map.erase(session_id); + RimeDestroySession(to_session_id(ipc_id)); + m_session_status_map.erase(ipc_id); m_active_session = 0; return 0; } @@ -238,7 +257,7 @@ void RimeWithWeaselHandler::UpdateColorTheme(BOOL darkMode) { for (auto& pair : m_session_status_map) { RIME_STRUCT(RimeStatus, status); - if (RimeGetStatus(pair.first, &status)) { + if (RimeGetStatus(to_session_id(pair.first), &status)) { _LoadSchemaSpecificSettings(pair.first, std::string(status.schema_id)); _LoadAppInlinePreeditSet(pair.first, true); _UpdateInlinePreeditStatus(pair.first); @@ -247,16 +266,17 @@ void RimeWithWeaselHandler::UpdateColorTheme(BOOL darkMode) { RimeFreeStatus(&status); } } - m_ui->style() = m_session_status_map[m_active_session].style; + m_ui->style() = get_session_status(m_active_session).style; } BOOL RimeWithWeaselHandler::ProcessKeyEvent(KeyEvent keyEvent, - UINT session_id, + WeaselSessionId ipc_id, EatLine eat) { DLOG(INFO) << "Process key event: keycode = " << keyEvent.keycode - << ", mask = " << keyEvent.mask << ", session_id = " << session_id; + << ", mask = " << keyEvent.mask << ", ipc_id = " << ipc_id; if (m_disabled) return FALSE; + RimeSessionId session_id = to_session_id(ipc_id); Bool handled = RimeProcessKey(session_id, keyEvent.keycode, expand_ibus_modifier(keyEvent.mask)); if (!handled) { @@ -271,96 +291,99 @@ BOOL RimeWithWeaselHandler::ProcessKeyEvent(KeyEvent keyEvent, RimeSetOption(session_id, "ascii_mode", True); } } - _Respond(session_id, eat); - _UpdateUI(session_id); - m_active_session = session_id; + _Respond(ipc_id, eat); + _UpdateUI(ipc_id); + m_active_session = ipc_id; return (BOOL)handled; } -void RimeWithWeaselHandler::CommitComposition(UINT session_id) { - DLOG(INFO) << "Commit composition: session_id = " << session_id; +void RimeWithWeaselHandler::CommitComposition(WeaselSessionId ipc_id) { + DLOG(INFO) << "Commit composition: ipc_id = " << ipc_id; if (m_disabled) return; - RimeCommitComposition(session_id); - _UpdateUI(session_id); - m_active_session = session_id; + RimeCommitComposition(to_session_id(ipc_id)); + _UpdateUI(ipc_id); + m_active_session = ipc_id; } -void RimeWithWeaselHandler::ClearComposition(UINT session_id) { - DLOG(INFO) << "Clear composition: session_id = " << session_id; +void RimeWithWeaselHandler::ClearComposition(WeaselSessionId ipc_id) { + DLOG(INFO) << "Clear composition: ipc_id = " << ipc_id; if (m_disabled) return; - RimeClearComposition(session_id); - _UpdateUI(session_id); - m_active_session = session_id; + RimeClearComposition(to_session_id(ipc_id)); + _UpdateUI(ipc_id); + m_active_session = ipc_id; } -void RimeWithWeaselHandler::SelectCandidateOnCurrentPage(size_t index, - UINT session_id) { - DLOG(INFO) << "select candidate on current page, session_id = " << session_id +void RimeWithWeaselHandler::SelectCandidateOnCurrentPage( + size_t index, + WeaselSessionId ipc_id) { + DLOG(INFO) << "select candidate on current page, ipc_id = " << ipc_id << ", index = " << index; if (m_disabled) return; RimeApi* api = rime_get_api(); - api->select_candidate_on_current_page(session_id, index); + api->select_candidate_on_current_page(to_session_id(ipc_id), index); } -bool RimeWithWeaselHandler::HighlightCandidateOnCurrentPage(size_t index, - UINT session_id, - EatLine eat) { - DLOG(INFO) << "highlight candidate on current page, session_id = " - << session_id << ", index = " << index; +bool RimeWithWeaselHandler::HighlightCandidateOnCurrentPage( + size_t index, + WeaselSessionId ipc_id, + EatLine eat) { + DLOG(INFO) << "highlight candidate on current page, ipc_id = " << ipc_id + << ", index = " << index; RimeApi* api = rime_get_api(); if (!api) return false; - bool res = api->highlight_candidate_on_current_page(session_id, index); - _Respond(session_id, eat); - _UpdateUI(session_id); + bool res = + api->highlight_candidate_on_current_page(to_session_id(ipc_id), index); + _Respond(ipc_id, eat); + _UpdateUI(ipc_id); return res; } bool RimeWithWeaselHandler::ChangePage(bool backward, - UINT session_id, + WeaselSessionId ipc_id, EatLine eat) { - DLOG(INFO) << "change page, session_id = " << session_id + DLOG(INFO) << "change page, ipc_id = " << ipc_id << (backward ? "backward" : "foreward"); RimeApi* api = rime_get_api(); if (!api) return false; - bool res = api->change_page(session_id, backward); - _Respond(session_id, eat); - _UpdateUI(session_id); + bool res = api->change_page(to_session_id(ipc_id), backward); + _Respond(ipc_id, eat); + _UpdateUI(ipc_id); return res; } -void RimeWithWeaselHandler::FocusIn(DWORD client_caps, UINT session_id) { - DLOG(INFO) << "Focus in: session_id = " << session_id +void RimeWithWeaselHandler::FocusIn(DWORD client_caps, WeaselSessionId ipc_id) { + DLOG(INFO) << "Focus in: ipc_id = " << ipc_id << ", client_caps = " << client_caps; if (m_disabled) return; - _UpdateUI(session_id); - m_active_session = session_id; + _UpdateUI(ipc_id); + m_active_session = ipc_id; } -void RimeWithWeaselHandler::FocusOut(DWORD param, UINT session_id) { - DLOG(INFO) << "Focus out: session_id = " << session_id; +void RimeWithWeaselHandler::FocusOut(DWORD param, WeaselSessionId ipc_id) { + DLOG(INFO) << "Focus out: ipc_id = " << ipc_id; if (m_ui) m_ui->Hide(); m_active_session = 0; } void RimeWithWeaselHandler::UpdateInputPosition(RECT const& rc, - UINT session_id) { + WeaselSessionId ipc_id) { DLOG(INFO) << "Update input position: (" << rc.left << ", " << rc.top - << "), session_id = " << session_id + << "), ipc_id = " << ipc_id << ", m_active_session = " << m_active_session; if (m_ui) m_ui->UpdateInputPosition(rc); if (m_disabled) return; - if (m_active_session != session_id) { - _UpdateUI(session_id); - m_active_session = session_id; + if (m_active_session != ipc_id) { + _UpdateUI(ipc_id); + m_active_session = ipc_id; } } @@ -394,7 +417,8 @@ void RimeWithWeaselHandler::OnNotify(void* context_object, } } -void RimeWithWeaselHandler::_ReadClientInfo(UINT session_id, LPWSTR buffer) { +void RimeWithWeaselHandler::_ReadClientInfo(WeaselSessionId ipc_id, + LPWSTR buffer) { std::string app_name; std::string client_type; // parse request text @@ -420,6 +444,8 @@ void RimeWithWeaselHandler::_ReadClientInfo(UINT session_id, LPWSTR buffer) { line.substr(kClientTypeKey.length()).c_str(), CP_UTF8); } } + RimeStatus& session_status = get_session_status(ipc_id); + RimeSessionId session_id = session_status.session_id; // set app specific options if (!app_name.empty()) { RimeSetProperty(session_id, "client_app", app_name.c_str()); @@ -428,7 +454,7 @@ void RimeWithWeaselHandler::_ReadClientInfo(UINT session_id, LPWSTR buffer) { if (it != m_app_options.end()) { AppOptions& options(m_app_options[it->first]); std::for_each(options.begin(), options.end(), - [session_id](std::pair& pair) { + [ipc_id, this](std::pair& pair) { DLOG(INFO) << "set app option: " << pair.first << " = " << pair.second; RimeSetOption(session_id, pair.first.c_str(), @@ -439,8 +465,8 @@ void RimeWithWeaselHandler::_ReadClientInfo(UINT session_id, LPWSTR buffer) { // ime | tsf RimeSetProperty(session_id, "client_type", client_type.c_str()); // inline preedit - bool inline_preedit = m_session_status_map[session_id].style.inline_preedit && - (client_type == "tsf"); + bool inline_preedit = + session_status.style.inline_preedit && (client_type == "tsf"); RimeSetOption(session_id, "inline_preedit", Bool(inline_preedit)); // show soft cursor on weasel panel but not inline RimeSetOption(session_id, "soft_cursor", Bool(!inline_preedit)); @@ -491,18 +517,20 @@ void RimeWithWeaselHandler::EndMaintenance() { m_session_status_map.clear(); } -void RimeWithWeaselHandler::SetOption(UINT session_id, +void RimeWithWeaselHandler::SetOption(WeaselSessionId ipc_id, const std::string& opt, bool val) { // from no-session client, not actual typing session - if (!session_id) { + if (!ipc_id) { if (m_global_ascii_mode && opt == "ascii_mode") { for (auto& pair : m_session_status_map) - RimeSetOption(pair.first, "ascii_mode", val); - } else - RimeSetOption(m_active_session, opt.c_str(), val); - } else - RimeSetOption(session_id, opt.c_str(), val); + RimeSetOption(to_session_id(pair.first), "ascii_mode", val); + } else { + RimeSetOption(to_session_id(m_active_session), opt.c_str(), val); + } + } else { + RimeSetOption(to_session_id(ipc_id), opt.c_str(), val); + } } void RimeWithWeaselHandler::OnUpdateUI(std::function const& cb) { @@ -518,16 +546,17 @@ bool RimeWithWeaselHandler::_IsDeployerRunning() { return deployer_detected; } -void RimeWithWeaselHandler::_UpdateUI(UINT session_id) { +void RimeWithWeaselHandler::_UpdateUI(WeaselSessionId ipc_id) { Status weasel_status; Context weasel_context; + RimeSessionId session_id = to_session_id(ipc_id); bool is_tsf = _IsSessionTSF(session_id); - if (session_id == 0) + if (ipc_id == 0) weasel_status.disabled = m_disabled; - _GetStatus(weasel_status, session_id, weasel_context); + _GetStatus(weasel_status, ipc_id, weasel_context); if (!is_tsf) { _GetContext(weasel_context, session_id); @@ -536,12 +565,11 @@ void RimeWithWeaselHandler::_UpdateUI(UINT session_id) { if (!m_ui) return; + SessionStatus& session_status = get_session_status(ipc_id); if (RimeGetOption(session_id, "inline_preedit")) - m_session_status_map[session_id].style.client_caps |= - INLINE_PREEDIT_CAPABLE; + session_status.style.client_caps |= INLINE_PREEDIT_CAPABLE; else - m_session_status_map[session_id].style.client_caps &= - ~INLINE_PREEDIT_CAPABLE; + session_status.style.client_caps &= ~INLINE_PREEDIT_CAPABLE; if (weasel_status.composing) { m_ui->Update(weasel_context, weasel_status); @@ -586,7 +614,7 @@ std::wstring _LoadIconSettingFromSchema( } void RimeWithWeaselHandler::_LoadSchemaSpecificSettings( - UINT session_id, + WeaselSessionId ipc_id, const std::string& schema_id) { if (!m_ui) return; @@ -596,7 +624,7 @@ void RimeWithWeaselHandler::_LoadSchemaSpecificSettings( _UpdateShowNotifications(&config); m_ui->style() = m_base_style; _UpdateUIStyle(&config, m_ui, false); - SessionStatus& session_status = m_session_status_map[session_id]; + SessionStatus& session_status = get_session_status(ipc_id); session_status.style = m_ui->style(); // load schema color style config const int BUF_SIZE = 255; @@ -648,57 +676,51 @@ void RimeWithWeaselHandler::_LoadSchemaSpecificSettings( RimeConfigClose(&config); } -void RimeWithWeaselHandler::_LoadAppInlinePreeditSet(UINT session_id, +void RimeWithWeaselHandler::_LoadAppInlinePreeditSet(WeaselSessionId ipc_id, bool ignore_app_name) { + SessionStatus& session_status = get_session_status(ipc_id); + RimeSessionId session_id = session_status.session_id; static char _app_name[50]; RimeGetProperty(session_id, "client_app", _app_name, sizeof(_app_name) - 1); std::string app_name(_app_name); if (!ignore_app_name && m_last_app_name == app_name) return; m_last_app_name = app_name; - SessionStatus& session_status = m_session_status_map[session_id]; bool inline_preedit = session_status.style.inline_preedit; + bool found = false; if (!app_name.empty()) { auto it = m_app_options.find(app_name); if (it != m_app_options.end()) { AppOptions& options(m_app_options[it->first]); - auto pfind = std::make_shared(false); - std::for_each( - options.begin(), options.end(), - [session_id, pfind, inline_preedit, - this](std::pair& pair) { - if (pair.first == "inline_preedit") { - *pfind = true; - RimeSetOption(session_id, pair.first.c_str(), Bool(pair.second)); - m_session_status_map[session_id].style.inline_preedit = - Bool(pair.second); - if (m_session_status_map[session_id].style.inline_preedit != - inline_preedit) - _UpdateInlinePreeditStatus(session_id); - } - }); - if (!(*pfind)) { - goto load_schema_inline; + for (const auto& pair : options) { + if (pair.first == "inline_preedit") { + RimeSetOption(session_id, pair.first.c_str(), Bool(pair.second)); + session_status.style.inline_preedit = Bool(pair.second); + found = true; + break; + } } - } else { - load_schema_inline: - session_status.style.inline_preedit = m_base_style.inline_preedit; - RIME_STRUCT(RimeStatus, status); - if (RimeGetStatus(session_id, &status)) { - std::string schema_id = status.schema_id; - RimeConfig config; - if (!RimeSchemaOpen(schema_id.c_str(), &config)) - return; - Bool inline_preedit = session_status.style.inline_preedit; - if (RimeConfigGetBool(&config, "style/inline_preedit", &inline_preedit)) - session_status.style.inline_preedit = !!inline_preedit; + } + } + if (!found) { + session_status.style.inline_preedit = m_base_style.inline_preedit; + // load from schema. + RIME_STRUCT(RimeStatus, status); + if (RimeGetStatus(session_id, &status)) { + std::string schema_id = status.schema_id; + RimeConfig config; + if (RimeSchemaOpen(schema_id.c_str(), &config)) { + Bool value = False; + if (RimeConfigGetBool(&config, "style/inline_preedit", &value)) { + session_status.style.inline_preedit = value; + } RimeConfigClose(&config); - RimeFreeStatus(&status); - if (session_status.style.inline_preedit != (!!inline_preedit)) - _UpdateInlinePreeditStatus(session_id); } + RimeFreeStatus(&status); } } + if (session_status.style.inline_preedit != inline_preedit) + _UpdateInlinePreeditStatus(ipc_id); } bool RimeWithWeaselHandler::_ShowMessage(Context& ctx, Status& status) { @@ -735,8 +757,8 @@ bool RimeWithWeaselHandler::_ShowMessage(Context& ctx, Status& status) { return m_ui->IsCountingDown(); auto foption = m_show_notifications.find(m_option_name); auto falways = m_show_notifications.find("always"); - if ((!addsession && (foption != m_show_notifications.end() || - falways != m_show_notifications.end())) || + if ((!add_session && (foption != m_show_notifications.end() || + falways != m_show_notifications.end())) || m_message_type == "deploy") { m_ui->Update(ctx, status); if (m_show_notifications_time) @@ -754,11 +776,12 @@ inline std::string _GetLabelText(const std::vector& labels, return wstring_to_string(std::wstring(buffer), CP_UTF8); } -bool RimeWithWeaselHandler::_Respond(UINT session_id, EatLine eat) { +bool RimeWithWeaselHandler::_Respond(WeaselSessionId ipc_id, EatLine eat) { std::set actions; std::list messages; - SessionStatus& session_status = m_session_status_map[session_id]; + SessionStatus& session_status = get_session_status(ipc_id); + RimeSessionId session_id = session_status.session_id; RIME_STRUCT(RimeCommit, commit); if (RimeGetCommit(session_id, &commit)) { actions.insert("commit"); @@ -784,8 +807,9 @@ bool RimeWithWeaselHandler::_Respond(UINT session_id, EatLine eat) { if (m_global_ascii_mode && (session_status.status.is_ascii_mode != status.is_ascii_mode)) { for (auto& pair : m_session_status_map) { - if (pair.first != session_id) - RimeSetOption(pair.first, "ascii_mode", !!status.is_ascii_mode); + if (pair.first != ipc_id) + RimeSetOption(to_session_id(pair.first), "ascii_mode", + !!status.is_ascii_mode); } } session_status.status = status; @@ -1434,8 +1458,10 @@ static void _LoadAppOptions(RimeConfig* config, } void RimeWithWeaselHandler::_GetStatus(Status& stat, - UINT session_id, + WeaselSessionId ipc_id, Context& ctx) { + SessionStatus& session_status = get_session_status(ipc_id); + RimeSessionId session_id = session_status.session_id; RIME_STRUCT(RimeStatus, status); if (RimeGetStatus(session_id, &status)) { std::string schema_id = ""; @@ -1448,21 +1474,19 @@ void RimeWithWeaselHandler::_GetStatus(Status& stat, stat.disabled = !!status.is_disabled; stat.full_shape = !!status.is_full_shape; if (schema_id != m_last_schema_id) { - m_session_status_map[session_id].__synced = false; + session_status.__synced = false; m_last_schema_id = schema_id; if (schema_id != ".default") { // don't load for schema select menu - bool inline_preedit = - m_session_status_map[session_id].style.inline_preedit; - _LoadSchemaSpecificSettings(session_id, schema_id); - _LoadAppInlinePreeditSet(session_id, true); - if (m_session_status_map[session_id].style.inline_preedit != - inline_preedit) + bool inline_preedit = session_status.style.inline_preedit; + _LoadSchemaSpecificSettings(ipc_id, schema_id); + _LoadAppInlinePreeditSet(ipc_id, true); + if (session_status.style.inline_preedit != inline_preedit) _UpdateInlinePreeditStatus( - session_id); // in case of inline_preedit set in schema + ipc_id); // in case of inline_preedit set in schema _RefreshTrayIcon( - session_id, + _s(ipc_id), _UpdateUICallback); // refresh icon after schema changed - m_ui->style() = m_session_status_map[session_id].style; + m_ui->style() = session_status.style; if (m_show_notifications.find("schema") != m_show_notifications.end() && m_show_notifications_time > 0) { ctx.aux.str = stat.schema_name; @@ -1476,7 +1500,7 @@ void RimeWithWeaselHandler::_GetStatus(Status& stat, } void RimeWithWeaselHandler::_GetContext(Context& weasel_context, - UINT session_id) { + RimeSessionId session_id) { RIME_STRUCT(RimeContext, ctx); if (RimeGetContext(session_id, &ctx)) { if (ctx.composition.length > 0) { @@ -1501,19 +1525,21 @@ void RimeWithWeaselHandler::_GetContext(Context& weasel_context, } } -bool RimeWithWeaselHandler::_IsSessionTSF(UINT session_id) { +bool RimeWithWeaselHandler::_IsSessionTSF(RimeSessionId session_id) { static char client_type[20] = {0}; RimeGetProperty(session_id, "client_type", client_type, sizeof(client_type) - 1); return std::string(client_type) == "tsf"; } -void RimeWithWeaselHandler::_UpdateInlinePreeditStatus(UINT session_id) { +void RimeWithWeaselHandler::_UpdateInlinePreeditStatus(WeaselSessionId ipc_id) { if (!m_ui) return; + SessionStatus& session_status = get_session_status(ipc_id); + RimeSessionId session_id = session_status.session_id; // set inline_preedit option - bool inline_preedit = m_session_status_map[session_id].style.inline_preedit && - _IsSessionTSF(session_id); + bool inline_preedit = + session_status.style.inline_preedit && _IsSessionTSF(session_id); RimeSetOption(session_id, "inline_preedit", Bool(inline_preedit)); // show soft cursor on weasel panel but not inline RimeSetOption(session_id, "soft_cursor", Bool(!inline_preedit)); diff --git a/WeaselDeployer/SwitcherSettingsDialog.cpp b/WeaselDeployer/SwitcherSettingsDialog.cpp index 79dcba628..8ba288909 100644 --- a/WeaselDeployer/SwitcherSettingsDialog.cpp +++ b/WeaselDeployer/SwitcherSettingsDialog.cpp @@ -79,7 +79,10 @@ LRESULT SwitcherSettingsDialog::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { schema_list_.SubclassWindow(GetDlgItem(IDC_SCHEMA_LIST)); schema_list_.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); - schema_list_.AddColumn(L"方案名稱", 0); + + CString schema_name; + schema_name.LoadStringW(IDS_STR_SCHEMA_NAME); + schema_list_.AddColumn(schema_name, 0); CRect rc; schema_list_.GetClientRect(&rc); schema_list_.SetColumnWidth(0, rc.Width() - 20); @@ -104,10 +107,25 @@ LRESULT SwitcherSettingsDialog::OnClose(UINT, WPARAM, LPARAM, BOOL&) { return 0; } +BOOL is_wow64() { + DWORD errorCode; + if (GetSystemWow64DirectoryW(NULL, 0) == 0) + if ((errorCode = GetLastError()) == ERROR_CALL_NOT_IMPLEMENTED) + return FALSE; + else + ExitProcess((UINT)errorCode); + else + return TRUE; +} + LRESULT SwitcherSettingsDialog::OnGetSchemata(WORD, WORD, HWND hWndCtl, BOOL&) { HKEY hKey; - LSTATUS ret = - RegOpenKey(HKEY_LOCAL_MACHINE, _T("Software\\Rime\\Weasel"), &hKey); + std::wstring hPath; + if (is_wow64()) + hPath = _T("Software\\WOW6432Node\\Rime\\Weasel"); + else + hPath = _T("Software\\Rime\\Weasel"); + LSTATUS ret = RegOpenKey(HKEY_LOCAL_MACHINE, hPath.c_str(), &hKey); if (ret == ERROR_SUCCESS) { WCHAR value[MAX_PATH]; DWORD len = sizeof(value); diff --git a/WeaselDeployer/WeaselDeployer.rc b/WeaselDeployer/WeaselDeployer.rc index 62eb386c6..87b1611c7 100644 Binary files a/WeaselDeployer/WeaselDeployer.rc and b/WeaselDeployer/WeaselDeployer.rc differ diff --git a/WeaselDeployer/WeaselDeployer.vcxproj b/WeaselDeployer/WeaselDeployer.vcxproj index 2c12c00a0..5d69c6b5d 100644 --- a/WeaselDeployer/WeaselDeployer.vcxproj +++ b/WeaselDeployer/WeaselDeployer.vcxproj @@ -5,15 +5,24 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B} Win32Proj WeaselDeployer + 10.0 @@ -23,6 +32,12 @@ Unicode $(PLATFORM_TOOLSET) + + Application + true + Unicode + $(PLATFORM_TOOLSET) + Application false @@ -30,21 +45,42 @@ Unicode $(PLATFORM_TOOLSET) + + Application + false + true + Unicode + $(PLATFORM_TOOLSET) + + + + + + + + true + $(SolutionDir)output\Win32\ + + true $(SolutionDir)output\ + false + $(SolutionDir)output\Win32\ + + false $(SolutionDir)output\ @@ -63,8 +99,33 @@ true $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) rime.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)output\Win32\$(ProjectName)$(TargetExt) + true + + + PerMonitorHighDPIAware + + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + /Zc:threadSafeInit- %(AdditionalOptions) + + + Windows + true + $(SolutionDir)\lib64;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) + rime.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) $(SolutionDir)output\$(ProjectName)$(TargetExt) + + PerMonitorHighDPIAware + @@ -83,8 +144,34 @@ true true true - rime.lib;rime.lib;%(AdditionalDependencies) + rime.lib;%(AdditionalDependencies) $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) + $(SolutionDir)output\Win32\$(ProjectName)$(TargetExt) + true + + + PerMonitorHighDPIAware + + + + + Level3 + Use + Disabled + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)\include;$(BOOST_ROOT);$(SolutionDir)\librime\include + MultiThreaded + /Zc:threadSafeInit- %(AdditionalOptions) + + + Windows + true + true + true + rime.lib;%(AdditionalDependencies) + $(SolutionDir)\lib64;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) $(SolutionDir)output\$(ProjectName)$(TargetExt) @@ -108,7 +195,9 @@ Create + Create Create + Create @@ -130,4 +219,4 @@ - \ No newline at end of file + diff --git a/WeaselDeployer/resource.h b/WeaselDeployer/resource.h index cbdfde62c..e02e07bfd 100644 Binary files a/WeaselDeployer/resource.h and b/WeaselDeployer/resource.h differ diff --git a/WeaselDeployer/stdafx.h b/WeaselDeployer/stdafx.h index 8cd64e95c..b5b52e439 100644 --- a/WeaselDeployer/stdafx.h +++ b/WeaselDeployer/stdafx.h @@ -23,3 +23,6 @@ #include #include +#ifdef _UNICODE +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif diff --git a/WeaselIME/WeaselIME.vcxproj b/WeaselIME/WeaselIME.vcxproj index 161bb4820..07ff2cc68 100644 --- a/WeaselIME/WeaselIME.vcxproj +++ b/WeaselIME/WeaselIME.vcxproj @@ -310,6 +310,9 @@ $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -437,6 +440,9 @@ + + PerMonitorHighDPIAware + @@ -563,6 +569,9 @@ $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -589,6 +598,9 @@ $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -624,6 +636,9 @@ $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -656,6 +671,9 @@ $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -692,6 +710,9 @@ + + PerMonitorHighDPIAware + @@ -725,6 +746,9 @@ + + PerMonitorHighDPIAware + diff --git a/WeaselServer/WeaselServer.rc b/WeaselServer/WeaselServer.rc index f73b083a5..06276d4e7 100644 Binary files a/WeaselServer/WeaselServer.rc and b/WeaselServer/WeaselServer.rc differ diff --git a/WeaselServer/WeaselServer.vcxproj b/WeaselServer/WeaselServer.vcxproj index 1f8dafa51..30e1c3310 100644 --- a/WeaselServer/WeaselServer.vcxproj +++ b/WeaselServer/WeaselServer.vcxproj @@ -70,6 +70,7 @@ {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D} Win32Proj WeaselServer + 10.0 @@ -207,7 +208,7 @@ true - $(SolutionDir)output\ + $(SolutionDir)output\Win32 true @@ -220,7 +221,7 @@ true - $(SolutionDir)output\ + $(SolutionDir)output\Win32\ $(SolutionDir)output\ @@ -285,12 +286,16 @@ true Windows MachineX86 - $(SolutionDir)\output\$(ProjectName).exe + $(SolutionDir)\output\Win32\$(ProjectName).exe + true + + PerMonitorHighDPIAware + @@ -365,12 +370,15 @@ imm32.lib;usp10.lib;rime.lib;%(AdditionalDependencies) - $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) + $(SolutionDir)\lib64;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) true Windows MachineX64 $(SolutionDir)\output\$(ProjectName).exe + + PerMonitorHighDPIAware + @@ -438,12 +446,13 @@ imm32.lib;usp10.lib;rime.lib;%(AdditionalDependencies) - $(SolutionDir)\output\$(ProjectName).exe + $(SolutionDir)\output\Win32\$(ProjectName).exe $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) Windows MachineX86 true UseLinkTimeCodeGeneration + true @@ -533,7 +542,7 @@ imm32.lib;usp10.lib;rime.lib;%(AdditionalDependencies) $(SolutionDir)\output\$(ProjectName).exe - $(SolutionDir)\lib;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) + $(SolutionDir)\lib64;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) false Windows MachineX64 @@ -542,6 +551,9 @@ + + PerMonitorHighDPIAware + @@ -932,4 +944,4 @@ - \ No newline at end of file + diff --git a/WeaselServer/WeaselServerApp.h b/WeaselServer/WeaselServerApp.h index a214c1921..2e6b7461b 100644 --- a/WeaselServer/WeaselServerApp.h +++ b/WeaselServer/WeaselServerApp.h @@ -17,19 +17,20 @@ namespace fs = boost::filesystem; class WeaselServerApp { public: static bool execute(const fs::path& cmd, const std::wstring& args) { - return (int)ShellExecuteW(NULL, NULL, cmd.c_str(), args.c_str(), NULL, - SW_SHOWNORMAL) > 32; + return (uintptr_t)ShellExecuteW(NULL, NULL, cmd.c_str(), args.c_str(), NULL, + SW_SHOWNORMAL) > 32; } static bool explore(const fs::path& path) { std::wstring quoted_path(L"\"" + path.wstring() + L"\""); - return (int)ShellExecuteW(NULL, L"open", L"explorer", quoted_path.c_str(), - NULL, SW_SHOWNORMAL) > 32; + return (uintptr_t)ShellExecuteW(NULL, L"open", L"explorer", + quoted_path.c_str(), NULL, + SW_SHOWNORMAL) > 32; } static bool open(const fs::path& path) { - return (int)ShellExecuteW(NULL, L"open", path.c_str(), NULL, NULL, - SW_SHOWNORMAL) > 32; + return (uintptr_t)ShellExecuteW(NULL, L"open", path.c_str(), NULL, NULL, + SW_SHOWNORMAL) > 32; } static bool check_update() { diff --git a/WeaselSetup/WeaselSetup.rc b/WeaselSetup/WeaselSetup.rc index 3082ae8eb..dd86daff1 100644 Binary files a/WeaselSetup/WeaselSetup.rc and b/WeaselSetup/WeaselSetup.rc differ diff --git a/WeaselTSF/WeaselTSF.rc b/WeaselTSF/WeaselTSF.rc index a3c511da6..bdc7a3f7e 100644 Binary files a/WeaselTSF/WeaselTSF.rc and b/WeaselTSF/WeaselTSF.rc differ diff --git a/WeaselTSF/WeaselTSF.vcxproj b/WeaselTSF/WeaselTSF.vcxproj index a9ae64a48..52b9c6567 100644 --- a/WeaselTSF/WeaselTSF.vcxproj +++ b/WeaselTSF/WeaselTSF.vcxproj @@ -308,6 +308,9 @@ $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -332,6 +335,7 @@ $(SolutionDir)\include + ARM64;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -360,6 +364,7 @@ $(SolutionDir)\include + _UNICODE;UNICODE;%(PreprocessorDefinitions) PerMonitorHighDPIAware @@ -390,6 +395,7 @@ $(SolutionDir)\include + ARM64;_UNICODE;UNICODE;%(PreprocessorDefinitions) PerMonitorHighDPIAware @@ -423,6 +429,9 @@ WEASEL_HANT;%(PreprocessorDefinitions) $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -448,7 +457,7 @@ Usp10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - WEASEL_HANT;%(PreprocessorDefinitions) + ARM64;WEASEL_HANT;%(PreprocessorDefinitions) $(SolutionDir)\include @@ -505,6 +514,7 @@ $(SolutionDir)\include + ARM64;%(PreprocessorDefinitions) @@ -535,7 +545,11 @@ $(SolutionDir)\include + WIN64;_UNICODE;UNICODE;%(PreprocessorDefinitions) + + PerMonitorHighDPIAware + @@ -562,7 +576,11 @@ $(SolutionDir)\include + ARM;_UNICODE;UNICODE;%(PreprocessorDefinitions) + + PerMonitorHighDPIAware + @@ -593,7 +611,11 @@ $(SolutionDir)\include + WIN64;_UNICODE;UNICODE;%(PreprocessorDefinitions) + + PerMonitorHighDPIAware + @@ -621,7 +643,11 @@ $(SolutionDir)\include + ARM;_UNICODE;UNICODE;%(PreprocessorDefinitions) + + PerMonitorHighDPIAware + @@ -651,9 +677,12 @@ Usp10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - WEASEL_HANT;%(PreprocessorDefinitions) + WIN64;WEASEL_HANT;%(PreprocessorDefinitions) $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -680,9 +709,12 @@ Usp10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - WEASEL_HANT;%(PreprocessorDefinitions) + ARM;WEASEL_HANT;%(PreprocessorDefinitions) $(SolutionDir)\include + + PerMonitorHighDPIAware + @@ -713,6 +745,7 @@ $(SolutionDir)\include + WIN64;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -741,6 +774,7 @@ $(SolutionDir)\include + ARM;_UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -868,4 +902,4 @@ - \ No newline at end of file + diff --git a/build.bat b/build.bat index 32f0c6585..b1a3524b8 100644 --- a/build.bat +++ b/build.bat @@ -6,11 +6,43 @@ if not exist env.bat copy env.bat.template env.bat if exist env.bat call env.bat -if not defined WEASEL_VERSION set WEASEL_VERSION=0.15.0 if not defined WEASEL_BUILD set WEASEL_BUILD=0 if not defined WEASEL_ROOT set WEASEL_ROOT=%CD% +if not defined VERSION_MAJOR set VERSION_MAJOR=0 +if not defined VERSION_MINOR set VERSION_MINOR=15 +if not defined VERSION_PATCH set VERSION_PATCH=0 +if not defined WEASEL_VERSION set WEASEL_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH% + +rem check if git is installed and available, then get the short commit id of head +git --version >nul 2>&1 +if not errorlevel 1 ( + rem get short commmit id of head + for /F %%i in ('git rev-parse --short HEAD') do (set commitid=%%i) +) + +if not defined RELEASE_BUILD ( + if defined commitid ( + rem if git is available and RELEASE_BUILD is not defined, then use commitid in the PROCDUCT_VERSION + rem for local build with git installed, when RELASE_BUILD usually not defined during local build + rem or github action nightly build/commit ci build, when RELEASE_BUILD is not defined, and git installed + if not defined PRODUCT_VERSION set PRODUCT_VERSION="%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%-%commitid%" + ) else ( + rem if git is not available, then use pure number in the PRODUCT_VERSION + rem for local build without git, when RELEASE_BUILD usually not defined during local build + if not defined PRODUCT_VERSION set PRODUCT_VERSION="%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%WEASEL_BUILD%" + ) +) else ( + rem if RELEASE_BUILD is defined, then use pure number in the PRODUCT_VERSION + rem this usually happens in github action release build + if not defined PRODUCT_VERSION set PRODUCT_VERSION="%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%WEASEL_BUILD%" +) +rem set FILE_VERSION always to the same as PRODUCT_VERSION when RELEASE_BUILD +if not defined FILE_VERSION set FILE_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%WEASEL_BUILD% + echo WEASEL_VERSION=%WEASEL_VERSION% +echo FILE_VERSION=%FILE_VERSION% +echo PRODUCT_VERSION=%PRODUCT_VERSION% echo WEASEL_BUILD=%WEASEL_BUILD% echo WEASEL_ROOT=%WEASEL_ROOT% echo WEASEL_BUNDLED_RECIPES=%WEASEL_BUNDLED_RECIPES% @@ -21,6 +53,7 @@ if defined BOOST_ROOT ( ) echo Error: Boost not found! Please set BOOST_ROOT in env.bat. exit /b 1 + :boost_found echo BOOST_ROOT=%BOOST_ROOT% echo. @@ -49,40 +82,41 @@ set build_weasel=0 set build_installer=0 set build_arm64=0 +rem parse the command line options :parse_cmdline_options -if "%1" == "" goto end_parsing_cmdline_options -if "%1" == "debug" ( - set build_config=Debug - set boost_build_variant=debug - set rime_build_variant=debug -) -if "%1" == "release" ( - set build_config=Release - set boost_build_variant=release - set rime_build_variant=release -) -if "%1" == "rebuild" set build_option=/t:Rebuild -if "%1" == "boost" set build_boost=1 -if "%1" == "data" set build_data=1 -if "%1" == "opencc" set build_opencc=1 -if "%1" == "hant" set build_hant=1 -if "%1" == "rime" set build_rime=1 -if "%1" == "librime" set build_rime=1 -if "%1" == "weasel" set build_weasel=1 -if "%1" == "installer" set build_installer=1 -if "%1" == "arm64" set build_arm64=1 -if "%1" == "all" ( - set build_boost=1 - set build_data=1 - set build_opencc=1 - set build_hant=1 - set build_rime=1 - set build_weasel=1 - set build_installer=1 - set build_arm64=1 -) -shift -goto parse_cmdline_options + if "%1" == "" goto end_parsing_cmdline_options + if "%1" == "debug" ( + set build_config=Debug + set boost_build_variant=debug + set rime_build_variant=debug + ) + if "%1" == "release" ( + set build_config=Release + set boost_build_variant=release + set rime_build_variant=release + ) + if "%1" == "rebuild" set build_option=/t:Rebuild + if "%1" == "boost" set build_boost=1 + if "%1" == "data" set build_data=1 + if "%1" == "opencc" set build_opencc=1 + if "%1" == "hant" set build_hant=1 + if "%1" == "rime" set build_rime=1 + if "%1" == "librime" set build_rime=1 + if "%1" == "weasel" set build_weasel=1 + if "%1" == "installer" set build_installer=1 + if "%1" == "arm64" set build_arm64=1 + if "%1" == "all" ( + set build_boost=1 + set build_data=1 + set build_opencc=1 + set build_hant=1 + set build_rime=1 + set build_weasel=1 + set build_installer=1 + set build_arm64=1 + ) + shift + goto parse_cmdline_options :end_parsing_cmdline_options if %build_weasel% == 0 ( @@ -93,42 +127,49 @@ if %build_rime% == 0 ( set build_weasel=1 ))))) +rem quit WeaselServer.exe before building cd /d %WEASEL_ROOT% if exist output\weaselserver.exe ( output\weaselserver.exe /q ) +rem build booost if %build_boost% == 1 ( call :build_boost if errorlevel 1 exit /b 1 cd /d %WEASEL_ROOT% ) +rem ------------------------------------------------------------------------- +rem build librime x64 and Win32 if %build_rime% == 1 ( if not exist librime\build.bat ( git submodule update --init --recursive ) - cd %WEASEL_ROOT%\librime - if not exist env.bat ( - copy %WEASEL_ROOT%\env.bat env.bat - ) - if not exist lib\opencc.lib ( - call build.bat deps %rime_build_variant% - if errorlevel 1 goto error + rem clean cache before building + for %%a in ( build dist lib ^ + deps\glog\build ^ + deps\googletest\build ^ + deps\leveldb\build ^ + deps\marisa-trie\build ^ + deps\opencc\build ^ + deps\yaml-cpp\build ) do ( + if exist %%a rd /s /q %%a ) - call build.bat %rime_build_variant% - if errorlevel 1 goto error -cd %WEASEL_ROOT% - copy /Y librime\dist\include\rime_*.h include\ - if errorlevel 1 goto error - copy /Y librime\dist\lib\rime.lib lib\ - if errorlevel 1 goto error - copy /Y librime\dist\lib\rime.dll output\ - if errorlevel 1 goto error + rem build x64 librime + set ARCH=x64 + call :build_librime_platform x64 %WEASEL_ROOT%\lib64 %WEASEL_ROOT%\output + rem build Win32 librime + set ARCH=Win32 + call :build_librime_platform Win32 %WEASEL_ROOT%\lib %WEASEL_ROOT%\output\Win32 + rem clean the modified file + rem git checkout . + rem git submodule foreach git checkout . ) +rem ------------------------------------------------------------------------- if %build_weasel% == 1 ( if not exist output\data\essay.txt ( set build_data=1 @@ -195,85 +236,152 @@ if %build_installer% == 1 ( /DWEASEL_VERSION=%WEASEL_VERSION% ^ /DWEASEL_BUILD=%WEASEL_BUILD% ^ output\install.nsi + if defined commitid ( + move output\archives\weasel-%WEASEL_VERSION%.%WEASEL_BUILD%-installer.exe output\archives\weasel-%WEASEL_VERSION%-%commitid%-installer.exe + ) if errorlevel 1 goto error ) goto end +rem ------------------------------------------------------------------------- +rem build boost :build_boost - -set BJAM_OPTIONS_COMMON=-j%NUMBER_OF_PROCESSORS%^ - --with-filesystem^ - --with-json^ - --with-locale^ - --with-regex^ - --with-serialization^ - --with-system^ - --with-thread^ - define=BOOST_USE_WINAPI_VERSION=0x0603^ - toolset=%BJAM_TOOLSET%^ - link=static^ - runtime-link=static^ - --build-type=complete - -set BJAM_OPTIONS_X86=%BJAM_OPTIONS_COMMON%^ - architecture=x86^ - address-model=32 - -set BJAM_OPTIONS_X64=%BJAM_OPTIONS_COMMON%^ - architecture=x86^ - address-model=64 - -set BJAM_OPTIONS_ARM32=%BJAM_OPTIONS_COMMON%^ - define=BOOST_USE_WINAPI_VERSION=0x0A00^ - architecture=arm^ - address-model=32 - -set BJAM_OPTIONS_ARM64=%BJAM_OPTIONS_COMMON%^ - define=BOOST_USE_WINAPI_VERSION=0x0A00^ - architecture=arm^ - address-model=64 - -cd /d %BOOST_ROOT% -if not exist b2.exe call bootstrap.bat -if errorlevel 1 goto error -b2 %BJAM_OPTIONS_X86% stage %BOOST_COMPILED_LIBS% -if errorlevel 1 goto error -b2 %BJAM_OPTIONS_X64% stage %BOOST_COMPILED_LIBS% -if errorlevel 1 goto error - -if %build_arm64% == 1 ( - b2 %BJAM_OPTIONS_ARM32% stage %BOOST_COMPILED_LIBS% + set BJAM_OPTIONS_COMMON=-j%NUMBER_OF_PROCESSORS%^ + --with-filesystem^ + --with-json^ + --with-locale^ + --with-regex^ + --with-serialization^ + --with-system^ + --with-thread^ + define=BOOST_USE_WINAPI_VERSION=0x0603^ + toolset=%BJAM_TOOLSET%^ + link=static^ + runtime-link=static^ + --build-type=complete + + set BJAM_OPTIONS_X86=%BJAM_OPTIONS_COMMON%^ + architecture=x86^ + address-model=32 + + set BJAM_OPTIONS_X64=%BJAM_OPTIONS_COMMON%^ + architecture=x86^ + address-model=64 + + set BJAM_OPTIONS_ARM32=%BJAM_OPTIONS_COMMON%^ + define=BOOST_USE_WINAPI_VERSION=0x0A00^ + architecture=arm^ + address-model=32 + + set BJAM_OPTIONS_ARM64=%BJAM_OPTIONS_COMMON%^ + define=BOOST_USE_WINAPI_VERSION=0x0A00^ + architecture=arm^ + address-model=64 + + cd /d %BOOST_ROOT% + if not exist b2.exe call bootstrap.bat if errorlevel 1 goto error - b2 %BJAM_OPTIONS_ARM64% stage %BOOST_COMPILED_LIBS% + b2 %BJAM_OPTIONS_X86% stage %BOOST_COMPILED_LIBS% if errorlevel 1 goto error -) -exit /b + b2 %BJAM_OPTIONS_X64% stage %BOOST_COMPILED_LIBS% + if errorlevel 1 goto error + + if %build_arm64% == 1 ( + b2 %BJAM_OPTIONS_ARM32% stage %BOOST_COMPILED_LIBS% + if errorlevel 1 goto error + b2 %BJAM_OPTIONS_ARM64% stage %BOOST_COMPILED_LIBS% + if errorlevel 1 goto error + ) + exit /b +rem --------------------------------------------------------------------------- :build_data -copy %WEASEL_ROOT%\LICENSE.txt output\ -copy %WEASEL_ROOT%\README.md output\README.txt -copy %WEASEL_ROOT%\plum\rime-install.bat output\ -set plum_dir=plum -set rime_dir=output/data -set WSLENV=plum_dir:rime_dir -bash plum/rime-install %WEASEL_BUNDLED_RECIPES% -if errorlevel 1 goto error -exit /b + copy %WEASEL_ROOT%\LICENSE.txt output\ + copy %WEASEL_ROOT%\README.md output\README.txt + copy %WEASEL_ROOT%\plum\rime-install.bat output\ + set plum_dir=plum + set rime_dir=output/data + set WSLENV=plum_dir:rime_dir + bash plum/rime-install %WEASEL_BUNDLED_RECIPES% + if errorlevel 1 goto error + exit /b +rem --------------------------------------------------------------------------- :build_opencc_data -if not exist %WEASEL_ROOT%\librime\share\opencc\TSCharacters.ocd2 ( + if not exist %WEASEL_ROOT%\librime\share\opencc\TSCharacters.ocd2 ( + cd %WEASEL_ROOT%\librime + call build.bat deps %rime_build_variant% + if errorlevel 1 goto error + ) + cd %WEASEL_ROOT% + if not exist output\data\opencc mkdir output\data\opencc + copy %WEASEL_ROOT%\librime\share\opencc\*.* output\data\opencc\ + if errorlevel 1 goto error + exit /b + +rem --------------------------------------------------------------------------- +rem %1 : ARCH +rem %2 : push | pop , push to backup when pop to restore +:stash_build + pushd %WEASEL_ROOT%\librime + for %%a in ( build dist lib ^ + deps\glog\build ^ + deps\googletest\build ^ + deps\leveldb\build ^ + deps\marisa-trie\build ^ + deps\opencc\build ^ + deps\yaml-cpp\build ) do ( + if "%2"=="push" ( + if exist %%a move %%a %%a_%1 + ) + if "%2"=="pop" ( + if exist %%a_%1 move %%a_%1 %%a + ) + ) + popd + exit /b + +rem --------------------------------------------------------------------------- +rem %1 : ARCH +rem %2 : target_path of rime.lib, base %WEASEL_ROOT% or abs path +rem %3 : target_path of rime.dll, base %WEASEL_ROOT% or abs path +:build_librime_platform + rem restore backuped %1 build + call :stash_build %1 pop + + cd %WEASEL_ROOT%\librime + if not exist env.bat ( + copy %WEASEL_ROOT%\env.bat env.bat + ) + if not exist lib\opencc.lib ( + call build.bat deps %rime_build_variant% + if errorlevel 1 ( + call :stash_build %1 push + goto error + ) + ) + call build.bat %rime_build_variant% + if errorlevel 1 ( + call :stash_build %1 push + goto error + ) + cd %WEASEL_ROOT%\librime - call build.bat deps %rime_build_variant% + call :stash_build %1 push + + copy /Y %WEASEL_ROOT%\librime\dist_%1\include\rime_*.h %WEASEL_ROOT%\include\ + if errorlevel 1 goto error + copy /Y %WEASEL_ROOT%\librime\dist_%1\lib\rime.lib %2\ + if errorlevel 1 goto error + copy /Y %WEASEL_ROOT%\librime\dist_%1\lib\rime.dll %3\ if errorlevel 1 goto error -) -cd %WEASEL_ROOT% -if not exist output\data\opencc mkdir output\data\opencc -copy %WEASEL_ROOT%\librime\share\opencc\*.* output\data\opencc\ -if errorlevel 1 goto error -exit /b + + exit /b +rem --------------------------------------------------------------------------- :error + echo error building weasel... :end diff --git a/env.vs2019.bat b/env.vs2019.bat index e01e3dc94..fd32a0f93 100644 --- a/env.vs2019.bat +++ b/env.vs2019.bat @@ -6,7 +6,7 @@ rem REQUIRED: path to Boost source directory if not defined BOOST_ROOT set BOOST_ROOT=%WEASEL_ROOT%\deps\boost_1_78_0 rem OPTIONAL: architecture, Visual Studio version and platform toolset -set ARCH=Win32 +rem set ARCH=Win32 set BJAM_TOOLSET=msvc-14.2 set CMAKE_GENERATOR="Visual Studio 16 2019" set PLATFORM_TOOLSET=v142 diff --git a/env.vs2022.bat b/env.vs2022.bat index f289aa026..4ed3bf11a 100644 --- a/env.vs2022.bat +++ b/env.vs2022.bat @@ -6,7 +6,7 @@ rem REQUIRED: path to Boost source directory if not defined BOOST_ROOT set BOOST_ROOT=%WEASEL_ROOT%\deps\boost_1_78_0 rem OPTIONAL: architecture, Visual Studio version and platform toolset -set ARCH=Win32 +rem set ARCH=Win32 set BJAM_TOOLSET=msvc-14.3 set CMAKE_GENERATOR="Visual Studio 17 2022" set PLATFORM_TOOLSET=v143 diff --git a/github.install.bat b/github.install.bat index 3bd54cf13..2e2cad74e 100644 --- a/github.install.bat +++ b/github.install.bat @@ -7,16 +7,25 @@ set rime_version=1.10.0 set download_archive=rime-295cb2a-Windows-msvc.7z set download_archive_deps=rime-deps-295cb2a-Windows-msvc.7z +set download_archive_x64=rime-295cb2a-Windows-clang.7z +set download_archive_deps_x64=rime-deps-295cb2a-Windows-clang.7z curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive% curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive_deps% +curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive_x64% +curl -LO https://github.com/rime/librime/releases/download/%rime_version%/%download_archive_deps_x64% 7z x %download_archive% * -olibrime\ -y 7z x %download_archive_deps% * -olibrime\ -y +7z x %download_archive_x64% * -olibrime_x64\ -y +7z x %download_archive_deps_x64% * -olibrime_x64\ -y copy /Y librime\dist\include\rime_*.h include\ copy /Y librime\dist\lib\rime.lib lib\ -copy /Y librime\dist\lib\rime.dll output\ +copy /Y librime\dist\lib\rime.dll output\Win32\ + +copy /Y librime_x64\dist\lib\rime.lib lib64\ +copy /Y librime_x64\dist\lib\rime.dll output\ if not exist output\data\opencc mkdir output\data\opencc copy /Y librime\share\opencc\*.* output\data\opencc\ diff --git a/include/RimeWithWeasel.h b/include/RimeWithWeasel.h index 1d0c7b6a5..6fb0a4cab 100644 --- a/include/RimeWithWeasel.h +++ b/include/RimeWithWeasel.h @@ -20,40 +20,46 @@ struct CaseInsensitiveCompare { typedef std::map AppOptions; typedef std::map AppOptionsByAppName; + struct SessionStatus { - SessionStatus() : style(weasel::UIStyle()), __synced(false) { + SessionStatus() : style(weasel::UIStyle()), __synced(false), session_id(0) { RIME_STRUCT(RimeStatus, status); } weasel::UIStyle style; RimeStatus status; bool __synced; + RimeSessionId session_id; }; -typedef std::map SessionStatusMap; +typedef std::map SessionStatusMap; +typedef DWORD WeaselSessionId; class RimeWithWeaselHandler : public weasel::RequestHandler { public: RimeWithWeaselHandler(weasel::UI* ui); virtual ~RimeWithWeaselHandler(); virtual void Initialize(); virtual void Finalize(); - virtual UINT FindSession(UINT session_id); - virtual UINT AddSession(LPWSTR buffer, EatLine eat = 0); - virtual UINT RemoveSession(UINT session_id); + virtual DWORD FindSession(WeaselSessionId ipc_id); + virtual DWORD AddSession(LPWSTR buffer, EatLine eat = 0); + virtual DWORD RemoveSession(WeaselSessionId ipc_id); virtual BOOL ProcessKeyEvent(weasel::KeyEvent keyEvent, - UINT session_id, + WeaselSessionId ipc_id, EatLine eat); - virtual void CommitComposition(UINT session_id); - virtual void ClearComposition(UINT session_id); - virtual void SelectCandidateOnCurrentPage(size_t index, UINT session_id); + virtual void CommitComposition(WeaselSessionId ipc_id); + virtual void ClearComposition(WeaselSessionId ipc_id); + virtual void SelectCandidateOnCurrentPage(size_t index, + WeaselSessionId ipc_id); virtual bool HighlightCandidateOnCurrentPage(size_t index, - UINT session_id, + WeaselSessionId ipc_id, EatLine eat); - virtual bool ChangePage(bool backward, UINT session_id, EatLine eat); - virtual void FocusIn(DWORD param, UINT session_id); - virtual void FocusOut(DWORD param, UINT session_id); - virtual void UpdateInputPosition(RECT const& rc, UINT session_id); + virtual bool ChangePage(bool backward, WeaselSessionId ipc_id, EatLine eat); + virtual void FocusIn(DWORD param, WeaselSessionId ipc_id); + virtual void FocusOut(DWORD param, WeaselSessionId ipc_id); + virtual void UpdateInputPosition(RECT const& rc, WeaselSessionId ipc_id); virtual void StartMaintenance(); virtual void EndMaintenance(); - virtual void SetOption(UINT session_id, const std::string& opt, bool val); + virtual void SetOption(WeaselSessionId ipc_id, + const std::string& opt, + bool val); virtual void UpdateColorTheme(BOOL darkMode); void OnUpdateUI(std::function const& cb); @@ -61,24 +67,37 @@ class RimeWithWeaselHandler : public weasel::RequestHandler { private: void _Setup(); bool _IsDeployerRunning(); - void _UpdateUI(UINT session_id); - void _LoadSchemaSpecificSettings(UINT session_id, + void _UpdateUI(WeaselSessionId ipc_id); + void _LoadSchemaSpecificSettings(WeaselSessionId ipc_id, const std::string& schema_id); - void _LoadAppInlinePreeditSet(UINT session_id, bool ignore_app_name = false); + void _LoadAppInlinePreeditSet(WeaselSessionId ipc_id, + bool ignore_app_name = false); bool _ShowMessage(weasel::Context& ctx, weasel::Status& status); - bool _Respond(UINT session_id, EatLine eat); - void _ReadClientInfo(UINT session_id, LPWSTR buffer); + bool _Respond(WeaselSessionId ipc_id, EatLine eat); + void _ReadClientInfo(WeaselSessionId ipc_id, LPWSTR buffer); void _GetCandidateInfo(weasel::CandidateInfo& cinfo, RimeContext& ctx); - void _GetStatus(weasel::Status& stat, UINT session_id, weasel::Context& ctx); - void _GetContext(weasel::Context& ctx, UINT session_id); + void _GetStatus(weasel::Status& stat, + WeaselSessionId ipc_id, + weasel::Context& ctx); + void _GetContext(weasel::Context& ctx, RimeSessionId session_id); void _UpdateShowNotifications(RimeConfig* config, bool initialize = false); - bool _IsSessionTSF(UINT session_id); - void _UpdateInlinePreeditStatus(UINT session_id); + bool _IsSessionTSF(RimeSessionId session_id); + void _UpdateInlinePreeditStatus(WeaselSessionId ipc_id); + + RimeSessionId to_session_id(WeaselSessionId ipc_id) { + return m_session_status_map[ipc_id].session_id; + } + SessionStatus& get_session_status(WeaselSessionId ipc_id) { + return m_session_status_map[ipc_id]; + } + SessionStatus& new_session_status(WeaselSessionId ipc_id) { + return m_session_status_map[ipc_id] = SessionStatus(); + } AppOptionsByAppName m_app_options; weasel::UI* m_ui; // reference - UINT m_active_session; + DWORD m_active_session; bool m_disabled; std::string m_last_schema_id; std::string m_last_app_name; @@ -99,4 +118,5 @@ class RimeWithWeaselHandler : public weasel::RequestHandler { bool m_current_dark_mode; bool m_global_ascii_mode; int m_show_notifications_time; + DWORD m_pid; }; diff --git a/include/WeaselIPC.h b/include/WeaselIPC.h index 770b51d00..5cf7cb797 100644 --- a/include/WeaselIPC.h +++ b/include/WeaselIPC.h @@ -37,8 +37,8 @@ enum WEASEL_IPC_COMMAND { namespace weasel { struct PipeMessage { WEASEL_IPC_COMMAND Msg; - UINT wParam; - UINT lParam; + DWORD wParam; + DWORD lParam; }; struct IPCMetadata { @@ -65,36 +65,36 @@ struct RequestHandler { virtual ~RequestHandler() {} virtual void Initialize() {} virtual void Finalize() {} - virtual UINT FindSession(UINT session_id) { return 0; } - virtual UINT AddSession(LPWSTR buffer, EatLine eat = 0) { return 0; } - virtual UINT RemoveSession(UINT session_id) { return 0; } + virtual DWORD FindSession(DWORD session_id) { return 0; } + virtual DWORD AddSession(LPWSTR buffer, EatLine eat = 0) { return 0; } + virtual DWORD RemoveSession(DWORD session_id) { return 0; } virtual BOOL ProcessKeyEvent(KeyEvent keyEvent, - UINT session_id, + DWORD session_id, EatLine eat) { return FALSE; } - virtual void CommitComposition(UINT session_id) {} - virtual void ClearComposition(UINT session_id) {} - virtual void SelectCandidateOnCurrentPage(size_t index, UINT session_id) {} + virtual void CommitComposition(DWORD session_id) {} + virtual void ClearComposition(DWORD session_id) {} + virtual void SelectCandidateOnCurrentPage(size_t index, DWORD session_id) {} virtual bool HighlightCandidateOnCurrentPage(size_t index, - UINT session_id, + DWORD session_id, EatLine eat) { return false; } - virtual bool ChangePage(bool backward, UINT session_id, EatLine eat) { + virtual bool ChangePage(bool backward, DWORD session_id, EatLine eat) { return false; } - virtual void FocusIn(DWORD param, UINT session_id) {} - virtual void FocusOut(DWORD param, UINT session_id) {} - virtual void UpdateInputPosition(RECT const& rc, UINT session_id) {} + virtual void FocusIn(DWORD param, DWORD session_id) {} + virtual void FocusOut(DWORD param, DWORD session_id) {} + virtual void UpdateInputPosition(RECT const& rc, DWORD session_id) {} virtual void StartMaintenance() {} virtual void EndMaintenance() {} - virtual void SetOption(UINT session_id, const std::string& opt, bool val) {} + virtual void SetOption(DWORD session_id, const std::string& opt, bool val) {} virtual void UpdateColorTheme(BOOL darkMode) {} }; // 處理server端回應之物件 -typedef std::function ResponseHandler; +typedef std::function ResponseHandler; // 事件處理函數 typedef std::function CommandHandler; diff --git a/lib64/WinSparkle.lib b/lib64/WinSparkle.lib new file mode 100644 index 000000000..99bcf2521 Binary files /dev/null and b/lib64/WinSparkle.lib differ diff --git a/output/Win32/WinSparkle.dll b/output/Win32/WinSparkle.dll new file mode 100644 index 000000000..c1faae497 Binary files /dev/null and b/output/Win32/WinSparkle.dll differ diff --git a/output/WinSparkle.dll b/output/WinSparkle.dll index c1faae497..d77a2104c 100644 Binary files a/output/WinSparkle.dll and b/output/WinSparkle.dll differ diff --git a/output/install.nsi b/output/install.nsi index c78808580..a70796bcc 100644 --- a/output/install.nsi +++ b/output/install.nsi @@ -3,6 +3,7 @@ !include LogicLib.nsh !include MUI2.nsh !include x64.nsh +!include winVer.nsh Unicode true @@ -207,11 +208,40 @@ program_files: File /nonfatal "weaseltARM.ime" File /nonfatal "weaseltARM64.ime" ${EndIf} - File "WeaselDeployer.exe" - File "WeaselServer.exe" + ; install x64 build for NativeARM64_WINDOWS11 and NativeAMD64_WINDOWS11 + ${If} ${AtLeastWin11} ; Windows 11 and above + ${If} ${IsNativeARM64} + File "WeaselDeployer.exe" + File "WeaselServer.exe" + File "rime.dll" + File "WinSparkle.dll" + ${ElseIf} ${IsNativeAMD64} + File "WeaselDeployer.exe" + File "WeaselServer.exe" + File "rime.dll" + File "WinSparkle.dll" + ${Else} + File "Win32\WeaselDeployer.exe" + File "Win32\WeaselServer.exe" + File "Win32\rime.dll" + File "Win32\WinSparkle.dll" + ${Endif} + ; install x64 build for NativeAMD64_BELLOW_WINDOWS11 + ${Else} ; Windows 10 or bellow + ${If} ${IsNativeAMD64} + File "WeaselDeployer.exe" + File "WeaselServer.exe" + File "rime.dll" + File "WinSparkle.dll" + ${Else} + File "Win32\WeaselDeployer.exe" + File "Win32\WeaselServer.exe" + File "Win32\rime.dll" + File "Win32\WinSparkle.dll" + ${Endif} + ${Endif} + File "WeaselSetup.exe" - File "rime.dll" - File "WinSparkle.dll" ; shared data files SetOutPath $INSTDIR\data File "data\*.yaml" diff --git a/test/TestResponseParser/TestResponseParser.vcxproj b/test/TestResponseParser/TestResponseParser.vcxproj index eee33f690..4a7a90014 100644 --- a/test/TestResponseParser/TestResponseParser.vcxproj +++ b/test/TestResponseParser/TestResponseParser.vcxproj @@ -458,6 +458,7 @@ true Console MachineX64 + $(SolutionDir)\lib64;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Debug;%(AdditionalLibraryDirectories) @@ -503,6 +504,7 @@ true true MachineX64 + $(SolutionDir)\lib64;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) diff --git a/test/TestWeaselIPC/TestWeaselIPC.cpp b/test/TestWeaselIPC/TestWeaselIPC.cpp index 13b245099..efa98c7e6 100644 --- a/test/TestWeaselIPC/TestWeaselIPC.cpp +++ b/test/TestWeaselIPC/TestWeaselIPC.cpp @@ -111,7 +111,7 @@ int client_main() { std::cerr << "failed to login." << std::endl; return -3; } - bool eaten = client.ProcessKeyEvent(weasel::KeyEvent(L'A', 0)); + bool eaten = client.ProcessKeyEvent(weasel::KeyEvent(L'a', 0)); std::cout << "server replies: " << eaten << std::endl; if (eaten) { WCHAR response[WEASEL_IPC_BUFFER_LENGTH]; diff --git a/test/TestWeaselIPC/TestWeaselIPC.vcxproj b/test/TestWeaselIPC/TestWeaselIPC.vcxproj index da68c6d7b..93ec758a9 100644 --- a/test/TestWeaselIPC/TestWeaselIPC.vcxproj +++ b/test/TestWeaselIPC/TestWeaselIPC.vcxproj @@ -500,6 +500,7 @@ true true MachineX64 + $(SolutionDir)\lib64;$(BOOST_ROOT)\stage\lib;$(SolutionDir)\librime\build\lib\Release;%(AdditionalLibraryDirectories) diff --git a/weasel.props.template b/weasel.props.template index f8c87c856..4aa59156b 100644 --- a/weasel.props.template +++ b/weasel.props.template @@ -18,4 +18,9 @@ true + + + $(PreprocessorDefinitions);VERSION_MAJOR=$(VERSION_MAJOR);VERSION_MINOR=$(VERSION_MINOR);VERSION_PATCH=$(VERSION_PATCH);PRODUCT_VERSION=$(PRODUCT_VERSION);FILE_VERSION=$(FILE_VERSION); + + diff --git a/weasel.sln b/weasel.sln index 56a2f68f0..0f56c9efe 100644 --- a/weasel.sln +++ b/weasel.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.5.33516.290 +VisualStudioVersion = 17.7.34024.191 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{53F79A24-5390-4640-84B5-19984EB3353B}" ProjectSection(SolutionItems) = preProject @@ -160,11 +160,13 @@ Global {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Debug|Win32.ActiveCfg = Debug|Win32 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Debug|Win32.Build.0 = Debug|Win32 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Debug|x64.ActiveCfg = Debug|x64 + {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Debug|x64.Build.0 = Debug|x64 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Release|ARM.ActiveCfg = Release|ARM {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Release|ARM64.ActiveCfg = Release|ARM64 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Release|Win32.ActiveCfg = Release|Win32 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Release|Win32.Build.0 = Release|Win32 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Release|x64.ActiveCfg = Release|x64 + {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.Release|x64.Build.0 = Release|x64 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.ReleaseHant|ARM.ActiveCfg = ReleaseHant|ARM {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.ReleaseHant|ARM64.ActiveCfg = ReleaseHant|ARM64 {A68C2A5C-D74D-4CB2-9E22-A4D2FC256A2D}.ReleaseHant|Win32.ActiveCfg = ReleaseHant|Win32 @@ -174,10 +176,10 @@ Global {9C1CC4BA-18FF-4890-908E-E545881C5586}.Debug|Win32.ActiveCfg = Debug|Win32 {9C1CC4BA-18FF-4890-908E-E545881C5586}.Debug|Win32.Build.0 = Debug|Win32 {9C1CC4BA-18FF-4890-908E-E545881C5586}.Debug|x64.ActiveCfg = Debug|x64 + {9C1CC4BA-18FF-4890-908E-E545881C5586}.Debug|x64.Build.0 = Debug|x64 {9C1CC4BA-18FF-4890-908E-E545881C5586}.Release|ARM.ActiveCfg = Release|ARM {9C1CC4BA-18FF-4890-908E-E545881C5586}.Release|ARM64.ActiveCfg = Release|ARM64 {9C1CC4BA-18FF-4890-908E-E545881C5586}.Release|Win32.ActiveCfg = Release|Win32 - {9C1CC4BA-18FF-4890-908E-E545881C5586}.Release|Win32.Build.0 = Release|Win32 {9C1CC4BA-18FF-4890-908E-E545881C5586}.Release|x64.ActiveCfg = Release|x64 {9C1CC4BA-18FF-4890-908E-E545881C5586}.ReleaseHant|ARM.ActiveCfg = ReleaseHant|ARM {9C1CC4BA-18FF-4890-908E-E545881C5586}.ReleaseHant|ARM64.ActiveCfg = ReleaseHant|ARM64 @@ -188,11 +190,13 @@ Global {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Debug|Win32.ActiveCfg = Debug|Win32 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Debug|Win32.Build.0 = Debug|Win32 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Debug|x64.ActiveCfg = Debug|x64 + {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Debug|x64.Build.0 = Debug|x64 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Release|ARM.ActiveCfg = Release|ARM {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Release|ARM64.ActiveCfg = Release|ARM64 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Release|Win32.ActiveCfg = Release|Win32 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Release|Win32.Build.0 = Release|Win32 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Release|x64.ActiveCfg = Release|x64 + {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.Release|x64.Build.0 = Release|x64 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.ReleaseHant|ARM.ActiveCfg = ReleaseHant|ARM {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.ReleaseHant|ARM64.ActiveCfg = ReleaseHant|ARM64 {26930622-CFA2-43DF-A9F3-4AA4A313B2A4}.ReleaseHant|Win32.ActiveCfg = ReleaseHant|Win32 @@ -202,10 +206,10 @@ Global {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Debug|Win32.ActiveCfg = Debug|Win32 {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Debug|Win32.Build.0 = Debug|Win32 {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Debug|x64.ActiveCfg = Debug|x64 + {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Debug|x64.Build.0 = Debug|x64 {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Release|ARM.ActiveCfg = Release|ARM {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Release|ARM64.ActiveCfg = Release|ARM64 {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Release|Win32.ActiveCfg = Release|Win32 - {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Release|Win32.Build.0 = Release|Win32 {CC642427-64D7-44D9-8543-8CBBF981FAE7}.Release|x64.ActiveCfg = Release|x64 {CC642427-64D7-44D9-8543-8CBBF981FAE7}.ReleaseHant|ARM.ActiveCfg = ReleaseHant|ARM {CC642427-64D7-44D9-8543-8CBBF981FAE7}.ReleaseHant|ARM64.ActiveCfg = ReleaseHant|ARM64 @@ -216,11 +220,13 @@ Global {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|Win32.ActiveCfg = Debug|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|Win32.Build.0 = Debug|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|x64.ActiveCfg = Debug|x64 + {1C497821-BD63-4F02-9094-32B185B62F23}.Debug|x64.Build.0 = Debug|x64 {1C497821-BD63-4F02-9094-32B185B62F23}.Release|ARM.ActiveCfg = Release|ARM {1C497821-BD63-4F02-9094-32B185B62F23}.Release|ARM64.ActiveCfg = Release|ARM64 {1C497821-BD63-4F02-9094-32B185B62F23}.Release|Win32.ActiveCfg = Release|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Release|Win32.Build.0 = Release|Win32 {1C497821-BD63-4F02-9094-32B185B62F23}.Release|x64.ActiveCfg = Release|x64 + {1C497821-BD63-4F02-9094-32B185B62F23}.Release|x64.Build.0 = Release|x64 {1C497821-BD63-4F02-9094-32B185B62F23}.ReleaseHant|ARM.ActiveCfg = ReleaseHant|ARM {1C497821-BD63-4F02-9094-32B185B62F23}.ReleaseHant|ARM64.ActiveCfg = ReleaseHant|ARM64 {1C497821-BD63-4F02-9094-32B185B62F23}.ReleaseHant|Win32.ActiveCfg = ReleaseHant|Win32 @@ -229,12 +235,14 @@ Global {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|ARM64.ActiveCfg = Debug|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|Win32.ActiveCfg = Debug|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|Win32.Build.0 = Debug|Win32 - {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|x64.ActiveCfg = Debug|Win32 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|x64.ActiveCfg = Debug|x64 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Debug|x64.Build.0 = Debug|x64 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|ARM.ActiveCfg = Release|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|ARM64.ActiveCfg = Release|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|Win32.ActiveCfg = Release|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|Win32.Build.0 = Release|Win32 - {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|x64.ActiveCfg = Release|Win32 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|x64.ActiveCfg = Release|x64 + {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.Release|x64.Build.0 = Release|x64 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.ReleaseHant|ARM.ActiveCfg = Release|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.ReleaseHant|ARM64.ActiveCfg = Release|Win32 {F53F3E9C-CC4D-4D1D-9C2E-719FE60A7E6B}.ReleaseHant|Win32.ActiveCfg = Release|Win32