popup: keep only computed geometry in Popup; one fallback for slivers

numx, textx and selx were compile-time constants stored per layout;
the number column starts at PopupPad and text at PopupPad+PopupNumw,
which dat.h now says once. The height fallback tried dropping the
marker, then the preedit, then the padding as three separate refits;
below one padded row it now shows as many bare rows as fit, at least
one, which is what those steps added up to.
This commit is contained in:
2026-08-16 18:27:24 +09:00
parent 68678283cd
commit 3f1ff03b94
3 changed files with 25 additions and 34 deletions

View File

@@ -166,10 +166,8 @@ popup_layout(struct ct *t)
CT_EQ_INT(t, PopupPad, p.rowsy);
CT_EQ_INT(t, -1, p.marky);
CT_EQ_INT(t, 2*PopupPad + 2*Fontsz, p.h);
CT_EQ_INT(t, PopupPad, p.numx);
CT_EQ_INT(t, p.numx + PopupNumw, p.textx);
CT_EQ_INT(t, PopupTextw, p.textw);
CT_EQ_INT(t, p.w - PopupPad, p.textx + p.textw);
CT_EQ_INT(t, p.w - PopupPad, PopupPad + PopupNumw + p.textw);
/* Preedit and candidates meet at one separator, with no empty rows. */
dc.pre = mkstr("preedit");
@@ -212,12 +210,9 @@ popup_layout(struct ct *t)
CT_EQ_INT(t, 2*PopupBasew, p.w);
CT_CHECK(t, p.h <= Imgh);
CT_EQ_INT(t, p.w - PopupPad, p.markx + p.markw);
CT_EQ_INT(t, PopupPad, p.selx);
CT_EQ_INT(t, p.w - 2*PopupPad, p.selw);
CT_EQ_INT(t, p.rowsy + dc.sel*Fontsz, p.sely);
CT_EQ_INT(t, PopupPad, p.numx);
CT_EQ_INT(t, p.numx + PopupNumw, p.textx);
CT_EQ_INT(t, p.w - PopupPad, p.textx + p.textw);
CT_EQ_INT(t, p.w - PopupPad, PopupPad + PopupNumw + p.textw);
img = emalloc(2*PopupBasew*Imgh*sizeof img[0]);
popupdraw(img, &dc, &p);
@@ -232,7 +227,7 @@ popup_layout(struct ct *t)
for(y = p.sely; y < p.sely + Fontsz; y++){
for(x = 0; x < p.w; x++){
c = pixel(img, &p, x, y);
if(x < p.selx || x >= p.selx + p.selw){
if(x < PopupPad || x >= PopupPad + p.selw){
CT_EQ_UINT(t, Colbg, c);
continue;
}
@@ -241,9 +236,9 @@ popup_layout(struct ct *t)
continue;
}
CT_CHECK(t,
(x >= p.numx && x < p.numx + PopupNumw) ||
(x >= p.textx && x < p.textx + p.textw));
if(x < p.numx + PopupNumw)
(x >= PopupPad && x < PopupPad + PopupNumw) ||
(x >= (PopupPad + PopupNumw) && x < (PopupPad + PopupNumw) + p.textw));
if(x < PopupPad + PopupNumw)
numink++;
else
textink++;
@@ -277,7 +272,7 @@ popup_layout(struct ct *t)
CT_CHECK(t, p.textw > PopupTextw);
CT_CHECK(t, n > p.textw);
CT_EQ_INT(t, PopupPad, p.rowsy);
CT_EQ_INT(t, p.w - PopupPad, p.textx + p.textw);
CT_EQ_INT(t, p.w - PopupPad, PopupPad + PopupNumw + p.textw);
popupdraw(img, &dc, &p);
ink = 0;
for(y = p.rowsy; y < p.rowsy + Fontsz; y++){
@@ -285,7 +280,7 @@ popup_layout(struct ct *t)
c = pixel(img, &p, x, y);
if(x < PopupPad || x >= p.w - PopupPad)
CT_EQ_UINT(t, Colbg, c);
if(x >= p.textx && x < p.textx + p.textw &&
if(x >= (PopupPad + PopupNumw) && x < (PopupPad + PopupNumw) + p.textw &&
c != (Colbg & Rgbmask))
ink++;
}
@@ -312,7 +307,7 @@ popup_layout(struct ct *t)
popupdraw(img, &dc, &p);
numink = 0;
for(y = p.rowsy; y < p.rowsy + Fontsz; y++)
for(x = p.numx; x < p.numx + PopupNumw; x++)
for(x = PopupPad; x < PopupPad + PopupNumw; x++)
if(pixel(img, &p, x, y) != (Colsel & Rgbmask))
numink++;
markink = 0;