Rename libdrw functions to simply "draw"

This commit is contained in:
speedie 2023-06-23 03:49:23 +02:00
parent 6328edc5cd
commit 59983981c2
12 changed files with 184 additions and 184 deletions

View file

@ -3,8 +3,8 @@
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
&& MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) && MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
#define LENGTH(X) (sizeof X / sizeof X[0]) #define LENGTH(X) (sizeof X / sizeof X[0])
#define TEXTW(X) (drw_font_getwidth(drw, (X), False) + sp.lrpad) #define TEXTW(X) (draw_font_getwidth(draw, (X), False) + sp.lrpad)
#define TEXTWM(X) (drw_font_getwidth(drw, (X), True) + sp.lrpad) #define TEXTWM(X) (draw_font_getwidth(draw, (X), True) + sp.lrpad)
#define NUMBERSMAXDIGITS 100 #define NUMBERSMAXDIGITS 100
#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1 #define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1
#define MAXITEMLENGTH 1024 #define MAXITEMLENGTH 1024

View file

@ -21,8 +21,8 @@ void drawhighlights(struct item *item, int x, int y, int w, int p, const char *i
// highlight character // highlight character
c = highlight[1]; c = highlight[1];
highlight[1] = '\0'; highlight[1] = '\0';
drw_text( draw_text(
drw, draw,
x + indent + (p), x + indent + (p),
y, y,
MIN(w - indent - sp.lrpad, TEXTW(highlight) - sp.lrpad), MIN(w - indent - sp.lrpad, TEXTW(highlight) - sp.lrpad),
@ -118,9 +118,9 @@ int drawitemtext(struct item *item, int x, int y, int w) {
if (!hidepowerline && powerlineitems && selitem) { if (!hidepowerline && powerlineitems && selitem) {
if (itempwlstyle == 2) { if (itempwlstyle == 2) {
drw_circle(drw, x - sp.plw, y, sp.plw, sp.bh, 0, col_menu, bgcol, alpha_menu, bga); draw_circle(draw, x - sp.plw, y, sp.plw, sp.bh, 0, col_menu, bgcol, alpha_menu, bga);
} else { } else {
drw_arrow(drw, x - sp.plw, y, sp.plw, sp.bh, 0, itempwlstyle, col_menu, bgcol, alpha_menu, bga); draw_arrow(draw, x - sp.plw, y, sp.plw, sp.bh, 0, itempwlstyle, col_menu, bgcol, alpha_menu, bga);
} }
} }
@ -136,7 +136,7 @@ int drawitemtext(struct item *item, int x, int y, int w) {
} }
apply_fribidi(buffer); apply_fribidi(buffer);
drw_text(drw, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga); draw_text(draw, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga);
drawhighlights(item, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, leftpadding, isrtl ? fribidi_text : buffer); drawhighlights(item, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, leftpadding, isrtl ? fribidi_text : buffer);
// position and width // position and width
@ -255,7 +255,7 @@ int drawitemtext(struct item *item, int x, int y, int w) {
// now draw any non-colored text // now draw any non-colored text
apply_fribidi(buffer); apply_fribidi(buffer);
int r = drw_text(drw, x, y, w, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga); int r = draw_text(draw, x, y, w, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga);
if (!hidehighlight) drawhighlights(item, x, y, w, leftpadding, buffer); if (!hidehighlight) drawhighlights(item, x, y, w, leftpadding, buffer);
// copy current buffer to item->clntext instead of item->text, this way SGR sequences aren't drawn // copy current buffer to item->clntext instead of item->text, this way SGR sequences aren't drawn
@ -264,9 +264,9 @@ int drawitemtext(struct item *item, int x, int y, int w) {
if (!hidepowerline && powerlineitems && selitem) { if (!hidepowerline && powerlineitems && selitem) {
if (itempwlstyle == 2) { if (itempwlstyle == 2) {
drw_circle(drw, r, y, sp.plw, sp.bh, 1, col_menu, bgcol, alpha_menu, bga); draw_circle(draw, r, y, sp.plw, sp.bh, 1, col_menu, bgcol, alpha_menu, bga);
} else { } else {
drw_arrow(drw, r, y, sp.plw, sp.bh, 1, itempwlstyle, col_menu, bgcol, alpha_menu, bga); draw_arrow(draw, r, y, sp.plw, sp.bh, 1, itempwlstyle, col_menu, bgcol, alpha_menu, bga);
} }
} }
@ -378,13 +378,13 @@ int drawitem(int x, int y, int w) {
int drawprompt(int x, int y, int w) { int drawprompt(int x, int y, int w) {
if (prompt && *prompt && !hideprompt) { if (prompt && *prompt && !hideprompt) {
x = drw_text(drw, x, y, w, sp.bh, sp.lrpad / 2, prompt, 0, pango_prompt ? True : False, col_promptfg, col_promptbg, alpha_promptfg, alpha_promptbg); x = draw_text(draw, x, y, w, sp.bh, sp.lrpad / 2, prompt, 0, pango_prompt ? True : False, col_promptfg, col_promptbg, alpha_promptfg, alpha_promptbg);
if (!hidepowerline && powerlineprompt) { if (!hidepowerline && powerlineprompt) {
if (promptpwlstyle == 2) { if (promptpwlstyle == 2) {
drw_circle(drw, x, y, sp.plw, sp.bh, 1, col_menu, col_promptbg, alpha_menu, alpha_promptbg); draw_circle(draw, x, y, sp.plw, sp.bh, 1, col_menu, col_promptbg, alpha_menu, alpha_promptbg);
} else { } else {
drw_arrow(drw, x, y, sp.plw, sp.bh, 1, promptpwlstyle, col_menu, col_promptbg, alpha_menu, alpha_promptbg); draw_arrow(draw, x, y, sp.plw, sp.bh, 1, promptpwlstyle, col_menu, col_promptbg, alpha_menu, alpha_promptbg);
} }
x += sp.plw; x += sp.plw;
@ -404,7 +404,7 @@ int drawinput(int x, int y, int w) {
if (fh > sp.bh) { if (fh > sp.bh) {
fh = sp.bh; fh = sp.bh;
} else if (!fh) { } else if (!fh) {
fh = drw->font->h; fh = draw->font->h;
} }
if (passwd) { if (passwd) {
@ -414,21 +414,21 @@ int drawinput(int x, int y, int w) {
memcpy(&censort[i], password, strlen(tx.text)); memcpy(&censort[i], password, strlen(tx.text));
apply_fribidi(censort); apply_fribidi(censort);
drw_text(drw, x, y, w, sp.bh, sp.lrpad / 2, isrtl ? fribidi_text : censort, 0, pango_password ? True : False, col_inputfg, col_inputbg, alpha_inputfg, alpha_inputbg); draw_text(draw, x, y, w, sp.bh, sp.lrpad / 2, isrtl ? fribidi_text : censort, 0, pango_password ? True : False, col_inputfg, col_inputbg, alpha_inputfg, alpha_inputbg);
curpos = TEXTW(censort) - TEXTW(&tx.text[sp.cursor]); curpos = TEXTW(censort) - TEXTW(&tx.text[sp.cursor]);
free(censort); free(censort);
} else if (!passwd) { } else if (!passwd) {
apply_fribidi(tx.text); apply_fribidi(tx.text);
drw_text(drw, x, y, w, sp.bh, sp.lrpad / 2, isrtl ? fribidi_text : tx.text, 0, pango_input ? True : False, col_inputfg, col_inputbg, alpha_inputfg, alpha_inputbg); draw_text(draw, x, y, w, sp.bh, sp.lrpad / 2, isrtl ? fribidi_text : tx.text, 0, pango_input ? True : False, col_inputfg, col_inputbg, alpha_inputfg, alpha_inputbg);
curpos = TEXTW(tx.text) - TEXTW(&tx.text[sp.cursor]); curpos = TEXTW(tx.text) - TEXTW(&tx.text[sp.cursor]);
} }
if ((curpos += sp.lrpad / 2 - 1) < w && !hidecaret) { if ((curpos += sp.lrpad / 2 - 1) < w && !hidecaret) {
curpos += fp; curpos += fp;
drw_rect(drw, x + curpos, 2 + (sp.bh - fh) / 2 + y, fw, fh - 4, 1, 0, col_caretfg, col_caretbg, alpha_caretfg, alpha_caretbg); draw_rect(draw, x + curpos, 2 + (sp.bh - fh) / 2 + y, fw, fh - 4, 1, 0, col_caretfg, col_caretbg, alpha_caretfg, alpha_caretbg);
} }
return x; return x;
@ -438,7 +438,7 @@ int drawlarrow(int x, int y, int w) {
if (hidelarrow) return x; if (hidelarrow) return x;
if (curr->left) { // draw left arrow if (curr->left) { // draw left arrow
drw_text(drw, x, y, w, sp.bh, sp.lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False, col_larrowfg, col_larrowbg, alpha_larrowfg, alpha_larrowbg); draw_text(draw, x, y, w, sp.bh, sp.lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False, col_larrowfg, col_larrowbg, alpha_larrowfg, alpha_larrowbg);
x += w; x += w;
} }
@ -449,7 +449,7 @@ int drawrarrow(int x, int y, int w) {
if (hiderarrow) return x; if (hiderarrow) return x;
if (next) { // draw right arrow if (next) { // draw right arrow
drw_text(drw, sp.mw - w, y, w, sp.bh, sp.lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False, col_rarrowfg, col_rarrowbg, alpha_rarrowfg, alpha_rarrowbg); draw_text(draw, sp.mw - w, y, w, sp.bh, sp.lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False, col_rarrowfg, col_rarrowbg, alpha_rarrowfg, alpha_rarrowbg);
x += w; x += w;
} }
@ -465,14 +465,14 @@ int drawnumber(int x, int y, int w) {
powerlinewidth = sp.plw / 2; powerlinewidth = sp.plw / 2;
} }
drw_text(drw, x, y, w, sp.bh, sp.lrpad / 2 + powerlinewidth, tx.numbers, 0, pango_numbers ? True : False, col_numfg, col_numbg, alpha_numfg, alpha_numbg); draw_text(draw, x, y, w, sp.bh, sp.lrpad / 2 + powerlinewidth, tx.numbers, 0, pango_numbers ? True : False, col_numfg, col_numbg, alpha_numfg, alpha_numbg);
// draw powerline for match count // draw powerline for match count
if (!hidepowerline && powerlinecount) { if (!hidepowerline && powerlinecount) {
if (matchcountpwlstyle == 2) { if (matchcountpwlstyle == 2) {
drw_circle(drw, x, y, sp.plw, sp.bh, 0, col_menu, col_numbg, alpha_menu, alpha_numbg); draw_circle(draw, x, y, sp.plw, sp.bh, 0, col_menu, col_numbg, alpha_menu, alpha_numbg);
} else { } else {
drw_arrow(drw, x, y, sp.plw, sp.bh, 0, matchcountpwlstyle, col_menu, col_numbg, alpha_menu, alpha_numbg); draw_arrow(draw, x, y, sp.plw, sp.bh, 0, matchcountpwlstyle, col_menu, col_numbg, alpha_menu, alpha_numbg);
} }
x += sp.plw; x += sp.plw;
@ -489,16 +489,16 @@ int drawmode(int x, int y, int w) {
powerlinewidth = sp.plw / 2; powerlinewidth = sp.plw / 2;
} }
drw_text(drw, x, y, w, sp.bh, sp.lrpad / 2 + powerlinewidth, tx.modetext, 0, pango_mode ? True : False, col_modefg, col_modebg, alpha_modefg, alpha_modebg); draw_text(draw, x, y, w, sp.bh, sp.lrpad / 2 + powerlinewidth, tx.modetext, 0, pango_mode ? True : False, col_modefg, col_modebg, alpha_modefg, alpha_modebg);
// draw powerline for match count // draw powerline for match count
if (!hidepowerline && powerlinemode) { if (!hidepowerline && powerlinemode) {
if (modepwlstyle == 2) { if (modepwlstyle == 2) {
drw_circle(drw, x, y, sp.plw, sp.bh, 0, draw_circle(draw, x, y, sp.plw, sp.bh, 0,
hidematchcount ? col_menu : col_numbg, col_modebg, hidematchcount ? col_menu : col_numbg, col_modebg,
hidematchcount ? alpha_menu : alpha_numbg, alpha_modebg); hidematchcount ? alpha_menu : alpha_numbg, alpha_modebg);
} else { } else {
drw_arrow(drw, x, y, sp.plw, sp.bh, 0, modepwlstyle, draw_arrow(draw, x, y, sp.plw, sp.bh, 0, modepwlstyle,
hidematchcount ? col_menu : col_numbg, col_modebg, hidematchcount ? col_menu : col_numbg, col_modebg,
hidematchcount ? alpha_menu : alpha_numbg, alpha_modebg); hidematchcount ? alpha_menu : alpha_numbg, alpha_modebg);
} }
@ -520,16 +520,16 @@ int drawcaps(int x, int y, int w) {
powerlinewidth = sp.plw / 2; powerlinewidth = sp.plw / 2;
} }
drw_text(drw, x, y, w, sp.bh, sp.lrpad / 2 + powerlinewidth, tx.capstext, 0, pango_caps ? True : False, col_capsfg, col_capsbg, alpha_capsfg, alpha_capsbg); draw_text(draw, x, y, w, sp.bh, sp.lrpad / 2 + powerlinewidth, tx.capstext, 0, pango_caps ? True : False, col_capsfg, col_capsbg, alpha_capsfg, alpha_capsbg);
// draw powerline for caps lock indicator // draw powerline for caps lock indicator
if (!hidepowerline && powerlinecaps) { if (!hidepowerline && powerlinecaps) {
if (capspwlstyle == 2) { if (capspwlstyle == 2) {
drw_circle(drw, x, y, sp.plw, sp.bh, 0, draw_circle(draw, x, y, sp.plw, sp.bh, 0,
hidemode ? hidematchcount ? col_menu : col_numbg : col_modebg, col_capsbg, hidemode ? hidematchcount ? col_menu : col_numbg : col_modebg, col_capsbg,
hidemode ? hidematchcount ? alpha_menu : alpha_numbg : alpha_modebg, alpha_capsbg); hidemode ? hidematchcount ? alpha_menu : alpha_numbg : alpha_modebg, alpha_capsbg);
} else { } else {
drw_arrow(drw, x, y, sp.plw, sp.bh, 0, capspwlstyle, draw_arrow(draw, x, y, sp.plw, sp.bh, 0, capspwlstyle,
hidemode ? hidematchcount ? col_menu : col_numbg : col_modebg, col_capsbg, hidemode ? hidematchcount ? col_menu : col_numbg : col_modebg, col_capsbg,
hidemode ? hidematchcount ? alpha_menu : alpha_numbg : alpha_modebg, alpha_capsbg); hidemode ? hidematchcount ? alpha_menu : alpha_numbg : alpha_modebg, alpha_capsbg);
} }
@ -580,10 +580,10 @@ void drawmenu(void) {
void drawmenu_layer(void) { void drawmenu_layer(void) {
int x = 0, y = 0, w = 0; int x = 0, y = 0, w = 0;
sp.plw = hidepowerline ? 0 : drw->font->h / 2 + 1; // powerline size sp.plw = hidepowerline ? 0 : draw->font->h / 2 + 1; // powerline size
// draw menu first using menu scheme // draw menu first using menu scheme
drw_rect(drw, 0, 0, sp.mw, sp.mh, 1, 1, col_menu, col_menu, alpha_menu, alpha_menu); draw_rect(draw, 0, 0, sp.mw, sp.mh, 1, 1, col_menu, col_menu, alpha_menu, alpha_menu);
int numberWidth = 0; int numberWidth = 0;
int modeWidth = 0; int modeWidth = 0;
@ -647,6 +647,6 @@ void drawmenu_layer(void) {
#if USEIMAGE #if USEIMAGE
drawimage(); drawimage();
#endif #endif
drw_map(drw, win, 0, 0, sp.mw, sp.mh); draw_map(draw, win, 0, 0, sp.mw, sp.mh);
#endif #endif
} }

View file

@ -39,72 +39,72 @@ void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha) {
} }
#if USEX #if USEX
Drw *drw_create_x11(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol) { Draw_t *draw_create_x11(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol) {
Drw *drw = ecalloc(1, sizeof(Drw)); Draw_t *draw = ecalloc(1, sizeof(Draw_t));
drw->protocol = protocol; draw->protocol = protocol;
drw->dpy = dpy; draw->dpy = dpy;
drw->screen = screen; draw->screen = screen;
drw->root = root; draw->root = root;
drw->w = w; draw->w = w;
drw->h = h; draw->h = h;
drw->visual = visual; draw->visual = visual;
drw->depth = depth; draw->depth = depth;
drw->cmap = cmap; draw->cmap = cmap;
drw->drawable = XCreatePixmap(dpy, root, w, h, depth); draw->drawable = XCreatePixmap(dpy, root, w, h, depth);
drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL); draw->gc = XCreateGC(dpy, draw->drawable, 0, NULL);
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter); XSetLineAttributes(dpy, draw->gc, 1, LineSolid, CapButt, JoinMiter);
return drw; return draw;
} }
#endif #endif
#if USEWAYLAND #if USEWAYLAND
Drw *drw_create_wl(int protocol) { Draw_t *draw_create_wl(int protocol) {
Drw *drw = ecalloc(1, sizeof(Drw)); Draw_t *draw = ecalloc(1, sizeof(Draw_t));
drw->protocol = protocol; draw->protocol = protocol;
return drw; return draw;
} }
void drw_create_surface_wl(Drw *drw, void *data, int32_t w, int32_t h) { void draw_create_surface_wl(Draw_t *draw, void *data, int32_t w, int32_t h) {
drw->data = data; draw->data = data;
drw->w = w; draw->w = w;
drw->h = h; draw->h = h;
drw->surface = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4); draw->surface = cairo_image_surface_create_for_data(draw->data, CAIRO_FORMAT_ARGB32, draw->w, draw->h, draw->w * 4);
drw->d = cairo_create(drw->surface); draw->d = cairo_create(draw->surface);
} }
#endif #endif
void drw_resize(Drw *drw, unsigned int w, unsigned int h) { void draw_resize(Draw_t *draw, unsigned int w, unsigned int h) {
if (!drw) if (!draw)
return; return;
drw->w = w; draw->w = w;
drw->h = h; draw->h = h;
#if USEX #if USEX
if (drw->drawable) if (draw->drawable)
XFreePixmap(drw->dpy, drw->drawable); XFreePixmap(draw->dpy, draw->drawable);
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth); draw->drawable = XCreatePixmap(draw->dpy, draw->root, w, h, draw->depth);
#endif #endif
} }
void drw_free(Drw *drw) { void draw_free(Draw_t *draw) {
#if USEX #if USEX
if (!drw->protocol) { if (!draw->protocol) {
XFreePixmap(drw->dpy, drw->drawable); XFreePixmap(draw->dpy, draw->drawable);
XFreeGC(drw->dpy, drw->gc); XFreeGC(draw->dpy, draw->gc);
} }
#endif #endif
drw_font_free(drw->font); draw_font_free(draw->font);
free(drw); free(draw);
} }
static Fnt *font_create(Drw *drw, const char *fontname) { static Fnt *font_create(Draw_t *draw, const char *fontname) {
Fnt *font; Fnt *font;
PangoFontMap *fontmap; PangoFontMap *fontmap;
PangoContext *context; PangoContext *context;
@ -116,7 +116,7 @@ static Fnt *font_create(Drw *drw, const char *fontname) {
} }
font = ecalloc(1, sizeof(Fnt)); font = ecalloc(1, sizeof(Fnt));
font->dpy = drw->dpy; font->dpy = draw->dpy;
fontmap = pango_cairo_font_map_new(); fontmap = pango_cairo_font_map_new();
context = pango_font_map_create_context(fontmap); context = pango_font_map_create_context(fontmap);
@ -141,25 +141,25 @@ void font_free(Fnt *font) {
free(font); free(font);
} }
Fnt* drw_font_create(Drw* drw, char *font[], size_t fontcount) { Fnt* draw_font_create(Draw_t* draw, char *font[], size_t fontcount) {
if (!drw || !font) if (!draw || !font)
return NULL; return NULL;
Fnt *fnt = NULL; Fnt *fnt = NULL;
fnt = font_create(drw, *font); fnt = font_create(draw, *font);
return (drw->font = fnt); return (draw->font = fnt);
} }
void drw_font_free(Fnt *font) { void draw_font_free(Fnt *font) {
if (font) { if (font) {
font_free(font); font_free(font);
} }
} }
void drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash, char *prevcol, char *nextcol, int prevalpha, int nextalpha) { void draw_arrow(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int direction, int slash, char *prevcol, char *nextcol, int prevalpha, int nextalpha) {
if (!drw) if (!draw)
return; return;
x = direction ? x : x + w; x = direction ? x : x + w;
@ -169,10 +169,10 @@ void drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direc
cairo_surface_t *sf = NULL; cairo_surface_t *sf = NULL;
if (drw->protocol) { if (draw->protocol) {
sf = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4); sf = cairo_image_surface_create_for_data(draw->data, CAIRO_FORMAT_ARGB32, draw->w, draw->h, draw->w * 4);
} else { } else {
sf = cairo_xlib_surface_create(drw->dpy, drw->drawable, drw->visual, drw->w, drw->h); sf = cairo_xlib_surface_create(draw->dpy, draw->drawable, draw->visual, draw->w, draw->h);
} }
cairo_t *cr = cairo_create(sf); cairo_t *cr = cairo_create(sf);
@ -194,16 +194,16 @@ void drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direc
cairo_surface_destroy(sf); cairo_surface_destroy(sf);
} }
void drw_circle(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, char *prevcol, char *nextcol, int prevalpha, int nextalpha) { void draw_circle(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int direction, char *prevcol, char *nextcol, int prevalpha, int nextalpha) {
if (!drw) if (!draw)
return; return;
cairo_surface_t *sf = NULL; cairo_surface_t *sf = NULL;
if (drw->protocol) { if (draw->protocol) {
sf = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4); sf = cairo_image_surface_create_for_data(draw->data, CAIRO_FORMAT_ARGB32, draw->w, draw->h, draw->w * 4);
} else { } else {
sf = cairo_xlib_surface_create(drw->dpy, drw->drawable, drw->visual, drw->w, drw->h); sf = cairo_xlib_surface_create(draw->dpy, draw->drawable, draw->visual, draw->w, draw->h);
} }
cairo_t *cr = cairo_create(sf); cairo_t *cr = cairo_create(sf);
@ -233,17 +233,17 @@ void drw_circle(Drw *drw, int x, int y, unsigned int w, unsigned int h, int dire
cairo_surface_destroy(sf); cairo_surface_destroy(sf);
} }
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert, char *fgcol, char *bgcol, int fgalpha, int bgalpha) { void draw_rect(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int filled, int invert, char *fgcol, char *bgcol, int fgalpha, int bgalpha) {
if (!drw) { if (!draw) {
return; return;
} }
cairo_surface_t *sf; cairo_surface_t *sf;
if (drw->protocol) { if (draw->protocol) {
sf = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4); sf = cairo_image_surface_create_for_data(draw->data, CAIRO_FORMAT_ARGB32, draw->w, draw->h, draw->w * 4);
} else { } else {
sf = cairo_xlib_surface_create(drw->dpy, drw->drawable, drw->visual, drw->w, drw->h); sf = cairo_xlib_surface_create(draw->dpy, draw->drawable, draw->visual, draw->w, draw->h);
} }
cairo_t *cr = cairo_create(sf); cairo_t *cr = cairo_create(sf);
@ -266,7 +266,7 @@ void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled
cairo_surface_destroy(sf); cairo_surface_destroy(sf);
} }
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup, char *fgcol, char *bgcol, int fgalpha, int bgalpha) { int draw_text(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup, char *fgcol, char *bgcol, int fgalpha, int bgalpha) {
char buf[1024]; char buf[1024];
unsigned int ew = 0; unsigned int ew = 0;
@ -274,7 +274,7 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
int render = x || y || w || h; int render = x || y || w || h;
char *t; char *t;
if (!drw || !text || !drw->font) { if (!draw || !text || !draw->font) {
return 0; return 0;
} }
@ -284,28 +284,28 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
x += lpad; x += lpad;
w -= lpad; w -= lpad;
if (drw->protocol) { if (draw->protocol) {
drw->surface = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4); draw->surface = cairo_image_surface_create_for_data(draw->data, CAIRO_FORMAT_ARGB32, draw->w, draw->h, draw->w * 4);
} else { } else {
drw->surface = cairo_xlib_surface_create(drw->dpy, drw->drawable, drw->visual, drw->w, drw->h); draw->surface = cairo_xlib_surface_create(draw->dpy, draw->drawable, draw->visual, draw->w, draw->h);
} }
drw->d = cairo_create(drw->surface); draw->d = cairo_create(draw->surface);
// draw bg // draw bg
cairo_set_source_hex(drw->d, invert ? fgcol : bgcol, invert ? fgalpha : bgalpha); cairo_set_source_hex(draw->d, invert ? fgcol : bgcol, invert ? fgalpha : bgalpha);
cairo_set_operator(drw->d, CAIRO_OPERATOR_SOURCE); cairo_set_operator(draw->d, CAIRO_OPERATOR_SOURCE);
cairo_rectangle(drw->d, x - lpad, y, w + lpad, h); cairo_rectangle(draw->d, x - lpad, y, w + lpad, h);
cairo_fill(drw->d); cairo_fill(draw->d);
} }
t = strdup(text); t = strdup(text);
len = strlen(t); len = strlen(t);
if (len) { if (len) {
drw_font_getexts(drw->font, t, len, &ew, NULL, markup); draw_font_getexts(draw->font, t, len, &ew, NULL, markup);
// shorten text if necessary // shorten text if necessary
for (len = MIN(len, sizeof(buf) - 1); len && ew > w; drw_font_getexts(drw->font, t, len, &ew, NULL, markup)) for (len = MIN(len, sizeof(buf) - 1); len && ew > w; draw_font_getexts(draw->font, t, len, &ew, NULL, markup))
len--; len--;
if (len) { if (len) {
@ -320,25 +320,25 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
if (render) { if (render) {
if (markup) { if (markup) {
pango_layout_set_markup(drw->font->layout, buf, len); pango_layout_set_markup(draw->font->layout, buf, len);
} else { } else {
pango_layout_set_text(drw->font->layout, buf, len); pango_layout_set_text(draw->font->layout, buf, len);
} }
pango_layout_set_single_paragraph_mode(drw->font->layout, True); pango_layout_set_single_paragraph_mode(draw->font->layout, True);
// draw fg // draw fg
cairo_set_source_hex(drw->d, fgcol, fgalpha); cairo_set_source_hex(draw->d, fgcol, fgalpha);
cairo_move_to(drw->d, x, y + (h - drw->font->h) / 2); cairo_move_to(draw->d, x, y + (h - draw->font->h) / 2);
// update and show layout // update and show layout
pango_cairo_update_layout(drw->d, drw->font->layout); pango_cairo_update_layout(draw->d, draw->font->layout);
pango_cairo_show_layout(drw->d, drw->font->layout); pango_cairo_show_layout(draw->d, draw->font->layout);
cairo_set_operator(drw->d, CAIRO_OPERATOR_SOURCE); cairo_set_operator(draw->d, CAIRO_OPERATOR_SOURCE);
if (markup) // clear markup attributes if (markup) // clear markup attributes
pango_layout_set_attributes(drw->font->layout, NULL); pango_layout_set_attributes(draw->font->layout, NULL);
} }
x += ew; x += ew;
@ -349,25 +349,25 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned in
return x + (render ? w : 0); return x + (render ? w : 0);
} }
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h) { void draw_map(Draw_t *draw, Window win, int x, int y, unsigned int w, unsigned int h) {
if (!drw) if (!draw)
return; return;
#if USEX #if USEX
if (!drw->protocol) { if (!draw->protocol) {
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y); XCopyArea(draw->dpy, draw->drawable, win, draw->gc, x, y, w, h, x, y);
XSync(drw->dpy, False); XSync(draw->dpy, False);
} }
#endif #endif
} }
unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup) { unsigned int draw_font_getwidth(Draw_t *draw, const char *text, Bool markup) {
if (!drw || !drw->font || !text) if (!draw || !draw->font || !text)
return 0; return 0;
return drw_text(drw, 0, 0, 0, 0, 0, text, 0, markup, "#000000", "#000000", 255, 255); return draw_text(draw, 0, 0, 0, 0, 0, text, 0, markup, "#000000", "#000000", 255, 255);
} }
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup) { void draw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup) {
if (!font || !text) if (!font || !text)
return; return;
@ -395,31 +395,31 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
*h = font->h; *h = font->h;
} }
void drw_set_img(Drw *drw, void *data, int w, int h) { void draw_set_img(Draw_t *draw, void *data, int w, int h) {
if (!w || !h || !drw) { if (!w || !h || !draw) {
return; return;
} }
drw->img_data = data; draw->img_data = data;
drw->img_surface = cairo_image_surface_create_for_data(drw->img_data, CAIRO_FORMAT_ARGB32, w, h, w * 4); draw->img_surface = cairo_image_surface_create_for_data(draw->img_data, CAIRO_FORMAT_ARGB32, w, h, w * 4);
} }
void drw_img(Drw *drw, int x, int y) { void draw_img(Draw_t *draw, int x, int y) {
if (!drw) { if (!draw) {
return; return;
} }
cairo_set_operator(drw->d, CAIRO_OPERATOR_OVER); cairo_set_operator(draw->d, CAIRO_OPERATOR_OVER);
cairo_set_source_surface(drw->d, drw->img_surface, x, y); cairo_set_source_surface(draw->d, draw->img_surface, x, y);
cairo_mask_surface(drw->d, drw->img_surface, x, y); cairo_mask_surface(draw->d, draw->img_surface, x, y);
cairo_set_source_surface(drw->d, drw->surface, drw->w, drw->h); cairo_set_source_surface(draw->d, draw->surface, draw->w, draw->h);
} }
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n, Bool markup) { unsigned int draw_fontset_getwidth_clamp(Draw_t *draw, const char *text, unsigned int n, Bool markup) {
unsigned int tmp = 0; unsigned int tmp = 0;
if (drw && drw->font && text && n) if (draw && draw->font && text && n)
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n, markup, "#000000", "#000000", 255, 255); tmp = draw_text(draw, 0, 0, 0, 0, 0, text, n, markup, "#000000", "#000000", 255, 255);
return MIN(n, tmp); return MIN(n, tmp);
} }

View file

@ -30,37 +30,37 @@ typedef struct {
cairo_surface_t *img_surface; cairo_surface_t *img_surface;
cairo_t *d; cairo_t *d;
cairo_t *img_d; cairo_t *img_d;
} Drw; } Draw_t;
/* Cairo color convertion */ /* Cairo color convertion */
void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha); void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha);
/* Cairo image drawing */ /* Cairo image drawing */
void drw_img(Drw *drw, int x, int y); void draw_img(Draw_t *draw, int x, int y);
void drw_set_img(Drw *drw, void *data, int w, int h); void draw_set_img(Draw_t *draw, void *data, int w, int h);
/* Drawable abstraction */ /* Drawable abstraction */
Drw *drw_create_x11(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol); Draw_t *draw_create_x11(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol);
Drw *drw_create_wl(int protocol); Draw_t *draw_create_wl(int protocol);
void drw_create_surface_wl(Drw *drw, void *data, int32_t w, int32_t h); void draw_create_surface_wl(Draw_t *draw, void *data, int32_t w, int32_t h);
void drw_resize(Drw *drw, unsigned int w, unsigned int h); void draw_resize(Draw_t *draw, unsigned int w, unsigned int h);
void drw_free(Drw *drw); void draw_free(Draw_t *draw);
/* Fnt abstraction */ /* Fnt abstraction */
Fnt *drw_font_create(Drw* drw, char *font[], size_t fontcount); Fnt *draw_font_create(Draw_t* draw, char *font[], size_t fontcount);
void drw_font_free(Fnt* set); void draw_font_free(Fnt* set);
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n, Bool markup); unsigned int draw_fontset_getwidth_clamp(Draw_t *draw, const char *text, unsigned int n, Bool markup);
unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup); unsigned int draw_font_getwidth(Draw_t *draw, const char *text, Bool markup);
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup); void draw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h, Bool markup);
/* Drawing functions */ /* Drawing functions */
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert, char *fgcol, char *bgcol, int fgalpha, int bgalpha); void draw_rect(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int filled, int invert, char *fgcol, char *bgcol, int fgalpha, int bgalpha);
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup, char *fgcol, char *bgcol, int fgalpha, int bgalpha); int draw_text(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert, Bool markup, char *fgcol, char *bgcol, int fgalpha, int bgalpha);
/* Map functions */ /* Map functions */
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); void draw_map(Draw_t *draw, Window win, int x, int y, unsigned int w, unsigned int h);
/* Powerline functions */ /* Powerline functions */
void drw_arrow(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, int slash, char *prevcol, char *nextcol, int prevalpha, int nextalpha); void draw_arrow(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int direction, int slash, char *prevcol, char *nextcol, int prevalpha, int nextalpha);
void drw_circle(Drw *drw, int x, int y, unsigned int w, unsigned int h, int direction, char *prevcol, char *nextcol, int prevalpha, int nextalpha); void draw_circle(Draw_t *draw, int x, int y, unsigned int w, unsigned int h, int direction, char *prevcol, char *nextcol, int prevalpha, int nextalpha);

