Don't reallocate drawables on every string op. - sam - An updated version of th… | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 4e40c16f1a9abc8c426a65a69bc56800306439aa | |
parent edf98760edc54f65d220af07e4b96c9599948fc8 | |
Author: Rob King <[email protected]> | |
Date: Thu, 11 Aug 2016 14:15:48 -0500 | |
Don't reallocate drawables on every string op. | |
Diffstat: | |
include/libg.h | 1 + | |
libXg/balloc.c | 5 ++++- | |
libXg/string.c | 6 +++--- | |
libXg/xtbinit.c | 1 + | |
4 files changed, 9 insertions(+), 4 deletions(-) | |
--- | |
diff --git a/include/libg.h b/include/libg.h | |
@@ -48,6 +48,7 @@ struct Bitmap | |
int ldepth; | |
int id; /* as known by the X server */ | |
Bitmap *cache; /* zero; distinguishes bitmap fro… | |
+ XftDraw *fd; /* font drawable */ | |
int flag; /* flag used by X implementation of li… | |
}; | |
diff --git a/libXg/balloc.c b/libXg/balloc.c | |
@@ -22,7 +22,7 @@ _balloc(Rectangle r, int ldepth) | |
int ld; | |
Rectangle rx; | |
- b = (Bitmap *)malloc(sizeof(Bitmap)); | |
+ b = (Bitmap *)calloc(1, sizeof(Bitmap)); | |
if(b == 0) | |
berror("balloc malloc"); | |
if (ldepth == 0) | |
@@ -55,6 +55,9 @@ _balloc(Rectangle r, int ldepth) | |
void | |
bfree(Bitmap *b) | |
{ | |
+ if (b->fd) | |
+ XftDrawDestroy(b->fd); | |
+ | |
XFreePixmap(_dpy, (Pixmap)b->id); | |
free(b); | |
} | |
diff --git a/libXg/string.c b/libXg/string.c | |
@@ -25,10 +25,10 @@ string(Bitmap *b, Point p, XftFont *ft, char *s, Fcode f) | |
} | |
y += ft->ascent; | |
- XftDraw *drawable = XftDrawCreate(_dpy, (Drawable)(b->id), DefaultVisu… | |
+ if (!b->fd) | |
+ b->fd = XftDrawCreate(_dpy, (Drawable)(b->id), DefaultVisual(_dpy,… | |
- XftDrawStringUtf8(drawable, &fontcolor, ft, x, y, s, length); | |
- XftDrawDestroy(drawable); | |
+ XftDrawStringUtf8(b->fd, &fontcolor, ft, x, y, s, length); | |
x += extents.xOff; | |
diff --git a/libXg/xtbinit.c b/libXg/xtbinit.c | |
@@ -181,6 +181,7 @@ xtbinit(Errfunc f, char *class, int *pargc, char **argv, ch… | |
screen.id = 0; | |
XtRealizeWidget(_toplevel); | |
+ | |
pid_t pid = getpid(); | |
XChangeProperty(_dpy, XtWindow(_toplevel), XInternAtom(_dpy, "_NET_WM_PID"… | |