popup: replace FreeType renderer with PangoCairo
This commit is contained in:
32
win.c
32
win.c
@@ -141,7 +141,7 @@ wininit(void)
|
||||
mask = XCB_CW_BACK_PIXMAP;
|
||||
xcb_change_window_attributes(conn, win, mask, &pix);
|
||||
img = emalloc(Imgw * Imgh * sizeof(img[0]));
|
||||
if(!fontinit(fontfiles, nfontfiles)){
|
||||
if(!textinit(fontfiles, nfontfiles)){
|
||||
fprint(2, "strans: popup disabled: no usable fonts\n");
|
||||
wincleanup();
|
||||
return 0;
|
||||
@@ -149,18 +149,6 @@ wininit(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
drawstr(u32int *buf, int x, int y, Rune *r, int n, int maxw, int maxh)
|
||||
{
|
||||
while(n-- > 0){
|
||||
if(*r != 0xfe0e && *r != 0xfe0f){
|
||||
putfont(buf, maxw, maxh, x, y, *r);
|
||||
x += Fontsz;
|
||||
}
|
||||
r++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fill(u32int *buf, int n, u32int color)
|
||||
{
|
||||
@@ -174,20 +162,22 @@ static void
|
||||
drawkouho(Drawcmd *dc, int n, int w, int h)
|
||||
{
|
||||
int npre, sely, y, i;
|
||||
Str *s;
|
||||
Str num, *s;
|
||||
|
||||
fill(img, w * h, Colbg);
|
||||
npre = dc->pre.n != 0;
|
||||
if(npre)
|
||||
drawstr(img, 0, 0, dc->pre.r, dc->pre.n, w, h);
|
||||
textdraw(img, w, h, 0, 0, &dc->pre);
|
||||
if(dc->sel >= 0 && dc->sel < n){
|
||||
sely = (npre + dc->sel) * Fontsz;
|
||||
fill(img + sely * w, Fontsz * w, Colsel);
|
||||
}
|
||||
for(i = 0, y = npre * Fontsz; i < n; i++, y += Fontsz){
|
||||
s = &dc->kouho[i];
|
||||
putfont(img, w, h, 0, y, '1' + i + Asciitofull);
|
||||
drawstr(img, 2*Fontsz, y, s->r, s->n, w, h);
|
||||
sclear(&num);
|
||||
sputr(&num, '1' + i + Asciitofull);
|
||||
textdraw(img, w, h, 0, y, &num);
|
||||
textdraw(img, w, h, 2*Fontsz, y, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +200,7 @@ winhide(void)
|
||||
static int
|
||||
winshow(Drawcmd *dc)
|
||||
{
|
||||
vlong width;
|
||||
int npre, px, py, w, h, i, n, maxw;
|
||||
u32int vals[4];
|
||||
xcb_query_pointer_reply_t *ptr;
|
||||
@@ -220,11 +211,12 @@ winshow(Drawcmd *dc)
|
||||
if(n == 0 && npre == 0){
|
||||
return winhide();
|
||||
}
|
||||
maxw = popupcells(dc->pre.r, dc->pre.n);
|
||||
maxw = textwidth(&dc->pre);
|
||||
for(i = 0; i < n; i++)
|
||||
maxw = max(maxw, popupcells(dc->kouho[i].r, dc->kouho[i].n));
|
||||
maxw = max(maxw, textwidth(&dc->kouho[i]));
|
||||
vals[3] = h = (n + npre) * Fontsz;
|
||||
vals[2] = w = (maxw + 3) * Fontsz;
|
||||
width = (vlong)maxw + 3*Fontsz;
|
||||
vals[2] = w = min(max(width, 1), Imgw);
|
||||
px = py = 0;
|
||||
if(!dc->caret.valid){
|
||||
cookie = xcb_query_pointer(conn, scr->root);
|
||||
|
||||
Reference in New Issue
Block a user