View file

@ -68,11 +68,11 @@ void drawimage(void) {
resizetoimageheight(width, imlib_image_get_height() - (fullscreen ? 2 * menumarginv : 0)); resizetoimageheight(width, imlib_image_get_height() - (fullscreen ? 2 * menumarginv : 0));
} }
drw_set_img(drw, imlib_image_get_data(), width, height); draw_set_img(draw, imlib_image_get_data(), width, height);
if (fullscreen) { if (fullscreen) {
xta = wta = leftmargin = 0; xta = wta = leftmargin = 0;
drw_img(drw, (imagewidth - width) / 2, 0); draw_img(draw, (imagewidth - width) / 2, 0);
if (sel) { if (sel) {
limg = sel->image; limg = sel->image;
@ -88,17 +88,17 @@ void drawimage(void) {
if (height > width) if (height > width)
width = height; width = height;
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, wta + leftmargin); draw_img(draw, leftmargin + (imagewidth - width) / 2 + xta, wta + leftmargin);
} else if (imageposition == 1 && image) { // bottom mode = 1 } else if (imageposition == 1 && image) { // bottom mode = 1
if (height > width) if (height > width)
width = height; width = height;
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, sp.mh - height - leftmargin); draw_img(draw, leftmargin + (imagewidth - width) / 2 + xta, sp.mh - height - leftmargin);
} else if (imageposition == 2 && image) { // center mode = 2 } else if (imageposition == 2 && image) { // center mode = 2
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, (sp.mh - wta - height) / 2 + wta); draw_img(draw, leftmargin + (imagewidth - width) / 2 + xta, (sp.mh - wta - height) / 2 + wta);
} else if (image) { // top center } else if (image) { // top center
int minh = MIN(height, sp.mh - sp.bh - leftmargin * 2); int minh = MIN(height, sp.mh - sp.bh - leftmargin * 2);
drw_img(drw, leftmargin + (imagewidth - width) / 2 + xta, (minh - height) / 2 + wta + leftmargin); draw_img(draw, leftmargin + (imagewidth - width) / 2 + xta, (minh - height) / 2 + wta + leftmargin);
} }
} }
@ -424,7 +424,7 @@ void resizetoimageheight_x11(int imageheight) {
} }
XMoveResizeWindow(dpy, win, x + sp.sp, y + sp.vp, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh); XMoveResizeWindow(dpy, win, x + sp.sp, y + sp.vp, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh);
drw_resize(drw, sp.mw - 2 * sp.sp - borderwidth, sp.mh); draw_resize(draw, sp.mw - 2 * sp.sp - borderwidth, sp.mh);
if (olines != lines) { if (olines != lines) {
struct item *item; struct item *item;
@ -476,8 +476,8 @@ void resizetoimageheight_wl(int imageheight) {
state.buffer = create_buffer(&state); state.buffer = create_buffer(&state);
if (drw == NULL) { if (draw == NULL) {
die("spmenu: drw == NULL"); die("spmenu: draw == NULL");
} }
if (state.buffer == NULL) { if (state.buffer == NULL) {
@ -485,7 +485,7 @@ void resizetoimageheight_wl(int imageheight) {
} }
set_layer_size(&state, state.width, state.height); set_layer_size(&state, state.width, state.height);
drw_create_surface_wl(drw, state.data, state.width, state.height); draw_create_surface_wl(draw, state.data, state.width, state.height);
drawmenu(); drawmenu();

View file

@ -29,7 +29,7 @@ void readstdin(void) {
if (!(items[i].text = strdup(buf))) if (!(items[i].text = strdup(buf)))
die("spmenu: cannot strdup %u bytes:", strlen(buf) + 1); die("spmenu: cannot strdup %u bytes:", strlen(buf) + 1);
items[i].hp = arrayhas(hpitems, hplength, items[i].text); items[i].hp = arrayhas(hpitems, hplength, items[i].text);
drw_font_getexts(drw->font, buf, strlen(buf), &tmpmax, NULL, True); draw_font_getexts(draw->font, buf, strlen(buf), &tmpmax, NULL, True);
if (tmpmax > sp.inputw) { if (tmpmax > sp.inputw) {
sp.inputw = tmpmax; sp.inputw = tmpmax;
} }

View file

@ -4,13 +4,13 @@ void prepare_window_size_wl(void) {
sp.sp = menupaddingh; sp.sp = menupaddingh;
sp.vp = (menuposition == 1) ? menupaddingv : - menupaddingv; sp.vp = (menuposition == 1) ? menupaddingv : - menupaddingv;
sp.bh = MAX(drw->font->h, drw->font->h + 2 + lineheight); sp.bh = MAX(draw->font->h, draw->font->h + 2 + lineheight);
lines = MAX(lines, 0); lines = MAX(lines, 0);
#if USEIMAGE #if USEIMAGE
img.setlines = lines; img.setlines = lines;
#endif #endif
sp.lrpad = drw->font->h + textpadding; sp.lrpad = draw->font->h + textpadding;
return; return;
} }

View file

@ -429,15 +429,15 @@ void draw_sf(struct state *state) {
// create buffer to draw on // create buffer to draw on
state->buffer = create_buffer(state); state->buffer = create_buffer(state);
if (drw == NULL) { if (draw == NULL) {
die("spmenu: drw == NULL"); die("spmenu: draw == NULL");
} }
if (state->buffer == NULL) { if (state->buffer == NULL) {
die("state->buffer == NULL"); die("state->buffer == NULL");
} }
drw_create_surface_wl(drw, state->data, state->width, state->height); draw_create_surface_wl(draw, state->data, state->width, state->height);
drawmenu_layer(); drawmenu_layer();
@ -540,7 +540,7 @@ void resizeclient_wl(struct state *state) {
for (item = items; item && item->text; item++) for (item = items; item && item->text; item++)
ic++; ic++;
sp.bh = MAX(drw->font->h, drw->font->h + 2 + lineheight); sp.bh = MAX(draw->font->h, draw->font->h + 2 + lineheight);
lines = MIN(ic, MAX(lines, 0)); lines = MIN(ic, MAX(lines, 0));
#if USEIMAGE #if USEIMAGE
img.setlines = lines; img.setlines = lines;
@ -560,15 +560,15 @@ void resizeclient_wl(struct state *state) {
state->buffer = create_buffer(state); state->buffer = create_buffer(state);
if (drw == NULL) { if (draw == NULL) {
die("spmenu: drw == NULL"); die("spmenu: draw == NULL");
} }
if (state->buffer == NULL) { if (state->buffer == NULL) {
die("state->buffer == null"); die("state->buffer == null");
} }
drw_create_surface_wl(drw, state->data, state->width, state->height); draw_create_surface_wl(draw, state->data, state->width, state->height);
set_layer_size(state, state->width, state->height); set_layer_size(state, state->width, state->height);
wl_surface_set_buffer_scale(state->surface, 1); wl_surface_set_buffer_scale(state->surface, 1);

View file

@ -87,7 +87,7 @@ void resizeclient_x11(void) {
for (item = items; item && item->text; item++) for (item = items; item && item->text; item++)
ic++; ic++;
sp.bh = MAX(drw->font->h, drw->font->h + 2 + lineheight); sp.bh = MAX(draw->font->h, draw->font->h + 2 + lineheight);
lines = MIN(ic, MAX(lines, 0)); lines = MIN(ic, MAX(lines, 0));
#if USEIMAGE #if USEIMAGE
img.setlines = lines; img.setlines = lines;
@ -165,7 +165,7 @@ void resizeclient_x11(void) {
if (!win || mh == sp.mh) return; if (!win || mh == sp.mh) return;
XMoveResizeWindow(dpy, win, x + sp.sp, y + sp.vp, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh); XMoveResizeWindow(dpy, win, x + sp.sp, y + sp.vp, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh);
drw_resize(drw, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh); draw_resize(draw, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh);
} }
void xinitvisual(void) { void xinitvisual(void) {

View file

@ -19,7 +19,7 @@ void eventloop_x11(void) {
break; break;
case Expose: case Expose:
if (ev.xexpose.count == 0) if (ev.xexpose.count == 0)
drw_map(drw, win, 0, 0, sp.mw, sp.mh); draw_map(draw, win, 0, 0, sp.mw, sp.mh);
break; break;
case FocusIn: case FocusIn:
// regrab focus from parent window // regrab focus from parent window

View file

@ -119,7 +119,7 @@ void setupdisplay_x11(void) {
} }
// resize window and draw // resize window and draw
drw_resize(drw, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh); draw_resize(draw, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh);
match(); match();
drawmenu(); drawmenu();
@ -129,13 +129,13 @@ void prepare_window_size_x11(void) {
sp.sp = menupaddingh; sp.sp = menupaddingh;
sp.vp = (menuposition == 1) ? menupaddingv : - menupaddingv; sp.vp = (menuposition == 1) ? menupaddingv : - menupaddingv;
sp.bh = MAX(drw->font->h, drw->font->h + 2 + lineheight); sp.bh = MAX(draw->font->h, draw->font->h + 2 + lineheight);
lines = MAX(lines, 0); lines = MAX(lines, 0);
#if USEIMAGE #if USEIMAGE
img.setlines = lines; img.setlines = lines;
#endif #endif
sp.lrpad = drw->font->h + textpadding; sp.lrpad = draw->font->h + textpadding;
get_mh(); get_mh();
return; return;
@ -174,7 +174,7 @@ void handle_x11(void) {
} }
xinitvisual(); // init visual and create drawable after xinitvisual(); // init visual and create drawable after
drw = drw_create_x11(dpy, x11.screen, root, wa.width, wa.height, x11.visual, x11.depth, x11.cmap, protocol); draw = draw_create_x11(dpy, x11.screen, root, wa.width, wa.height, x11.visual, x11.depth, x11.cmap, protocol);
} }
void cleanup_x11(Display *disp) { void cleanup_x11(Display *disp) {

View file

@ -190,7 +190,7 @@ static struct item *prev, *curr, *next, *sel;
#include "libs/sort.h" #include "libs/sort.h"
#include "libs/history.h" #include "libs/history.h"
static Drw *drw; static Draw_t *draw;
// high priority // high priority
static int hplength = 0; static int hplength = 0;
@ -382,7 +382,7 @@ void cleanup(void) {
free(hpitems[i]); free(hpitems[i]);
// free drawing and close the display // free drawing and close the display
drw_free(drw); draw_free(draw);
#if USEX #if USEX
if (!protocol) { if (!protocol) {
@ -509,7 +509,7 @@ void handle(void) {
#if USEX #if USEX
handle_x11(); handle_x11();
if (!drw_font_create(drw, fonts, LENGTH(fonts))) { if (!draw_font_create(draw, fonts, LENGTH(fonts))) {
die("no fonts could be loaded."); die("no fonts could be loaded.");
} }
@ -547,9 +547,9 @@ void handle(void) {
borderwidth = 0; borderwidth = 0;
managed = 0; managed = 0;
drw = drw_create_wl(protocol); draw = draw_create_wl(protocol);
if (!drw_font_create(drw, fonts, LENGTH(fonts))) { if (!draw_font_create(draw, fonts, LENGTH(fonts))) {
die("no fonts could be loaded."); die("no fonts could be loaded.");
} }