Skip to content

Commit c34b9c8

Browse files
committed
fix typo false :v, and reomve some func
1 parent 2788977 commit c34b9c8

3 files changed

Lines changed: 20 additions & 82 deletions

File tree

src/ack-apps.h renamed to src/app_quirks.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@
66
*/
77

88
/**
9-
* @file ack-apps.h
9+
* @file app_quirks.h
1010
* @brief List of applications requiring acknowledgment workaround.
1111
*
1212
* These browsers need special handling for uinput mode to work correctly.
1313
*/
1414

1515
#include <string>
16-
#include <vector>
16+
#include <string_view>
1717

1818
/**
1919
* @brief List of application names requiring ACK workaround.
2020
*
2121
* Chromium-based browsers that need special handling for text replacement.
2222
*/
23-
static std::vector<std::string> ack_apps = {"chrome", "chromium", "brave", "edge", "vivaldi", "opera", "coccoc", "cromite", "helium", "thorium", "slimjet", "yandex"};
23+
inline constexpr std::array<std::string_view, 12> ack_apps = {"chrome", "chromium", "brave", "edge", "vivaldi", "opera",
24+
"coccoc", "cromite", "helium", "thorium", "slimjet", "yandex"};
2425

2526
/**
2627
* @brief List of application names have goood support surrowding text
2728
*
2829
*/
29-
static std::vector<std::string> surrtp_apps = {"mullvad", "soffice"};
30+
inline constexpr std::array<std::string_view, 1> surrtp_apps = {"soffice"};

