new color stuff/new rendering stuff
This commit is contained in:
parent
9833610356
commit
b55bd709ee
6 changed files with 70 additions and 58 deletions
39
config.arg.h
39
config.arg.h
|
@ -4,50 +4,59 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TAGS \
|
#define TAGS \
|
||||||
const char *tags[] = { "work", "net", "fnord", NULL };
|
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
#define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*"
|
|
||||||
#define BGCOLOR "#666699"
|
#define FONT "fixed"
|
||||||
#define FGCOLOR "#eeeeee"
|
#define SELBGCOLOR "#666699"
|
||||||
#define BORDERCOLOR "#9999CC"
|
#define SELFGCOLOR "#eeeeee"
|
||||||
|
#define NORMBGCOLOR "#333366"
|
||||||
|
#define NORMFGCOLOR "#cccccc"
|
||||||
|
#define STATUSBGCOLOR "#dddddd"
|
||||||
|
#define STATUSFGCOLOR "#222222"
|
||||||
|
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define MASTERW 60 /* percent */
|
#define MASTERW 60 /* percent */
|
||||||
|
|
||||||
#define KEYS \
|
#define KEYS \
|
||||||
static Key key[] = { \
|
static Key key[] = { \
|
||||||
/* modifier key function arguments */ \
|
/* modifier key function arguments */ \
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, \
|
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
|
||||||
{ .cmd = "exec uxterm -bg '#e0e0e0' -fg '#000000' -cr '#000000' +sb -fn '"FONT"'" } }, \
|
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
|
||||||
{ MODKEY, XK_p, spawn, \
|
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
|
||||||
{ .cmd = "exec `ls -lL /usr/bin /usr/X11R6/bin /usr/local/bin 2>/dev/null | " \
|
|
||||||
"awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u | dmenu`" } }, \
|
|
||||||
{ MODKEY, XK_j, focusnext, { 0 } }, \
|
|
||||||
{ MODKEY, XK_k, focusprev, { 0 } }, \
|
|
||||||
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
{ MODKEY, XK_Return, zoom, { 0 } }, \
|
||||||
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
{ MODKEY, XK_m, togglemax, { 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
{ MODKEY|ShiftMask, XK_2, tag, { .i = 1 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
{ MODKEY|ShiftMask, XK_3, tag, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ShiftMask, XK_4, tag, { .i = 3 } }, \
|
||||||
|
{ MODKEY|ShiftMask, XK_5, tag, { .i = 4 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_1, toggletag, { .i = 0 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_2, toggletag, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
{ MODKEY|ControlMask|ShiftMask, XK_3, toggletag, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
|
||||||
|
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
|
||||||
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
{ MODKEY, XK_space, togglemode, { 0 } }, \
|
||||||
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
{ MODKEY, XK_1, view, { .i = 0 } }, \
|
||||||
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
{ MODKEY, XK_2, view, { .i = 1 } }, \
|
||||||
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
{ MODKEY, XK_3, view, { .i = 2 } }, \
|
||||||
|
{ MODKEY, XK_4, view, { .i = 3 } }, \
|
||||||
|
{ MODKEY, XK_5, view, { .i = 4 } }, \
|
||||||
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
{ MODKEY|ControlMask, XK_1, toggleview, { .i = 0 } }, \
|
||||||
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
{ MODKEY|ControlMask, XK_2, toggleview, { .i = 1 } }, \
|
||||||
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
{ MODKEY|ControlMask, XK_3, toggleview, { .i = 2 } }, \
|
||||||
|
{ MODKEY|ControlMask, XK_4, toggleview, { .i = 3 } }, \
|
||||||
|
{ MODKEY|ControlMask, XK_5, toggleview, { .i = 4 } }, \
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
{ MODKEY|ShiftMask, XK_q, quit, { 0 } }, \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Query class:instance:title for regex matching info with following command:
|
||||||
|
* xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/{ printf("%s\n",$2) }' */
|
||||||
#define RULES \
|
#define RULES \
|
||||||
static Rule rule[] = { \
|
static Rule rule[] = { \
|
||||||
/* class:instance:title regex tags regex isfloat */ \
|
/* class:instance:title regex tags regex isfloat */ \
|
||||||
{ "Firefox.*", "net", False }, \
|
{ "Firefox.*", "2", False }, \
|
||||||
{ "Gimp.*", NULL, True}, \
|
{ "Gimp.*", NULL, True}, \
|
||||||
{ "MPlayer.*", NULL, True}, \
|
|
||||||
{ "Acroread.*", NULL, True}, \
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,10 +7,15 @@
|
||||||
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
const char *tags[] = { "1", "2", "3", "4", "5", NULL };
|
||||||
|
|
||||||
#define DEFMODE dotile /* dofloat */
|
#define DEFMODE dotile /* dofloat */
|
||||||
|
|
||||||
#define FONT "fixed"
|
#define FONT "fixed"
|
||||||
#define BGCOLOR "#666699"
|
#define SELBGCOLOR "#666699"
|
||||||
#define FGCOLOR "#eeeeee"
|
#define SELFGCOLOR "#eeeeee"
|
||||||
#define BORDERCOLOR "#9999CC"
|
#define NORMBGCOLOR "#333366"
|
||||||
|
#define NORMFGCOLOR "#cccccc"
|
||||||
|
#define STATUSBGCOLOR "#dddddd"
|
||||||
|
#define STATUSFGCOLOR "#222222"
|
||||||
|
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define MASTERW 60 /* percent */
|
#define MASTERW 60 /* percent */
|
||||||
|
|
||||||
|
|
49
draw.c
49
draw.c
|
@ -22,29 +22,16 @@ textnw(const char *text, unsigned int len)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
drawtext(const char *text, Bool invert, Bool highlight)
|
drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
unsigned int len, olen;
|
unsigned int len, olen;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
XPoint points[5];
|
|
||||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||||
|
|
||||||
XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
|
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||||
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
|
||||||
points[0].x = dc.x;
|
|
||||||
points[0].y = dc.y;
|
|
||||||
points[1].x = dc.w - 1;
|
|
||||||
points[1].y = 0;
|
|
||||||
points[2].x = 0;
|
|
||||||
points[2].y = dc.h - 1;
|
|
||||||
points[3].x = -(dc.w - 1);
|
|
||||||
points[3].y = 0;
|
|
||||||
points[4].x = 0;
|
|
||||||
points[4].y = -(dc.h - 1);
|
|
||||||
XSetForeground(dpy, dc.gc, dc.border);
|
|
||||||
XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
|
|
||||||
|
|
||||||
if(!text)
|
if(!text)
|
||||||
return;
|
return;
|
||||||
|
@ -74,15 +61,14 @@ drawtext(const char *text, Bool invert, Bool highlight)
|
||||||
|
|
||||||
if(w > dc.w)
|
if(w > dc.w)
|
||||||
return; /* too long */
|
return; /* too long */
|
||||||
gcv.foreground = invert ? dc.bg : dc.fg;
|
gcv.foreground = col[ColFG];
|
||||||
gcv.background = invert ? dc.fg : dc.bg;
|
|
||||||
if(dc.font.set) {
|
if(dc.font.set) {
|
||||||
XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv);
|
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
|
||||||
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gcv.font = dc.font.xfont->fid;
|
gcv.font = dc.font.xfont->fid;
|
||||||
XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv);
|
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||||
}
|
}
|
||||||
if(highlight) {
|
if(highlight) {
|
||||||
|
@ -108,21 +94,25 @@ drawall()
|
||||||
void
|
void
|
||||||
drawstatus()
|
drawstatus()
|
||||||
{
|
{
|
||||||
|
static const char *mode[] = { "~", "=" };
|
||||||
int i, x;
|
int i, x;
|
||||||
Bool istile = arrange == dotile;
|
|
||||||
|
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
dc.w = bw;
|
dc.w = bw;
|
||||||
drawtext(NULL, !istile, False);
|
|
||||||
|
if(!modew)
|
||||||
|
modew = textw(mode[0]) > textw(mode[1]) ? textw(mode[0]) : textw(mode[1]);
|
||||||
|
drawtext(mode[arrange == dotile ? 1 : 0], dc.status, False);
|
||||||
|
|
||||||
dc.w = 0;
|
dc.w = 0;
|
||||||
|
dc.x = modew;
|
||||||
for(i = 0; i < ntags; i++) {
|
for(i = 0; i < ntags; i++) {
|
||||||
dc.x += dc.w;
|
dc.x += dc.w;
|
||||||
dc.w = textw(tags[i]);
|
dc.w = textw(tags[i]);
|
||||||
if(istile)
|
if(seltag[i])
|
||||||
drawtext(tags[i], seltag[i], sel && sel->tags[i]);
|
drawtext(tags[i], dc.sel, sel && sel->tags[i]);
|
||||||
else
|
else
|
||||||
drawtext(tags[i], !seltag[i], sel && sel->tags[i]);
|
drawtext(tags[i], dc.norm, sel && sel->tags[i]);
|
||||||
}
|
}
|
||||||
x = dc.x + dc.w;
|
x = dc.x + dc.w;
|
||||||
dc.w = textw(stext);
|
dc.w = textw(stext);
|
||||||
|
@ -131,11 +121,11 @@ drawstatus()
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
dc.w = bw - x;
|
dc.w = bw - x;
|
||||||
}
|
}
|
||||||
drawtext(stext, !istile, False);
|
drawtext(stext, dc.status, False);
|
||||||
|
|
||||||
if(sel && ((dc.w = dc.x - x) > bh)) {
|
if(sel && ((dc.w = dc.x - x) > bh)) {
|
||||||
dc.x = x;
|
dc.x = x;
|
||||||
drawtext(sel->name, istile, False);
|
drawtext(sel->name, dc.sel, False);
|
||||||
}
|
}
|
||||||
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -145,20 +135,19 @@ void
|
||||||
drawtitle(Client *c)
|
drawtitle(Client *c)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Bool istile = arrange == dotile;
|
|
||||||
|
|
||||||
if(c == sel && issel) {
|
if(c == sel && issel) {
|
||||||
drawstatus();
|
drawstatus();
|
||||||
XUnmapWindow(dpy, c->twin);
|
XUnmapWindow(dpy, c->twin);
|
||||||
XSetWindowBorder(dpy, c->win, dc.fg);
|
XSetWindowBorder(dpy, c->win, dc.sel[ColBG]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetWindowBorder(dpy, c->win, dc.bg);
|
XSetWindowBorder(dpy, c->win, dc.norm[ColBG]);
|
||||||
XMapWindow(dpy, c->twin);
|
XMapWindow(dpy, c->twin);
|
||||||
dc.x = dc.y = 0;
|
dc.x = dc.y = 0;
|
||||||
dc.w = c->tw;
|
dc.w = c->tw;
|
||||||
drawtext(c->name, !istile, False);
|
drawtext(c->name, dc.norm, False);
|
||||||
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
}
|
}
|
||||||
|
|
11
dwm.h
11
dwm.h
|
@ -23,6 +23,9 @@ enum { WMProtocols, WMDelete, WMLast };
|
||||||
/* cursor */
|
/* cursor */
|
||||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||||
|
|
||||||
|
/* color */
|
||||||
|
enum { ColFG, ColBG, ColLast };
|
||||||
|
|
||||||
/* window corners */
|
/* window corners */
|
||||||
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
typedef enum { TopLeft, TopRight, BotLeft, BotRight } Corner;
|
||||||
|
|
||||||
|
@ -36,9 +39,9 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct { /* draw context */
|
typedef struct { /* draw context */
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
unsigned long bg;
|
unsigned long norm[ColLast];
|
||||||
unsigned long fg;
|
unsigned long sel[ColLast];
|
||||||
unsigned long border;
|
unsigned long status[ColLast];
|
||||||
Drawable drawable;
|
Drawable drawable;
|
||||||
Fnt font;
|
Fnt font;
|
||||||
GC gc;
|
GC gc;
|
||||||
|
@ -66,7 +69,7 @@ struct Client {
|
||||||
extern const char *tags[];
|
extern const char *tags[];
|
||||||
extern char stext[1024];
|
extern char stext[1024];
|
||||||
extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
extern int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
||||||
extern unsigned int ntags, numlockmask;
|
extern unsigned int ntags, numlockmask, modew;
|
||||||
extern void (*handler[LASTEvent])(XEvent *);
|
extern void (*handler[LASTEvent])(XEvent *);
|
||||||
extern void (*arrange)(Arg *);
|
extern void (*arrange)(Arg *);
|
||||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||||
|
|
4
event.c
4
event.c
|
@ -105,7 +105,9 @@ buttonpress(XEvent *e)
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
|
|
||||||
if(barwin == ev->window) {
|
if(barwin == ev->window) {
|
||||||
x = 0;
|
if(ev->x < modew)
|
||||||
|
return;
|
||||||
|
x = modew;
|
||||||
for(a.i = 0; a.i < ntags; a.i++) {
|
for(a.i = 0; a.i < ntags; a.i++) {
|
||||||
x += textw(tags[a.i]);
|
x += textw(tags[a.i]);
|
||||||
if(ev->x < x) {
|
if(ev->x < x) {
|
||||||
|
|
14
main.c
14
main.c
|
@ -20,7 +20,7 @@
|
||||||
char stext[1024];
|
char stext[1024];
|
||||||
Bool *seltag;
|
Bool *seltag;
|
||||||
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
|
||||||
unsigned int ntags, numlockmask;
|
unsigned int ntags, numlockmask, modew;
|
||||||
Atom wmatom[WMLast], netatom[NetLast];
|
Atom wmatom[WMLast], netatom[NetLast];
|
||||||
Bool running = True;
|
Bool running = True;
|
||||||
Bool issel = True;
|
Bool issel = True;
|
||||||
|
@ -121,11 +121,15 @@ setup()
|
||||||
seltag[0] = True;
|
seltag[0] = True;
|
||||||
|
|
||||||
/* style */
|
/* style */
|
||||||
dc.bg = getcolor(BGCOLOR);
|
dc.norm[ColBG] = getcolor(NORMBGCOLOR);
|
||||||
dc.fg = getcolor(FGCOLOR);
|
dc.norm[ColFG] = getcolor(NORMFGCOLOR);
|
||||||
dc.border = getcolor(BORDERCOLOR);
|
dc.sel[ColBG] = getcolor(SELBGCOLOR);
|
||||||
|
dc.sel[ColFG] = getcolor(SELFGCOLOR);
|
||||||
|
dc.status[ColBG] = getcolor(STATUSBGCOLOR);
|
||||||
|
dc.status[ColFG] = getcolor(STATUSFGCOLOR);
|
||||||
setfont(FONT);
|
setfont(FONT);
|
||||||
|
|
||||||
|
modew = 0;
|
||||||
sx = sy = 0;
|
sx = sy = 0;
|
||||||
sw = DisplayWidth(dpy, screen);
|
sw = DisplayWidth(dpy, screen);
|
||||||
sh = DisplayHeight(dpy, screen);
|
sh = DisplayHeight(dpy, screen);
|
||||||
|
@ -133,7 +137,7 @@ setup()
|
||||||
|
|
||||||
bx = by = 0;
|
bx = by = 0;
|
||||||
bw = sw;
|
bw = sw;
|
||||||
dc.h = bh = dc.font.height + 4;
|
dc.h = bh = dc.font.height + 2;
|
||||||
wa.override_redirect = 1;
|
wa.override_redirect = 1;
|
||||||
wa.background_pixmap = ParentRelative;
|
wa.background_pixmap = ParentRelative;
|
||||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||||
|
|
Loading…
Reference in a new issue