Xft support
This commit is contained in:
parent
7204cbdc46
commit
272f4b1c2a
10
awesome.c
10
awesome.c
|
@ -67,10 +67,7 @@ cleanup(DC *drawcontext, awesome_config *awesomeconf)
|
||||||
|
|
||||||
for(screen = 0; screen < get_screen_count(awesomeconf->display); screen++)
|
for(screen = 0; screen < get_screen_count(awesomeconf->display); screen++)
|
||||||
{
|
{
|
||||||
if(drawcontext[screen].font.set)
|
XftFontClose(awesomeconf->display, drawcontext->font);
|
||||||
XFreeFontSet(awesomeconf->display, drawcontext[screen].font.set);
|
|
||||||
else
|
|
||||||
XFreeFont(awesomeconf->display, drawcontext[screen].font.xfont);
|
|
||||||
|
|
||||||
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, screen));
|
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, screen));
|
||||||
|
|
||||||
|
@ -206,14 +203,11 @@ setup(DC *drawcontext, awesome_config *awesomeconf)
|
||||||
compileregs(awesomeconf->rules, awesomeconf->nrules);
|
compileregs(awesomeconf->rules, awesomeconf->nrules);
|
||||||
|
|
||||||
/* bar */
|
/* bar */
|
||||||
drawcontext->h = awesomeconf->statusbar.height = drawcontext->font.height + 2;
|
drawcontext->h = awesomeconf->statusbar.height = drawcontext->font->height + 2;
|
||||||
initstatusbar(awesomeconf->display, awesomeconf->screen, drawcontext, &awesomeconf->statusbar);
|
initstatusbar(awesomeconf->display, awesomeconf->screen, drawcontext, &awesomeconf->statusbar);
|
||||||
drawcontext->gc = XCreateGC(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), 0, 0);
|
drawcontext->gc = XCreateGC(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), 0, 0);
|
||||||
XSetLineAttributes(awesomeconf->display, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter);
|
XSetLineAttributes(awesomeconf->display, drawcontext->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
|
||||||
if(!drawcontext->font.set)
|
|
||||||
XSetFont(awesomeconf->display, drawcontext->gc, drawcontext->font.xfont->fid);
|
|
||||||
|
|
||||||
loadawesomeprops(awesomeconf->display, awesomeconf);
|
loadawesomeprops(awesomeconf->display, awesomeconf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ awesome:
|
||||||
# Master window width factor (used by tile layouts)
|
# Master window width factor (used by tile layouts)
|
||||||
mwfact = 0.6;
|
mwfact = 0.6;
|
||||||
# Font
|
# Font
|
||||||
font = "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*";
|
font = "fixed-12";
|
||||||
# Tags
|
# Tags
|
||||||
tags = ( "1", "2", "3", "4", "5", "6", "7", "8", "9" );
|
tags = ( "1", "2", "3", "4", "5", "6", "7", "8", "9" );
|
||||||
# Colors
|
# Colors
|
||||||
|
|
94
config.c
94
config.c
|
@ -38,8 +38,7 @@
|
||||||
#include "layouts/max.h"
|
#include "layouts/max.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
static void initfont(Display *, DC *, const char *);
|
static XColor initxcolor(Display *, int, const char *);
|
||||||
static unsigned long initcolor(Display *, int, const char *);
|
|
||||||
static unsigned int get_numlockmask(Display *);
|
static unsigned int get_numlockmask(Display *);
|
||||||
|
|
||||||
/** Link a name to a function */
|
/** Link a name to a function */
|
||||||
|
@ -180,6 +179,7 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
|
||||||
char *confpath;
|
char *confpath;
|
||||||
KeySym tmp_key;
|
KeySym tmp_key;
|
||||||
ssize_t confpath_len;
|
ssize_t confpath_len;
|
||||||
|
XColor colorbuf;
|
||||||
|
|
||||||
if(confpatharg)
|
if(confpatharg)
|
||||||
confpath = a_strdup(confpatharg);
|
confpath = a_strdup(confpatharg);
|
||||||
|
@ -211,7 +211,10 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
|
||||||
|
|
||||||
/* font */
|
/* font */
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.font");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.font");
|
||||||
initfont(disp, drawcontext, tmp ? tmp : "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*");
|
drawcontext->font = XftFontOpenName(disp, awesomeconf->phys_screen, tmp ? tmp : "sans-12");
|
||||||
|
|
||||||
|
if(!drawcontext->font)
|
||||||
|
eprint("awesome: cannot init font\n");
|
||||||
|
|
||||||
/* layouts */
|
/* layouts */
|
||||||
conflayouts = config_lookup(&awesomelibconf, "awesome.layouts");
|
conflayouts = config_lookup(&awesomelibconf, "awesome.layouts");
|
||||||
|
@ -253,7 +256,9 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
|
||||||
|
|
||||||
for(i = 0; i < awesomeconf->nlayouts; i++)
|
for(i = 0; i < awesomeconf->nlayouts; i++)
|
||||||
{
|
{
|
||||||
j = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->layouts[i].symbol, drawcontext->font.height);
|
j = drawcontext->font->height +
|
||||||
|
textwidth(disp, drawcontext->font,
|
||||||
|
awesomeconf->layouts[i].symbol, a_strlen(awesomeconf->layouts[i].symbol));
|
||||||
if(j > awesomeconf->statusbar.width)
|
if(j > awesomeconf->statusbar.width)
|
||||||
awesomeconf->statusbar.width = j;
|
awesomeconf->statusbar.width = j;
|
||||||
}
|
}
|
||||||
|
@ -399,79 +404,35 @@ parse_config(Display * disp, int scr, DC * drawcontext, const char *confpatharg,
|
||||||
|
|
||||||
/* colors */
|
/* colors */
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_border_color");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_border_color");
|
||||||
drawcontext->norm[ColBorder] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#dddddd");
|
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#dddddd");
|
||||||
|
drawcontext->norm[ColBorder] = colorbuf.pixel;
|
||||||
|
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_bg_color");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_bg_color");
|
||||||
drawcontext->norm[ColBG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#000000");
|
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#000000");
|
||||||
|
drawcontext->norm[ColBG] = colorbuf.pixel;
|
||||||
|
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_fg_color");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.normal_fg_color");
|
||||||
drawcontext->norm[ColFG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff");
|
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff");
|
||||||
|
drawcontext->norm[ColFG] = colorbuf.pixel;
|
||||||
|
drawcontext->text_normal = colorbuf;
|
||||||
|
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_border_color");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_border_color");
|
||||||
drawcontext->sel[ColBorder] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b");
|
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b");
|
||||||
|
drawcontext->sel[ColBorder] = colorbuf.pixel;
|
||||||
|
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_bg_color");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_bg_color");
|
||||||
drawcontext->sel[ColBG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b");
|
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#008b8b");
|
||||||
|
drawcontext->sel[ColBG] = colorbuf.pixel;
|
||||||
|
|
||||||
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color");
|
tmp = config_lookup_string(&awesomelibconf, "awesome.focus_fg_color");
|
||||||
drawcontext->sel[ColFG] = initcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff");
|
colorbuf = initxcolor(disp, awesomeconf->phys_screen, tmp ? tmp : "#ffffff");
|
||||||
|
drawcontext->sel[ColFG] = colorbuf.pixel;
|
||||||
|
drawcontext->text_selected = colorbuf;
|
||||||
|
|
||||||
config_destroy(&awesomelibconf);
|
config_destroy(&awesomelibconf);
|
||||||
p_delete(&confpath);
|
p_delete(&confpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize font from X side and store in draw context
|
|
||||||
* \param fontstr Font name
|
|
||||||
* \param disp Display ref
|
|
||||||
* \param drawcontext Draw context
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
initfont(Display *disp, DC *drawcontext, const char *fontstr)
|
|
||||||
{
|
|
||||||
char *def, **missing;
|
|
||||||
int i, n;
|
|
||||||
|
|
||||||
missing = NULL;
|
|
||||||
if(drawcontext->font.set)
|
|
||||||
XFreeFontSet(disp, drawcontext->font.set);
|
|
||||||
drawcontext->font.set = XCreateFontSet(disp, fontstr, &missing, &n, &def);
|
|
||||||
if(missing)
|
|
||||||
{
|
|
||||||
while(n--)
|
|
||||||
fprintf(stderr, "awesome: missing fontset: %s\n", missing[n]);
|
|
||||||
XFreeStringList(missing);
|
|
||||||
}
|
|
||||||
if(drawcontext->font.set)
|
|
||||||
{
|
|
||||||
XFontSetExtents *font_extents;
|
|
||||||
XFontStruct **xfonts;
|
|
||||||
char **font_names;
|
|
||||||
drawcontext->font.ascent = drawcontext->font.descent = 0;
|
|
||||||
font_extents = XExtentsOfFontSet(drawcontext->font.set);
|
|
||||||
n = XFontsOfFontSet(drawcontext->font.set, &xfonts, &font_names);
|
|
||||||
for(i = 0, drawcontext->font.ascent = 0, drawcontext->font.descent = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
if(drawcontext->font.ascent < (*xfonts)->ascent)
|
|
||||||
drawcontext->font.ascent = (*xfonts)->ascent;
|
|
||||||
if(drawcontext->font.descent < (*xfonts)->descent)
|
|
||||||
drawcontext->font.descent = (*xfonts)->descent;
|
|
||||||
xfonts++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(drawcontext->font.xfont)
|
|
||||||
XFreeFont(disp, drawcontext->font.xfont);
|
|
||||||
drawcontext->font.xfont = NULL;
|
|
||||||
if(!(drawcontext->font.xfont = XLoadQueryFont(disp, fontstr))
|
|
||||||
&& !(drawcontext->font.xfont = XLoadQueryFont(disp, "fixed")))
|
|
||||||
die("awesome: error, cannot load font: '%s'\n", fontstr);
|
|
||||||
drawcontext->font.ascent = drawcontext->font.xfont->ascent;
|
|
||||||
drawcontext->font.descent = drawcontext->font.xfont->descent;
|
|
||||||
}
|
|
||||||
drawcontext->font.height = drawcontext->font.ascent + drawcontext->font.descent;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
get_numlockmask(Display *disp)
|
get_numlockmask(Display *disp)
|
||||||
{
|
{
|
||||||
|
@ -499,12 +460,11 @@ get_numlockmask(Display *disp)
|
||||||
* \param scr Screen number
|
* \param scr Screen number
|
||||||
* \return XColor pixel
|
* \return XColor pixel
|
||||||
*/
|
*/
|
||||||
static unsigned long
|
static XColor
|
||||||
initcolor(Display *disp, int scr, const char *colstr)
|
initxcolor(Display *disp, int scr, const char *colstr)
|
||||||
{
|
{
|
||||||
Colormap cmap = DefaultColormap(disp, scr);
|
|
||||||
XColor color;
|
XColor color;
|
||||||
if(!XAllocNamedColor(disp, cmap, colstr, &color, &color))
|
if(!XAllocNamedColor(disp, DefaultColormap(disp, scr), colstr, &color, &color))
|
||||||
die("awesome: error, cannot allocate color '%s'\n", colstr);
|
die("awesome: error, cannot allocate color '%s'\n", colstr);
|
||||||
return color.pixel;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
12
config.h
12
config.h
|
@ -25,6 +25,7 @@
|
||||||
#define AWESOME_CONFIG_FILE ".awesomerc"
|
#define AWESOME_CONFIG_FILE ".awesomerc"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
/** Bar possible position */
|
/** Bar possible position */
|
||||||
enum
|
enum
|
||||||
|
@ -41,16 +42,11 @@ typedef struct
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
unsigned long norm[ColLast];
|
unsigned long norm[ColLast];
|
||||||
unsigned long sel[ColLast];
|
unsigned long sel[ColLast];
|
||||||
|
XColor text_normal;
|
||||||
|
XColor text_selected;
|
||||||
GC gc;
|
GC gc;
|
||||||
Cursor cursor[CurLast];
|
Cursor cursor[CurLast];
|
||||||
struct
|
XftFont *font;
|
||||||
{
|
|
||||||
int ascent;
|
|
||||||
int descent;
|
|
||||||
int height;
|
|
||||||
XFontSet set;
|
|
||||||
XFontStruct *xfont;
|
|
||||||
} font;
|
|
||||||
} DC;
|
} DC;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -14,8 +14,8 @@ X11INC = /usr/include/X11
|
||||||
X11LIB = /usr/lib/X11
|
X11LIB = /usr/lib/X11
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig`
|
INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig xft`
|
||||||
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig` -lXext -lXrandr -lXinerama
|
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig xft` -lXext -lXrandr -lXinerama
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O3 ${INCS} -DVERSION=\"${VERSION}\"
|
CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O3 ${INCS} -DVERSION=\"${VERSION}\"
|
||||||
|
|
54
draw.c
54
draw.c
|
@ -28,15 +28,18 @@ extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||||
/* static */
|
/* static */
|
||||||
|
|
||||||
void
|
void
|
||||||
drawtext(Display *disp, DC drawcontext, Drawable drawable, const char *text, unsigned long col[ColLast])
|
drawtext(Display *disp, int screen, DC *drawcontext, Drawable drawable, const char *text, unsigned long col[ColLast], XColor textcolor)
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
size_t len, olen;
|
size_t len, olen;
|
||||||
XRectangle r = { drawcontext.x, drawcontext.y, drawcontext.w, drawcontext.h };
|
XRectangle r = { drawcontext->x, drawcontext->y, drawcontext->w, drawcontext->h };
|
||||||
|
XRenderColor xrcolor;
|
||||||
|
XftColor xftcolor;
|
||||||
|
XftDraw *xftdrawable;
|
||||||
|
|
||||||
XSetForeground(disp, drawcontext.gc, col[ColBG]);
|
XSetForeground(disp, drawcontext->gc, col[ColBG]);
|
||||||
XFillRectangles(disp, drawable, drawcontext.gc, &r, 1);
|
XFillRectangles(disp, drawable, drawcontext->gc, &r, 1);
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
w = 0;
|
w = 0;
|
||||||
|
@ -45,13 +48,12 @@ drawtext(Display *disp, DC drawcontext, Drawable drawable, const char *text, uns
|
||||||
len = sizeof(buf) - 1;
|
len = sizeof(buf) - 1;
|
||||||
memcpy(buf, text, len);
|
memcpy(buf, text, len);
|
||||||
buf[len] = 0;
|
buf[len] = 0;
|
||||||
h = drawcontext.font.ascent + drawcontext.font.descent;
|
h = drawcontext->font->ascent + drawcontext->font->descent;
|
||||||
y = drawcontext.y + (drawcontext.h / 2) - (h / 2) + drawcontext.font.ascent;
|
y = drawcontext->y + (drawcontext->h / 2) - (h / 2) + drawcontext->font->ascent;
|
||||||
x = drawcontext.x + (h / 2);
|
x = drawcontext->x + (h / 2);
|
||||||
/* shorten text if necessary */
|
while(len && (w = textwidth(disp, drawcontext->font, buf, len)) > drawcontext->w - h)
|
||||||
while(len && (w = textnw(drawcontext.font.set, drawcontext.font.xfont, buf, len)) > drawcontext.w - h)
|
|
||||||
buf[--len] = 0;
|
buf[--len] = 0;
|
||||||
if(w > drawcontext.w)
|
if(w > drawcontext->w)
|
||||||
return; /* too long */
|
return; /* too long */
|
||||||
if(len < olen)
|
if(len < olen)
|
||||||
{
|
{
|
||||||
|
@ -62,11 +64,14 @@ drawtext(Display *disp, DC drawcontext, Drawable drawable, const char *text, uns
|
||||||
if(len > 3)
|
if(len > 3)
|
||||||
buf[len - 3] = '.';
|
buf[len - 3] = '.';
|
||||||
}
|
}
|
||||||
XSetForeground(disp, drawcontext.gc, col[ColFG]);
|
xrcolor.red = textcolor.red;
|
||||||
if(drawcontext.font.set)
|
xrcolor.green = textcolor.green;
|
||||||
XmbDrawString(disp, drawable, drawcontext.font.set, drawcontext.gc, x, y, buf, len);
|
xrcolor.blue = textcolor.blue;
|
||||||
else
|
xrcolor.alpha = 255;
|
||||||
XDrawString(disp, drawable, drawcontext.gc, x, y, buf, len);
|
XftColorAllocValue(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), &xrcolor, &xftcolor);
|
||||||
|
xftdrawable = XftDrawCreate(disp, drawable, DefaultVisual(disp, screen), DefaultColormap(disp, screen));
|
||||||
|
XftDrawStringUtf8(xftdrawable, &xftcolor, drawcontext->font, x, y, (FcChar8 *) buf, len);
|
||||||
|
XftColorFree(disp, DefaultVisual(disp, screen), DefaultColormap(disp, screen), &xftcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -76,9 +81,9 @@ drawsquare(Display *disp, DC drawcontext, Drawable drawable, Bool filled, unsign
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XRectangle r = { drawcontext.x, drawcontext.y, drawcontext.w, drawcontext.h };
|
XRectangle r = { drawcontext.x, drawcontext.y, drawcontext.w, drawcontext.h };
|
||||||
|
|
||||||
|
x = (drawcontext.font->ascent + drawcontext.font->descent + 2) / 4;
|
||||||
gcv.foreground = col;
|
gcv.foreground = col;
|
||||||
XChangeGC(disp, drawcontext.gc, GCForeground, &gcv);
|
XChangeGC(disp, drawcontext.gc, GCForeground, &gcv);
|
||||||
x = (drawcontext.font.ascent + drawcontext.font.descent + 2) / 4;
|
|
||||||
r.x = drawcontext.x + 1;
|
r.x = drawcontext.x + 1;
|
||||||
r.y = drawcontext.y + 1;
|
r.y = drawcontext.y + 1;
|
||||||
r.width = r.height = x;
|
r.width = r.height = x;
|
||||||
|
@ -91,16 +96,11 @@ drawsquare(Display *disp, DC drawcontext, Drawable drawable, Bool filled, unsign
|
||||||
XDrawRectangles(disp, drawable, drawcontext.gc, &r, 1);
|
XDrawRectangles(disp, drawable, drawcontext.gc, &r, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
textnw(XFontSet set, XFontStruct *xfont, const char *text, int len)
|
unsigned short
|
||||||
|
textwidth(Display *disp, XftFont *font, char *text, ssize_t len)
|
||||||
{
|
{
|
||||||
XRectangle r;
|
XGlyphInfo gi;
|
||||||
|
XftTextExtentsUtf8(disp, font, (FcChar8 *) text, len, &gi);
|
||||||
if(set)
|
return gi.width;
|
||||||
{
|
|
||||||
XmbTextExtents(set, text, len, NULL, &r);
|
|
||||||
return r.width;
|
|
||||||
}
|
|
||||||
return XTextWidth(xfont, text, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
draw.h
7
draw.h
|
@ -24,10 +24,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#define textw(set, xfont, text, height) (textnw(set, xfont, text, a_strlen(text)) + height)
|
|
||||||
|
|
||||||
void drawsquare(Display *, DC, Drawable, Bool, unsigned long);
|
void drawsquare(Display *, DC, Drawable, Bool, unsigned long);
|
||||||
void drawtext(Display *, DC, Drawable, const char *, unsigned long *);
|
void drawtext(Display *, int, DC *, Drawable, const char *, unsigned long *, XColor);
|
||||||
int textnw(XFontSet, XFontStruct *, const char *, int);
|
inline unsigned short textwidth(Display *, XftFont *, char *, ssize_t);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
2
event.c
2
event.c
|
@ -154,7 +154,7 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
||||||
int x = 0;
|
int x = 0;
|
||||||
for(i = 0; i < awesomeconf[screen].ntags; i++)
|
for(i = 0; i < awesomeconf[screen].ntags; i++)
|
||||||
{
|
{
|
||||||
x += textw(dc[screen].font.set, dc[screen].font.xfont, awesomeconf[screen].tags[i].name, dc[screen].font.height);
|
x += textwidth(e->xany.display, dc[screen].font, awesomeconf[screen].tags[i].name, a_strlen(awesomeconf[screen].tags[i].name)) + dc[screen].font->height;
|
||||||
if(ev->x < x)
|
if(ev->x < x)
|
||||||
{
|
{
|
||||||
if(ev->button == Button1)
|
if(ev->button == Button1)
|
||||||
|
|
18
statusbar.c
18
statusbar.c
|
@ -56,38 +56,38 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
|
||||||
drawcontext->x = drawcontext->y = 0;
|
drawcontext->x = drawcontext->y = 0;
|
||||||
for(i = 0; i < awesomeconf->ntags; i++)
|
for(i = 0; i < awesomeconf->ntags; i++)
|
||||||
{
|
{
|
||||||
drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->tags[i].name, drawcontext->font.height);
|
drawcontext->w = textwidth(disp, drawcontext->font, awesomeconf->tags[i].name, a_strlen(awesomeconf->tags[i].name)) + drawcontext->font->height;
|
||||||
if(awesomeconf->tags[i].selected)
|
if(awesomeconf->tags[i].selected)
|
||||||
{
|
{
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->tags[i].name, drawcontext->sel);
|
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, awesomeconf->tags[i].name, drawcontext->sel, drawcontext->text_selected);
|
||||||
if(isoccupied(i, awesomeconf->screen))
|
if(isoccupied(i, awesomeconf->screen))
|
||||||
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->sel[ColFG]);
|
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->sel[ColFG]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->tags[i].name, drawcontext->norm);
|
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, awesomeconf->tags[i].name, drawcontext->norm, drawcontext->text_normal);
|
||||||
if(isoccupied(i, awesomeconf->screen))
|
if(isoccupied(i, awesomeconf->screen))
|
||||||
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->norm[ColFG]);
|
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel && sel->tags[i], drawcontext->norm[ColFG]);
|
||||||
}
|
}
|
||||||
drawcontext->x += drawcontext->w;
|
drawcontext->x += drawcontext->w;
|
||||||
}
|
}
|
||||||
drawcontext->w = awesomeconf->statusbar.width;
|
drawcontext->w = awesomeconf->statusbar.width;
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->current_layout->symbol, drawcontext->norm);
|
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, awesomeconf->current_layout->symbol, drawcontext->norm, drawcontext->text_normal);
|
||||||
x = drawcontext->x + drawcontext->w;
|
x = drawcontext->x + drawcontext->w;
|
||||||
drawcontext->w = textw(drawcontext->font.set, drawcontext->font.xfont, awesomeconf->statustext, drawcontext->font.height);
|
drawcontext->w = textwidth(disp, drawcontext->font, awesomeconf->statustext, a_strlen(awesomeconf->statustext)) + drawcontext->font->height;
|
||||||
drawcontext->x = si[awesomeconf->screen].width - drawcontext->w;
|
drawcontext->x = si[awesomeconf->screen].width - drawcontext->w;
|
||||||
if(drawcontext->x < x)
|
if(drawcontext->x < x)
|
||||||
{
|
{
|
||||||
drawcontext->x = x;
|
drawcontext->x = x;
|
||||||
drawcontext->w = si[awesomeconf->screen].width - x;
|
drawcontext->w = si[awesomeconf->screen].width - x;
|
||||||
}
|
}
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, awesomeconf->statustext, drawcontext->norm);
|
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, awesomeconf->statustext, drawcontext->norm, drawcontext->text_normal);
|
||||||
if((drawcontext->w = drawcontext->x - x) > awesomeconf->statusbar.height)
|
if((drawcontext->w = drawcontext->x - x) > awesomeconf->statusbar.height)
|
||||||
{
|
{
|
||||||
drawcontext->x = x;
|
drawcontext->x = x;
|
||||||
if(sel)
|
if(sel)
|
||||||
{
|
{
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, sel->name, drawcontext->sel);
|
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, sel->name, drawcontext->sel, drawcontext->text_selected);
|
||||||
if(sel->isfloating)
|
if(sel->isfloating)
|
||||||
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel->ismax, drawcontext->sel[ColFG]);
|
drawsquare(disp, *drawcontext, awesomeconf->statusbar.drawable, sel->ismax, drawcontext->sel[ColFG]);
|
||||||
}
|
}
|
||||||
|
@ -95,10 +95,10 @@ drawstatusbar(Display *disp, DC *drawcontext, awesome_config * awesomeconf)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
snprintf(buf, sizeof(buf), "nmaster: %d ncols: %d mwfact: %.2lf", awesomeconf->nmaster, awesomeconf->ncols, awesomeconf->mwfact);
|
snprintf(buf, sizeof(buf), "nmaster: %d ncols: %d mwfact: %.2lf", awesomeconf->nmaster, awesomeconf->ncols, awesomeconf->mwfact);
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, buf, drawcontext->norm);
|
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, buf, drawcontext->norm, drawcontext->text_normal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
drawtext(disp, *drawcontext, awesomeconf->statusbar.drawable, NULL, drawcontext->norm);
|
drawtext(disp, awesomeconf->phys_screen, drawcontext, awesomeconf->statusbar.drawable, NULL, drawcontext->norm, drawcontext->text_normal);
|
||||||
}
|
}
|
||||||
XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, si[awesomeconf->screen].width, awesomeconf->statusbar.height, 0, 0);
|
XCopyArea(disp, awesomeconf->statusbar.drawable, awesomeconf->statusbar.window, drawcontext->gc, 0, 0, si[awesomeconf->screen].width, awesomeconf->statusbar.height, 0, 0);
|
||||||
XSync(disp, False);
|
XSync(disp, False);
|
||||||
|
|
Loading…
Reference in New Issue