popup: no fallbacks for work areas no desktop has; text setup cannot fail

popuplayout had two refit stages for a work area shorter than one
padded row — 40 pixels — and popupdraw re-checked the layout it had
just been handed, against an Imgh that bounded no buffer any more.
Pango and Cairo abort rather than return nil, so textinit is void and
the layout is never nil; the stride Cairo computes for RGB24 is w*4 by
definition; and textdraw set the layout's width and ellipsis twice.
This commit is contained in:
2026-08-17 01:36:16 +09:00
parent cd637be4ca
commit 87cb03fdf8
7 changed files with 20 additions and 89 deletions

View File

@@ -189,10 +189,7 @@ font_render(struct ct *t)
buf = mem + Guard;
fillpixels(buf, Testn, Colbg);
a = mkstr("A");
if(!CT_CHECK(t, textinit())){
free(mem);
return;
}
textinit();
for(i = 0; i < nelem(plain); i++)
checktext(t, buf, plain[i]);
@@ -257,6 +254,4 @@ font_render(struct ct *t)
checkguards(t, mem);
free(mem);
textclose();
textclose();
CT_EQ_INT(t, 0, textwidth(&a));
}

View File

@@ -2,6 +2,9 @@
#include "fn.h"
#include "test.h"
/* A popup with every section, tall enough for the tests. */
#define Imgh (2*PopupPad + (Maxdisp + 2)*Fontsz + PopupSep)
enum {
Rgbmask = 0xffffff,
};
@@ -40,9 +43,6 @@ checkpadding(struct ct *t, u32int *img, Popup *p)
void
popup_layout(struct ct *t)
{
int tinyheight[] = {
1, PopupPad, 2*PopupPad + Fontsz - 1,
};
static const struct {
int first;
int shown;
@@ -132,8 +132,7 @@ popup_layout(struct ct *t)
CT_EQ_INT(t, 100, x);
CT_EQ_INT(t, 200, y);
if(!CT_CHECK(t, textinit()))
return;
textinit();
/* Empty sections reserve nothing. */
memset(&dc, 0, sizeof dc);
@@ -320,24 +319,5 @@ popup_layout(struct ct *t)
CT_CHECK(t, numink > 0); /* full-width */
CT_CHECK(t, markink > 0); /* 9-9/9 */
/* The selected row wins over preedit and footer in one-row height. */
dc.pre = mkstr("preedit");
popuplayout(&dc, PopupBasew, 2*PopupPad + Fontsz, &p);
CT_EQ_INT(t, -1, p.prey);
CT_EQ_INT(t, 1, p.n);
CT_EQ_INT(t, Maxdisp - 1, p.row0);
CT_EQ_INT(t, -1, p.marky);
/* With less than one padded row, selected content starts at the top. */
for(i = 0; i < nelem(tinyheight); i++){
popuplayout(&dc, PopupBasew, tinyheight[i], &p);
CT_EQ_INT(t, min(tinyheight[i], Fontsz), p.h);
CT_EQ_INT(t, 0, p.rowsy);
CT_EQ_INT(t, 0, p.sely);
CT_EQ_INT(t, 1, p.n);
CT_EQ_INT(t, Maxdisp - 1, p.row0);
popupdraw(img, &dc, &p);
CT_EQ_UINT(t, Colsel, pixel(img, &p, p.w - PopupPad - 1, 0));
}
free(img);
}