feat(x11): add XDrawer global phone controls drawer, softkey chord detection, and st/T9 scrollback

This commit is contained in:
Luxferre
2026-10-21 09:26:41 +03:00
parent da24f0d9ac
commit 8045929c87
23 changed files with 1265 additions and 55 deletions
+31 -6
View File
@@ -421,6 +421,8 @@ std::vector<T9Item> T9State::getItemsForKey(int keyId) const {
makeKey("PgDn", FcitxKey_Page_Down, 117),
makeKey("Home", FcitxKey_Home, 110),
makeKey("End", FcitxKey_End, 115),
makeKey("ScrlUp", FcitxKey_Page_Up, 112, fcitx::KeyState::Shift),
makeKey("ScrlDn", FcitxKey_Page_Down, 117, fcitx::KeyState::Shift),
};
case kKey8:
return {
@@ -894,12 +896,35 @@ void T9State::showPreview(const std::vector<T9Item>& items, int index) {
if (total == 0) {
return;
}
constexpr int kPageSize = 7;
int page = index / kPageSize;
int start = page * kPageSize;
int end = std::min(start + kPageSize, total);
constexpr int kMaxItemsPerPage = 7;
std::string prefix = modePrefix() + ":";
size_t maxItemsWidth =
(kFixedPreeditChars > prefix.size() + 1)
? (kFixedPreeditChars - prefix.size() - 1)
: 23;
std::string preedit = modePrefix() + ":";
int start = 0;
int end = 0;
while (start < total) {
size_t width = 0;
int count = 0;
end = start;
while (end < total && count < kMaxItemsPerPage) {
size_t itemWidth = items[end].label.size() + 2;
if (count > 0 && width + itemWidth > maxItemsWidth) {
break;
}
width += itemWidth;
++end;
++count;
}
if (index < end) {
break;
}
start = end;
}
std::string preedit = prefix;
for (int i = start; i < end; ++i) {
if (i == index) {
preedit += "[";
@@ -911,7 +936,7 @@ void T9State::showPreview(const std::vector<T9Item>& items, int index) {
preedit += " ";
}
}
if (total > kPageSize) {
if (start > 0 || end < total) {
preedit += (end < total) ? ">" : "<";
}
if (preedit.size() < kFixedPreeditChars) {