src/lotus-engine.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "lotus-candidates.h"
1313
#include "lotus-monitor.h"
1414
#include "lotus-utils.h"
15-
#include "ack-apps.h"
15+
#include "app_quirks.h"
1616
#include <sys/socket.h>
1717
#include <utility>
1818
#ifndef DISABLE_VERSION_ACTION
@@ -375,7 +375,7 @@ namespace fcitx {
375375
//
376376
// TODO: Properly fixes instead ugly WA
377377
state->wa_flag = false;
378-
state->surrtp = true;
378+
state->surrtp = false;
379379
state->waitAck_ = false;
380380
if (*config_.fixUinputWithAck) {
381381
if (targetMode == LotusMode::Uinput || targetMode == LotusMode::UinputHC || targetMode == LotusMode::Smooth) {
@@ -388,7 +388,7 @@ namespace fcitx {
388388
if (appName.find(ackApp) != std::string::npos) {
389389
if (is_dbus) {
390390
state->waitAck_ = true;
391-
LOTUS_INFO(ackApp + " detected, waiting for ack");
391+
LOTUS_INFO(std::string(ackApp) + " detected, waiting for ack");
392392
}
393393
state->wa_flag = true;
394394
break;
@@ -621,7 +621,6 @@ namespace fcitx {
621621
auto* state = ic->propertyFor(&factory_);
622622
const bool surrvalid = ic->surroundingText().isValid();
623623
const bool is_dbus = getFrontendName(ic) == "dbus";
624-
state->lastDeactivateTime_ = now_ms();
625624
if (realMode == LotusMode::Preedit && event.type() != EventType::InputContextFocusOut) {
626625
state->commitBuffer();
627626
} else {

src/lotus-state.cpp

Lines changed: 12 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ namespace fcitx {
468468
if (surr.isValid() && surr.cursor() == realtextLen.load(std::memory_order_acquire)) {
469469
LOTUS_INFO("Skip retry");
470470
} else {
471-
// Retry x3 (2 ms each), khi can (chromium,electron,...)
472-
for (int retry = 0; retry < 3; ++retry) {
473-
std::this_thread::sleep_for(std::chrono::milliseconds(2));
471+
// Retry x5 (1 ms each), khi can (chromium,electron,...)
472+
for (int retry = 0; retry < 5; ++retry) {
473+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
474474
const auto& surr2 = ic_->surroundingText();
475475
if (surr2.isValid() && surr2.cursor() == realtextLen.load(std::memory_order_acquire)) {
476476
break;
@@ -484,8 +484,8 @@ namespace fcitx {
484484
pending_commit_string_ = "";
485485

486486
event.filterAndAccept(); // Filter out the final trigger backspace.
487-
if (getFrontendName(ic_) == "dbus" && !ic_->surroundingText().isValid())
488-
replayBufferedKeys(); // Does we need drop this?
487+
//if (getFrontendName(ic_) == "dbus" && !ic_->surroundingText().isValid())
488+
// replayBufferedKeys(); // Does we need drop this?
489489
return true;
490490
}
491491
return false;
@@ -683,32 +683,6 @@ namespace fcitx {
683683
history_ += keyUtf8;
684684
realtextLen.fetch_add(1, std::memory_order_acq_rel);
685685

686-
replayBufferToEngine(history_);
687-
688-
auto commitAfterReplay = UniqueCPtr<char>(EnginePullCommit(lotusEngine_.handle()));
689-
if (commitAfterReplay && (*commitAfterReplay.get() != 0)) {
690-
std::string commitStr = commitAfterReplay.get();
691-
std::string commonPrefix;
692-
std::string deletedPart;
693-
std::string addedPart;
694-
compareAndSplitStrings(oldPreBuffer_, commitStr, commonPrefix, deletedPart, addedPart);
695-
696-
if (!deletedPart.empty()) {
697-
if (performReplacement(deletedPart, addedPart))
698-
keyEvent.forward();
699-
} else if (!addedPart.empty()) {
700-
ic_->commitString(addedPart);
701-
LOTUS_INFO("Commit: " + addedPart);
702-
}
703-
704-
history_.clear();
705-
ResetEngine(lotusEngine_.handle());
706-
oldPreBuffer_.clear();
707-
708-
keyEvent.filterAndAccept();
709-
return;
710-
}
711-
712686
UniqueCPtr<char> preeditC(EnginePullPreedit(lotusEngine_.handle()));
713687
std::string preeditStr = (preeditC && (*preeditC.get() != 0)) ? preeditC.get() : "";
714688

@@ -969,8 +943,8 @@ namespace fcitx {
969943
}
970944
replacement_thread_id_.store(0, std::memory_order_release);
971945
replacement_start_ms_.store(0, std::memory_order_release);
972-
if (getFrontendName(ic_) == "dbus" && !ic_->surroundingText().isValid())
973-
replayBufferedKeys(); // Does we need drop this?
946+
//if (getFrontendName(ic_) == "dbus" && !ic_->surroundingText().isValid())
947+
// replayBufferedKeys(); // Does we need drop this?
974948
}
975949
KeySym currentSym = keyEvent.rawKey().sym();
976950
if (*engine_->config().autoCapitalizeAfterPunctuation && realMode != LotusMode::Off) {
@@ -1162,11 +1136,9 @@ namespace fcitx {
11621136
}
11631137
oldPreBuffer_.clear();
11641138
history_.clear();
1165-
if (!is_deleting_.load(std::memory_order_acquire)) {
1166-
expected_backspaces_ = 0;
1167-
current_backspace_count_ = 0;
1168-
pending_commit_string_.clear();
1169-
}
1139+
expected_backspaces_ = 0;
1140+
current_backspace_count_ = 0;
1141+
pending_commit_string_.clear();
11701142
emojiBuffer_.clear();
11711143
emojiCandidates_.clear();
11721144
buffered_keys_.clear();
@@ -1179,14 +1151,13 @@ namespace fcitx {
11791151
bool LotusState::isEmptyHistory() {
11801152
return history_.empty();
11811153
}
1182-
1154+
/*
11831155
void LotusState::replayBufferedKeys() {
11841156
LOTUS_INFO("Starting replay buffered keys");
11851157
if (buffered_keys_.empty()) {
11861158
return;
11871159
}
11881160
auto keys = std::move(buffered_keys_);
1189-
buffered_keys_.clear();
11901161
for (size_t i = 0; i < keys.size(); ++i) {
11911162
KeySym sym = static_cast<KeySym>(keys[i].sym);
11921163
uint32_t state = keys[i].state;
@@ -1236,40 +1207,6 @@ namespace fcitx {
12361207
history_ += keyUtf8;
12371208
realtextLen.fetch_add(1, std::memory_order_acq_rel);
12381209
1239-
replayBufferToEngine(history_);
1240-
1241-
auto commitAfterReplay = UniqueCPtr<char>(EnginePullCommit(lotusEngine_.handle()));
1242-
if (commitAfterReplay && (*commitAfterReplay.get() != 0)) {
1243-
std::string commitStr = commitAfterReplay.get();
1244-
std::string commonPrefix;
1245-
std::string deletedPart;
1246-
std::string addedPart;
1247-
compareAndSplitStrings(oldPreBuffer_, commitStr, commonPrefix, deletedPart, addedPart);
1248-
1249-
if (!deletedPart.empty()) {
1250-
// Re-buffer remaining keys for next replay cycle.
1251-
for (size_t j = i + 1; j < keys.size(); ++j) {
1252-
if (buffered_keys_.size() < MAX_BUFFERED_KEYS) {
1253-
buffered_keys_.push_back(keys[j]);
1254-
}
1255-
}
1256-
performReplacement(deletedPart, addedPart);
1257-
1258-
history_.clear();
1259-
ResetEngine(lotusEngine_.handle());
1260-
oldPreBuffer_.clear();
1261-
return;
1262-
}
1263-
if (!addedPart.empty()) {
1264-
ic_->commitString(addedPart);
1265-
}
1266-
1267-
history_.clear();
1268-
ResetEngine(lotusEngine_.handle());
1269-
oldPreBuffer_.clear();
1270-
continue;
1271-
}
1272-
12731210
UniqueCPtr<char> preeditC(EnginePullPreedit(lotusEngine_.handle()));
12741211
std::string preeditStr = (preeditC && (*preeditC.get() != 0)) ? preeditC.get() : "";
12751212
@@ -1307,4 +1244,5 @@ namespace fcitx {
13071244
}
13081245
LOTUS_INFO("Replay buffered keys done");
13091246
}
1247+
*/
13101248
} // namespace fcitx

0 commit comments

Comments
 (0)