diff options
Diffstat (limited to 'drw.h')
-rw-r--r-- | drw.h | 70 |
1 files changed, 25 insertions, 45 deletions
@@ -1,21 +1,9 @@ /* See LICENSE file for copyright and license details. */ - -#include "kconfig.h" - -#ifdef CONFIG_DWM_PANGO -#include <X11/Xft/Xft.h> -#include <pango/pango.h> -#include <pango/pangoxft.h> +#define DRW_FONT_CACHE_SIZE 32 typedef struct { - XftColor norm[4]; - XftColor sel[4]; - XftDraw *drawable; -} Xft; -#endif - -typedef struct { - unsigned long rgb; + unsigned long pix; + XftColor rgb; } Clr; typedef struct { @@ -23,15 +11,12 @@ typedef struct { } Cur; typedef struct { + Display *dpy; int ascent; int descent; unsigned int h; -#ifdef CONFIG_DWM_PANGO - PangoLayout *layout; -#else - XFontSet set; - XFontStruct *xfont; -#endif + XftFont *xfont; + FcPattern *pattern; } Fnt; typedef struct { @@ -48,10 +33,8 @@ typedef struct { Drawable drawable; GC gc; ClrScheme *scheme; -#ifdef CONFIG_DWM_PANGO - Xft xft; -#endif - Fnt *font; + size_t fontcount; + Fnt *fonts[DRW_FONT_CACHE_SIZE]; } Drw; typedef struct { @@ -60,35 +43,32 @@ typedef struct { } Extnts; /* Drawable abstraction */ -Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); -void drw_resize(Drw *drw, unsigned int w, unsigned int h); -void drw_free(Drw *drw); +Drw *drw_create(Display *, int, Window, unsigned int, unsigned int); +void drw_resize(Drw *, unsigned int, unsigned int); +void drw_free(Drw *); /* Fnt abstraction */ -Fnt *drw_font_create(Display *dpy, const char *fontname); -void drw_font_free(Display *dpy, Fnt *font); -void drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *extnts); -unsigned int drw_font_getexts_width(Fnt *font, const char *text, unsigned int len); +Fnt *drw_font_create(Drw *, const char *); +void drw_load_fonts(Drw *, const char *[], size_t); +void drw_font_free(Fnt *); +void drw_font_getexts(Fnt *, const char *, unsigned int, Extnts *); +unsigned int drw_font_getexts_width(Fnt *, const char *, unsigned int); /* Colour abstraction */ -#ifdef CONFIG_DWM_PANGO -Clr *drw_clr_create(Drw *drw, const char *clrname, XftColor *color); -#else -Clr *drw_clr_create(Drw *drw, const char *clrname); -#endif -void drw_clr_free(Clr *clr); +Clr *drw_clr_create(Drw *, const char *); +void drw_clr_free(Clr *); /* Cursor abstraction */ -Cur *drw_cur_create(Drw *drw, int shape); -void drw_cur_free(Drw *drw, Cur *cursor); +Cur *drw_cur_create(Drw *, int); +void drw_cur_free(Drw *, Cur *); /* Drawing context manipulation */ -void drw_setfont(Drw *drw, Fnt *font); -void drw_setscheme(Drw *drw, ClrScheme *scheme); +void drw_setfont(Drw *, Fnt *); +void drw_setscheme(Drw *, ClrScheme *); /* Drawing functions */ -void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert); -void drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert); +void drw_rect(Drw *, int, int, unsigned int, unsigned int, int, int, int); +int drw_text(Drw *, int, int, unsigned int, unsigned int, const char *, int); /* Map functions */ -void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h); +void drw_map(Drw *, Window, int, int, unsigned int, unsigned int); |