diff --git a/CMakeLists.txt b/CMakeLists.txt index 0255b8e..f0824df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,8 +135,6 @@ else() set(WMFS_HAVE_IMLIB "") endif() - - target_link_libraries(wmfs ${LIBRARIES_TO_LINK}) # Messages diff --git a/src/draw.c b/src/draw.c index e017f03..6067ac5 100644 --- a/src/draw.c +++ b/src/draw.c @@ -49,6 +49,20 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str) if(!str) return; + /* To draw image everywhere we can draw text */ +#ifdef HAVE_IMLIB + char *ostr = NULL; + int i, ni; + StatusImage im[56]; + + ostr = _strdup(str); + + ni = statustext_image(im, str); + + for(i = 0; i < ni; ++i) + draw_image(d, im[i].x, im[i].y, im[i].w, im[i].h, im[i].name); +#endif /* HAVE_IMLIB */ + /* Transform X Drawable -> Xft Drawable */ xftd = XftDrawCreate(dpy, d, DefaultVisual(dpy, SCREEN), DefaultColormap(dpy, SCREEN)); @@ -63,6 +77,11 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str) XftDrawDestroy(xftd); +#ifdef HAVE_IMLIB + strcpy(str, ostr); + IFREE(ostr); +#endif /* HAVE_IMLIB */ + return; } @@ -90,7 +109,7 @@ draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color) * \param dr Drawable * \param x X position * \param y Y position - * \param name Path of the XPM + * \param name Path of the image */ void draw_image(Drawable dr, int x, int y, int w, int h, char *name) @@ -132,15 +151,30 @@ draw_image(Drawable dr, int x, int y, int w, int h, char *name) * \return final text width */ ushort -textw(const char *text) +textw(char *text) { XGlyphInfo gl; if(!text) return 0; +#ifdef HAVE_IMLIB + char *ostr = NULL; + + StatusImage im[56]; + + ostr = _strdup(text); + + statustext_image(im, text); +#endif /* HAVE_IMLIB */ + XftTextExtentsUtf8(dpy, font, (FcChar8 *)text, strlen(text), &gl); +#ifdef HAVE_IMLIB + strcpy(text, ostr); + IFREE(ostr); +#endif /* HAVE_IMLIB */ + return gl.width + font->descent; } diff --git a/src/status.c b/src/status.c index a6fa48b..f35cfff 100644 --- a/src/status.c +++ b/src/status.c @@ -94,7 +94,6 @@ statustext_image(StatusImage *im, char *str) int n, i, j, k; for(i = j = n = 0; i < strlen(str); ++i, ++j) - /* %512[^]] */ if(sscanf(&str[i], "\\i[%d;%d;%d;%d;%512[^]]]%c", &im[n].x, &im[n].y, &im[n].w, &im[n].h, im[n].name, &as) == 6 && as == '\\') for(++n, ++i, --j; str[i] != as || str[i - 1] != ']'; ++i); @@ -193,10 +192,9 @@ statustext_handle(int sc, char *str) int ni; StatusImage im[128]; - ni = statustext_image(im, str); + ni = statustext_image(im, str); #endif /* HAVE_IMLIB */ - /* Draw normal text (and possibly colored with \#color\ blocks) */ statustext_normal(sc, str); diff --git a/src/wmfs.h b/src/wmfs.h index 6192312..069f213 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -136,7 +136,7 @@ void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color); void draw_image(Drawable dr, int x, int y, int w, int h, char *name); #endif /* HAVE_IMLIB */ -ushort textw(const char *text); +ushort textw(char *text); /* infobar.c */ void infobar_init(void);