remove textw function, change it with a macro

This commit is contained in:
Julien Danjou 2007-09-06 22:09:00 +02:00
parent 9a6cc53933
commit bd5bef5acf
2 changed files with 17 additions and 21 deletions

33
draw.c
View File

@ -12,19 +12,6 @@ extern Client *clients, *sel, *stack; /* global client list and stack */
/* static */ /* static */
static unsigned int
textnw(const char *text, unsigned int len)
{
XRectangle r;
if(dc.font.set)
{
XmbTextExtents(dc.font.set, text, len, NULL, &r);
return r.width;
}
return XTextWidth(dc.font.xfont, text, len);
}
static void static void
drawtext(Display *disp, const char *text, unsigned long col[ColLast]) drawtext(Display *disp, const char *text, unsigned long col[ColLast])
{ {
@ -109,6 +96,19 @@ isoccupied(unsigned int t)
/* extern */ /* extern */
unsigned int
textnw(const char *text, unsigned int len)
{
XRectangle r;
if(dc.font.set)
{
XmbTextExtents(dc.font.set, text, len, NULL, &r);
return r.width;
}
return XTextWidth(dc.font.xfont, text, len);
}
void void
drawstatus(Display *disp, jdwm_config * jdwmconf) drawstatus(Display *disp, jdwm_config * jdwmconf)
{ {
@ -154,10 +154,3 @@ drawstatus(Display *disp, jdwm_config * jdwmconf)
XCopyArea(disp, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); XCopyArea(disp, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
XSync(disp, False); XSync(disp, False);
} }
inline unsigned int
textw(const char *text)
{
return textnw(text, strlen(text)) + dc.font.height;
}

5
draw.h
View File

@ -3,9 +3,12 @@
#ifndef JDWM_DRAW_H #ifndef JDWM_DRAW_H
#define JDWM_DRAW_H #define JDWM_DRAW_H
#include <string.h>
#include "config.h" #include "config.h"
#define textw(text) (textnw(text, strlen(text)) + dc.font.height)
void drawstatus(Display *, jdwm_config *); /* draw the bar */ void drawstatus(Display *, jdwm_config *); /* draw the bar */
inline unsigned int textw(const char *text); /* return the width of text in px */ unsigned int textnw(const char *, unsigned int);
#endif #endif