aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-03-27 20:11:03 -0300
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-03-27 20:11:03 -0300
commitaa56d5c82580bdaf679bebaa17834dc4f715ea9e (patch)
tree38d807b4e216dc3230fc96152b79be235f3036c1
parent71322ec48c466329c1767c48d56e835b17017121 (diff)
Removed pango for debugging purposes
-rw-r--r--config.h7
-rw-r--r--config.mk4
-rw-r--r--dwm.c132
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 <X11/Xlib.h>
#include <X11/Xproto.h>
#include <X11/Xutil.h>
-#include <X11/Xft/Xft.h>
-#include <pango/pango.h>
-#include <pango/pangoxft.h>
+//#include <X11/Xft/Xft.h>
+//#include <pango/pango.h>
+//#include <pango/pangoxft.h>
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif /* XINERAMA */
@@ -113,14 +113,11 @@ typedef struct {
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<NUMCOLORS; c++) {
- for(i = ColBorder; i < ColLast; i++) {
- XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), dc.xft.colors[c] + i);
- }
- }
- XftDrawDestroy(dc.xft.drawable);
- g_object_unref(dc.font.layout);
XFreeGC(dpy, dc.gc);
XFreeCursor(dpy, cursor[CurNormal]);
XFreeCursor(dpy, cursor[CurResize]);
@@ -651,7 +643,6 @@ configurenotify(XEvent *e) {
if(dc.drawable != 0)
XFreePixmap(dpy, dc.drawable);
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
- XftDrawChange(dc.xft.drawable, dc.drawable);
if(dc.tabdrawable != 0)
XFreePixmap(dpy, dc.tabdrawable);
dc.tabdrawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
@@ -1015,7 +1006,7 @@ drawsquare(Bool filled, Bool empty, int col) {
void
//drawtext(Drawable drawable, const char *text, unsigned long col[ColLast], Bool pad) {
drawtext(Drawable drawable, const char *text, int col, Bool pad) {
- char buf[512];
+ char buf[256];
int i, x, y, h, len, olen;
XSetForeground(dpy, dc.gc, dc.colors[col][ColBG]);
@@ -1024,8 +1015,7 @@ drawtext(Drawable drawable, const char *text, int col, Bool pad) {
return;
olen = strlen(text);
h = pad ? (dc.font.ascent + dc.font.descent) : 0;
- //y = dc.y + ((dc.h + dc.font.ascent - dc.font.descent) / 2); patched!
- y = dc.y + (dc.h / 2) - (h / 2);
+ y = dc.y + ((dc.h + dc.font.ascent - dc.font.descent) / 2);
x = dc.x + (h / 2);
/* shorten text if necessary (this could wreak havoc with pango markup but fortunately
dc.w is adjusted to the width of the status text and not the other way around) */
@@ -1035,19 +1025,11 @@ drawtext(Drawable drawable, const char *text, int col, Bool pad) {
memcpy(buf, text, len);
if(len < olen)
for(i = len; i && i > 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; i<NUMCOLORS; i++) {
- dc.colors[i][ColBorder] = getcolor( colors[i][ColBorder], dc.xft.colors[i] + ColBorder );
- dc.colors[i][ColFG] = getcolor( colors[i][ColFG], dc.xft.colors[i] + ColFG );
- dc.colors[i][ColBG] = getcolor( colors[i][ColBG], dc.xft.colors[i] + ColBG );
+ dc.colors[i][ColBorder] = getcolor( colors[i][ColBorder] );
+ dc.colors[i][ColFG] = getcolor( colors[i][ColFG] );
+ dc.colors[i][ColBG] = getcolor( colors[i][ColBG] );
}
dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
dc.tabdrawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), th, DefaultDepth(dpy, screen));
- dc.xft.drawable = XftDrawCreate(dpy, dc.drawable, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
dc.gc = XCreateGC(dpy, root, 0, NULL);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
+ if(!dc.font.set)
+ XSetFont(dpy, dc.gc, dc.font.xfont->fid);
/* 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