From aa56d5c82580bdaf679bebaa17834dc4f715ea9e Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Fri, 27 Mar 2015 20:11:03 -0300 Subject: Removed pango for debugging purposes --- config.h | 7 ++-- config.mk | 4 +- dwm.c | 132 +++++++++++++++++++++++++++++--------------------------------- 3 files changed, 67 insertions(+), 76 deletions(-) diff --git a/config.h b/config.h index 9185239..4638ccb 100644 --- a/config.h +++ b/config.h @@ -1,17 +1,16 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -//static const char font[] = "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*"; -static const char font[] = "Sans 8"; +static const char font[] = "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*"; +//static const char font[] = "Sans 8"; -#define NUMCOLORS 5 // need at least 3 +#define NUMCOLORS 4 // need at least 3 static const char colors[NUMCOLORS][ColLast][8] = { // border foreground background { "#3b3b3b", "#888888", "#0b0b0b" }, // 0 = normal { "#000000", "#386dff", "#0b0b0b" }, // 1 = selected { "#ffffff", "#808080", "#ffffaa" }, // 2 = urgent/warning { "#ffffff", "#808080", "#ffaaaa" }, // 3 = error - { "#000000", "#d0d0d0", "#386dff" }, // 4 = tab selection }; static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ diff --git a/config.mk b/config.mk index e3940be..f83751a 100644 --- a/config.mk +++ b/config.mk @@ -15,8 +15,8 @@ XINERAMALIBS = -L${X11LIB} -lXinerama XINERAMAFLAGS = -DXINERAMA # includes and libs -INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags xft pango pangoxft` -LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} `pkg-config --libs xft pango pangoxft` +INCS = -I. -I/usr/include -I${X11INC} #`pkg-config --cflags xft pango pangoxft` +LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} #`pkg-config --libs xft pango pangoxft` # flags CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/dwm.c b/dwm.c index 9393a01..6dd904e 100644 --- a/dwm.c +++ b/dwm.c @@ -37,9 +37,9 @@ #include #include #include -#include -#include -#include +//#include +//#include +//#include #ifdef XINERAMA #include #endif /* XINERAMA */ @@ -112,15 +112,12 @@ typedef struct { Drawable drawable; Drawable tabdrawable; GC gc; - struct { - XftColor colors[MAXCOLORS][ColLast]; - XftDraw *drawable; - } xft; struct { int ascent; int descent; int height; - PangoLayout *layout; + XFontSet set; + XFontStruct *xfont; } font; } DC; /* draw context */ @@ -214,8 +211,7 @@ static void focuswin(const Arg* arg); static void focusin(XEvent *e); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); -//static unsigned long getcolor(const char *colstr); patched! -static unsigned long getcolor(const char *colstr, XftColor *color); +static unsigned long getcolor(const char *colstr); static Bool getrootptr(int *x, int *y); static long getstate(Window w); static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); @@ -284,7 +280,7 @@ static void zoom(const Arg *arg); /* variables */ static const char broken[] = "broken"; -static char stext[512]; +static char stext[256]; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh, blw = 0; /* bar geometry */ @@ -542,23 +538,19 @@ cleanup(void) { Arg a = {.ui = ~0}; Layout foo = { "", NULL }; Monitor *m; - int i; view(&a); selmon->lt[selmon->sellt] = &foo; for(m = mons; m; m = m->next) while(m->stack) unmanage(m->stack, False); + if(dc.font.set) + XFreeFontSet(dpy, dc.font.set); + else + XFreeFont(dpy, dc.font.xfont); XUngrabKey(dpy, AnyKey, AnyModifier, root); XFreePixmap(dpy, dc.drawable); XFreePixmap(dpy, dc.tabdrawable); - for(int c=0; c len - 3; buf[--i] = '.'); - //XSetForeground(dpy, dc.gc, col[ColFG]); patched! - //if(dc.font.set) - // XmbDrawString(dpy, drawable, dc.font.set, dc.gc, x, y, buf, len); - if(text == stext && statusmarkup) - pango_layout_set_markup(dc.font.layout, buf, len); - + XSetForeground(dpy, dc.gc, col[ColFG]); patched! + if(dc.font.set) + XmbDrawString(dpy, drawable, dc.font.set, dc.gc, x, y, buf, len); else - //XDrawString(dpy, drawable, dc.gc, x, y, buf, len); patched! and further ahead, patchy issues - pango_layout_set_text(dc.font.layout, buf, len); - pango_xft_render_layout(dc.xft.drawable, dc.xft.colors[col] + ColFG, - dc.font.layout, x * PANGO_SCALE, y * PANGO_SCALE); - if(text == stext && statusmarkup) /* clear markup attributes */ - pango_layout_set_attributes(dc.font.layout, NULL); + XDrawString(dpy, drawable, dc.gc, x, y, buf, len); } @@ -1182,13 +1164,12 @@ getatomprop(Client *c, Atom prop) { } unsigned long -getcolor(const char *colstr, XftColor *color) { +getcolor(const char *colstr) { Colormap cmap = DefaultColormap(dpy, screen); - Visual *vis = DefaultVisual(dpy, screen); - - if(!XftColorAllocName(dpy, vis, cmap, colstr, color)) + XColor color; + if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) die("error, cannot allocate color '%s'\n", colstr); - return color->pixel; + return color.pixel; } Bool @@ -1289,24 +1270,36 @@ incnmaster(const Arg *arg) { void initfont(const char *fontstr) { - PangoFontMap *fontmap; - PangoContext *context; - PangoFontDescription *desc; - PangoFontMetrics *metrics; - - fontmap = pango_xft_get_font_map(dpy, screen); - context = pango_font_map_create_context(fontmap); - desc = pango_font_description_from_string(fontstr); - dc.font.layout = pango_layout_new(context); - pango_layout_set_font_description(dc.font.layout, desc); - - metrics = pango_context_get_metrics(context, desc, NULL); - dc.font.ascent = pango_font_metrics_get_ascent(metrics) / PANGO_SCALE; - dc.font.descent = pango_font_metrics_get_descent(metrics) / PANGO_SCALE; - dc.font.height = dc.font.ascent + dc.font.descent; + char *def, **missing; + int n; - pango_font_metrics_unref(metrics); - g_object_unref(context); + dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); + if(missing) { + while(n--) + fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]); + XFreeStringList(missing); + } + if(dc.font.set) { + XFontStruct **xfonts; + char **font_names; + + dc.font.ascent = dc.font.descent = 0; + XExtentsOfFontSet(dc.font.set); + n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names); + while(n--) { + dc.font.ascent = MAX(dc.font.ascent, (*xfonts)->ascent); + dc.font.descent = MAX(dc.font.descent,(*xfonts)->descent); + xfonts++; + } + } + else { + if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)) + && !(dc.font.xfont = XLoadQueryFont(dpy, "fixed"))) + die("error, cannot load font: '%s'\n", fontstr); + dc.font.ascent = dc.font.xfont->ascent; + dc.font.descent = dc.font.xfont->descent; + } + dc.font.height = dc.font.ascent + dc.font.descent; } #ifdef XINERAMA @@ -1863,15 +1856,16 @@ setup(void) { cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); /* init appearance */ for(int i=0; ifid); /* init bars */ updatebars(); updatestatus(); @@ -1941,15 +1935,13 @@ tagmon(const Arg *arg) { int textnw(const char *text, unsigned int len) { - PangoRectangle r; - if(text == stext && statusmarkup) - pango_layout_set_markup(dc.font.layout, text, len); - else - pango_layout_set_text(dc.font.layout, text, len); - pango_layout_get_extents(dc.font.layout, 0, &r); - if(text == stext && statusmarkup) /* clear markup attributes */ - pango_layout_set_attributes(dc.font.layout, NULL); - return r.width / PANGO_SCALE; + 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 -- cgit v1.2.3