fix(input): add sliding-window multi-tap candidate bar and input tail-scrolling across plugins and fcitx5-t9
This commit is contained in:
1 parent
a53a331111
commit
1f9138f0c6
24 files changed
+394
-125
No files matched your search
@@ -41,7 +41,7 @@ enum class TextCaseMode {
|
||||
|
||||
const char* kMultiTapSms[10] = {
|
||||
" 0\n", // 0
|
||||
".,?!'-:;()@/1", // 1
|
||||
kMultiTapPunct1, // 1
|
||||
"abc2", // 2
|
||||
"def3", // 3
|
||||
"ghi4", // 4
|
||||
@@ -776,11 +776,17 @@ int runSmsApp(int argc, char** argv) {
|
||||
if (!cname.empty()) {
|
||||
toDisp += " (" + cname + ")";
|
||||
}
|
||||
if (toSel && cname.empty()) {
|
||||
toDisp = tailFitPangoText(layoutMain, toDisp, kWinWidth - 20);
|
||||
}
|
||||
drawPango(layoutMain, toSel ? &colWhite : &colLight, 10, 36, 32, toDisp,
|
||||
kWinWidth - 20);
|
||||
|
||||
// Field 1: Message Body
|
||||
bool msgSel = (composeField == 1);
|
||||
bool smsTapActive =
|
||||
(msgSel && lastTapDigit >= 0 && lastTapDigit <= 9 &&
|
||||
(nowMs() - lastTapMs) <= 850);
|
||||
XSetForeground(dpy, gc,
|
||||
msgSel ? pt.spec.bgInputFocus : pt.spec.bgInput);
|
||||
XFillRectangle(dpy, pix, gc, 6, 72, kWinWidth - 12, 156);
|
||||
@@ -789,6 +795,7 @@ int runSmsApp(int argc, char** argv) {
|
||||
|
||||
std::string bodyDisp = composeText;
|
||||
if (msgSel) bodyDisp += "|";
|
||||
int bodyMaxH = smsTapActive ? 126 : 146;
|
||||
if (bodyDisp.empty()) {
|
||||
drawPango(layoutSmall, &colMuted, 12, 78, 20,
|
||||
"Type message (# Input mode)...", kWinWidth - 24);
|
||||
@@ -801,17 +808,28 @@ int runSmsApp(int argc, char** argv) {
|
||||
int tw = 0, th = 0;
|
||||
pango_layout_get_pixel_size(layoutMain, &tw, &th);
|
||||
int textY = 76;
|
||||
if (th > 146) {
|
||||
textY = 76 - (th - 146);
|
||||
if (th > bodyMaxH) {
|
||||
textY = 76 - (th - bodyMaxH);
|
||||
}
|
||||
XRectangle clipRect {6, 73, static_cast<unsigned short>(kWinWidth - 12),
|
||||
154};
|
||||
static_cast<unsigned short>(smsTapActive ? 134 : 154)};
|
||||
XftDrawSetClipRectangles(xftDraw, 0, 0, &clipRect, 1);
|
||||
pango_xft_render_layout(xftDraw, &colWhite, layoutMain,
|
||||
12 * PANGO_SCALE, textY * PANGO_SCALE);
|
||||
XftDrawSetClip(xftDraw, nullptr);
|
||||
}
|
||||
|
||||
if (smsTapActive) {
|
||||
XSetForeground(dpy, gc, pt.spec.bgAltOdd);
|
||||
XFillRectangle(dpy, pix, gc, 7, 208, kWinWidth - 14, 19);
|
||||
XSetForeground(dpy, gc, pt.spec.divider);
|
||||
XDrawLine(dpy, pix, gc, 7, 208, kWinWidth - 8, 208);
|
||||
std::string cand = formatMultiTapBar(
|
||||
std::to_string(lastTapDigit) + ":", kMultiTapSms[lastTapDigit],
|
||||
lastTapCycle, caseMode == TextCaseMode::Upper);
|
||||
drawPango(layoutSmall, &colYellow, 10, 208, 19, cand, kWinWidth - 20);
|
||||
}
|
||||
|
||||
// Field 2 & 3: Send & Save Draft buttons
|
||||
bool sendSel = (composeField == 2);
|
||||
bool draftSel = (composeField == 3);
|
||||
@@ -956,7 +974,8 @@ int runSmsApp(int argc, char** argv) {
|
||||
XFillRectangle(dpy, pix, gc, 12, 80, kWinWidth - 24, 34);
|
||||
XSetForeground(dpy, gc, pt.spec.accentAlt);
|
||||
XDrawRectangle(dpy, pix, gc, 12, 80, kWinWidth - 25, 33);
|
||||
std::string disp = addBlockInput + "|";
|
||||
std::string disp =
|
||||
tailFitPangoText(layoutMain, addBlockInput + "|", kWinWidth - 36);
|
||||
drawPango(layoutMain, &colWhite, 18, 83, 28, disp, kWinWidth - 36);
|
||||
drawPango(layoutSmall, &colMuted, 12, 124, 20,
|
||||
"0-9 / * / #: Digits #: + prefix", 216);
|
||||
@@ -1660,6 +1679,12 @@ int runSmsApp(int argc, char** argv) {
|
||||
zeroHeld = false;
|
||||
}
|
||||
|
||||
if (visible && mode == ViewMode::Compose && lastTapDigit != -1 &&
|
||||
(tNow - lastTapMs) > 850) {
|
||||
lastTapDigit = -1;
|
||||
drawUI();
|
||||
}
|
||||
|
||||
int timeoutMs = -1;
|
||||
if (visible) {
|
||||
timeoutMs = 250;
|
||||
@@ -1672,6 +1697,11 @@ int runSmsApp(int argc, char** argv) {
|
||||
timeoutMs,
|
||||
std::max(1, static_cast<int>((zeroPressMs + 420) - tNow)));
|
||||
}
|
||||
if (mode == ViewMode::Compose && lastTapDigit != -1) {
|
||||
timeoutMs = std::min(
|
||||
timeoutMs,
|
||||
std::max(1, static_cast<int>(851 - (tNow - lastTapMs))));
|
||||
}
|
||||
}
|
||||
|
||||
struct pollfd pfds[3];
|
||||
|
||||
Reference in new issue
Block a user