changed default colors
This commit is contained in:
parent
44f2e8b952
commit
9e8b3258a0
4
Makefile
4
Makefile
|
@ -3,7 +3,7 @@
|
|||
|
||||
include config.mk
|
||||
|
||||
SRC = client.c dev.c draw.c event.c util.c wm.c
|
||||
SRC = client.c dev.c draw.c event.c main.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
MAN1 = dwm.1
|
||||
BIN = dwm
|
||||
|
@ -22,7 +22,7 @@ config:
|
|||
@echo CC $<
|
||||
@${CC} -c ${CFLAGS} $<
|
||||
|
||||
${OBJ}: wm.h
|
||||
${OBJ}: dwm.h
|
||||
|
||||
dwm: ${OBJ}
|
||||
@echo LD $@
|
||||
|
|
15
client.c
15
client.c
|
@ -9,7 +9,7 @@
|
|||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include "wm.h"
|
||||
#include "dwm.h"
|
||||
|
||||
static void floating(void);
|
||||
static void tiling(void);
|
||||
|
@ -125,8 +125,8 @@ resize_title(Client *c)
|
|||
c->tw = 0;
|
||||
for(i = 0; i < TLast; i++)
|
||||
if(c->tags[i])
|
||||
c->tw += textw(&dc.font, c->tags[i]) + dc.font.height;
|
||||
c->tw += textw(&dc.font, c->name) + dc.font.height;
|
||||
c->tw += textw(c->tags[i]) + dc.font.height;
|
||||
c->tw += textw(c->name) + dc.font.height;
|
||||
if(c->tw > c->w)
|
||||
c->tw = c->w + 2;
|
||||
c->tx = c->x + c->w - c->tw + 2;
|
||||
|
@ -226,10 +226,12 @@ focus(Client *c)
|
|||
c->snext = stack;
|
||||
stack = c;
|
||||
if(old && old != c) {
|
||||
XSetWindowBorder(dpy, old->win, dc.bg);
|
||||
XMapWindow(dpy, old->title);
|
||||
draw_client(old);
|
||||
}
|
||||
XUnmapWindow(dpy, c->title);
|
||||
XSetWindowBorder(dpy, c->win, dc.fg);
|
||||
draw_client(c);
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
XFlush(dpy);
|
||||
|
@ -250,8 +252,6 @@ manage(Window w, XWindowAttributes *wa)
|
|||
c->th = th;
|
||||
c->border = 1;
|
||||
update_size(c);
|
||||
XSetWindowBorderWidth(dpy, c->win, 1);
|
||||
XSetWindowBorder(dpy, c->win, dc.border);
|
||||
XSelectInput(dpy, c->win,
|
||||
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
|
||||
XGetTransientForHint(dpy, c->win, &c->trans);
|
||||
|
@ -269,6 +269,7 @@ manage(Window w, XWindowAttributes *wa)
|
|||
for(l=&clients; *l; l=&(*l)->next);
|
||||
c->next = *l; /* *l == nil */
|
||||
*l = c;
|
||||
XSetWindowBorderWidth(dpy, c->win, 1);
|
||||
XMapRaised(dpy, c->win);
|
||||
XMapRaised(dpy, c->title);
|
||||
XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
|
||||
|
@ -435,12 +436,12 @@ draw_client(Client *c)
|
|||
for(i = 0; i < TLast; i++) {
|
||||
if(c->tags[i]) {
|
||||
dc.x += dc.w;
|
||||
dc.w = textw(&dc.font, c->tags[i]) + dc.font.height;
|
||||
dc.w = textw(c->tags[i]) + dc.font.height;
|
||||
draw(True, c->tags[i]);
|
||||
}
|
||||
}
|
||||
dc.x += dc.w;
|
||||
dc.w = textw(&dc.font, c->name) + dc.font.height;
|
||||
dc.w = textw(c->name) + dc.font.height;
|
||||
draw(True, c->name);
|
||||
XCopyArea(dpy, dc.drawable, c->title, dc.gc,
|
||||
0, 0, c->tw, c->th, 0, 0);
|
||||
|
|
2
dev.c
2
dev.c
|
@ -3,7 +3,7 @@
|
|||
* See LICENSE file for license details.
|
||||
*/
|
||||
|
||||
#include "wm.h"
|
||||
#include "dwm.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
89
draw.c
89
draw.c
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <X11/Xlocale.h>
|
||||
|
||||
#include "wm.h"
|
||||
#include "dwm.h"
|
||||
|
||||
static void
|
||||
drawborder(void)
|
||||
|
@ -59,7 +59,7 @@ draw(Bool border, const char *text)
|
|||
x = dc.x + (h / 2);
|
||||
|
||||
/* shorten text if necessary */
|
||||
while(len && (w = textnw(&dc.font, buf, len)) > dc.w - h)
|
||||
while(len && (w = textnw(buf, len)) > dc.w - h)
|
||||
buf[--len] = 0;
|
||||
|
||||
if(w > dc.w)
|
||||
|
@ -79,93 +79,80 @@ draw(Bool border, const char *text)
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
xinitcolors(Colormap cmap, const char *colstr)
|
||||
unsigned long
|
||||
initcolor(const char *colstr)
|
||||
{
|
||||
XColor color;
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
|
||||
XAllocNamedColor(dpy, cmap, colstr, &color, &color);
|
||||
return color.pixel;
|
||||
}
|
||||
|
||||
void
|
||||
initcolors(const char *bg, const char *fg, const char *border)
|
||||
{
|
||||
Colormap cmap = DefaultColormap(dpy, screen);
|
||||
dc.bg = xinitcolors(cmap, bg);
|
||||
dc.fg = xinitcolors(cmap, fg);
|
||||
dc.border = xinitcolors(cmap, border);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
textnw(Fnt *font, char *text, unsigned int len)
|
||||
textnw(char *text, unsigned int len)
|
||||
{
|
||||
XRectangle r;
|
||||
if(font->set) {
|
||||
XmbTextExtents(font->set, text, len, NULL, &r);
|
||||
if(dc.font.set) {
|
||||
XmbTextExtents(dc.font.set, text, len, NULL, &r);
|
||||
return r.width;
|
||||
}
|
||||
return XTextWidth(font->xfont, text, len);
|
||||
return XTextWidth(dc.font.xfont, text, len);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
textw(Fnt *font, char *text)
|
||||
textw(char *text)
|
||||
{
|
||||
return textnw(font, text, strlen(text));
|
||||
}
|
||||
|
||||
unsigned int
|
||||
texth(Fnt *font)
|
||||
{
|
||||
return font->height + 4;
|
||||
return textnw(text, strlen(text));
|
||||
}
|
||||
|
||||
void
|
||||
initfont(Fnt *font, const char *fontstr)
|
||||
initfont(const char *fontstr)
|
||||
{
|
||||
char **missing, *def;
|
||||
int i, n;
|
||||
|
||||
missing = NULL;
|
||||
setlocale(LC_ALL, "");
|
||||
if(font->set)
|
||||
XFreeFontSet(dpy, font->set);
|
||||
font->set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
|
||||
if(dc.font.set)
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
|
||||
if(missing) {
|
||||
while(n--)
|
||||
fprintf(stderr, "missing fontset: %s\n", missing[n]);
|
||||
XFreeStringList(missing);
|
||||
if(font->set) {
|
||||
XFreeFontSet(dpy, font->set);
|
||||
font->set = NULL;
|
||||
if(dc.font.set) {
|
||||
XFreeFontSet(dpy, dc.font.set);
|
||||
dc.font.set = NULL;
|
||||
}
|
||||
}
|
||||
if(font->set) {
|
||||
if(dc.font.set) {
|
||||
XFontSetExtents *font_extents;
|
||||
XFontStruct **xfonts;
|
||||
char **font_names;
|
||||
|
||||
font->ascent = font->descent = 0;
|
||||
font_extents = XExtentsOfFontSet(font->set);
|
||||
n = XFontsOfFontSet(font->set, &xfonts, &font_names);
|
||||
for(i = 0, font->ascent = 0, font->descent = 0; i < n; i++) {
|
||||
if(font->ascent < (*xfonts)->ascent)
|
||||
font->ascent = (*xfonts)->ascent;
|
||||
if(font->descent < (*xfonts)->descent)
|
||||
font->descent = (*xfonts)->descent;
|
||||
dc.font.ascent = dc.font.descent = 0;
|
||||
font_extents = XExtentsOfFontSet(dc.font.set);
|
||||
n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
|
||||
for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
|
||||
if(dc.font.ascent < (*xfonts)->ascent)
|
||||
dc.font.ascent = (*xfonts)->ascent;
|
||||
if(dc.font.descent < (*xfonts)->descent)
|
||||
dc.font.descent = (*xfonts)->descent;
|
||||
xfonts++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(font->xfont)
|
||||
XFreeFont(dpy, font->xfont);
|
||||
font->xfont = NULL;
|
||||
font->xfont = XLoadQueryFont(dpy, fontstr);
|
||||
if (!font->xfont)
|
||||
font->xfont = XLoadQueryFont(dpy, "fixed");
|
||||
if (!font->xfont)
|
||||
if(dc.font.xfont)
|
||||
XFreeFont(dpy, dc.font.xfont);
|
||||
dc.font.xfont = NULL;
|
||||
dc.font.xfont = XLoadQueryFont(dpy, fontstr);
|
||||
if (!dc.font.xfont)
|
||||
dc.font.xfont = XLoadQueryFont(dpy, "fixed");
|
||||
if (!dc.font.xfont)
|
||||
error("error, cannot init 'fixed' font\n");
|
||||
font->ascent = font->xfont->ascent;
|
||||
font->descent = font->xfont->descent;
|
||||
dc.font.ascent = dc.font.xfont->ascent;
|
||||
dc.font.descent = dc.font.xfont->descent;
|
||||
}
|
||||
font->height = font->ascent + font->descent;
|
||||
dc.font.height = dc.font.ascent + dc.font.descent;
|
||||
}
|
||||
|
|
29
wm.h → dwm.h
29
wm.h → dwm.h
|
@ -8,10 +8,9 @@
|
|||
/********** CUSTOMIZE **********/
|
||||
|
||||
#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
|
||||
#define BGCOLOR "#666699"
|
||||
#define FGCOLOR "#ffffff"
|
||||
#define BORDERCOLOR "#9999CC"
|
||||
#define STATUSDELAY 10 /* seconds */
|
||||
#define BGCOLOR "DarkSlateGrey"
|
||||
#define FGCOLOR "LightSteelBlue"
|
||||
#define BORDERCOLOR "SlateGray"
|
||||
#define WM_PROTOCOL_DELWIN 1
|
||||
|
||||
/* tags */
|
||||
|
@ -106,11 +105,11 @@ extern void gravitate(Client *c, Bool invert);
|
|||
|
||||
/* draw.c */
|
||||
extern void draw(Bool border, const char *text);
|
||||
extern void initcolors(const char *bg, const char *fg, const char *bo);
|
||||
extern void initfont(Fnt *font, const char *fontstr);
|
||||
extern unsigned int textnw(Fnt *font, char *text, unsigned int len);
|
||||
extern unsigned int textw(Fnt *font, char *text);
|
||||
extern unsigned int texth(Fnt *font);
|
||||
extern unsigned long initcolor(const char *colstr);
|
||||
extern void initfont(const char *fontstr);
|
||||
extern unsigned int textnw(char *text, unsigned int len);
|
||||
extern unsigned int textw(char *text);
|
||||
extern unsigned int texth(void);
|
||||
|
||||
/* event.c */
|
||||
extern void discard_events(long even_mask);
|
||||
|
@ -121,6 +120,12 @@ extern void keypress(XEvent *e);
|
|||
extern void mresize(Client *c);
|
||||
extern void mmove(Client *c);
|
||||
|
||||
/* main.c */
|
||||
extern int error_handler(Display *dsply, XErrorEvent *e);
|
||||
extern void send_message(Window w, Atom a, long value);
|
||||
extern int win_proto(Window w);
|
||||
extern void quit(void *aux);
|
||||
|
||||
/* util.c */
|
||||
extern void error(const char *errstr, ...);
|
||||
extern void *emallocz(unsigned int size);
|
||||
|
@ -129,9 +134,3 @@ extern void *erealloc(void *ptr, unsigned int size);
|
|||
extern char *estrdup(const char *str);
|
||||
extern void spawn(char *argv[]);
|
||||
extern void swap(void **p1, void **p2);
|
||||
|
||||
/* wm.c */
|
||||
extern int error_handler(Display *dsply, XErrorEvent *e);
|
||||
extern void send_message(Window w, Atom a, long value);
|
||||
extern int win_proto(Window w);
|
||||
extern void quit(void *aux);
|
2
event.c
2
event.c
|
@ -9,7 +9,7 @@
|
|||
#include <X11/keysym.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include "wm.h"
|
||||
#include "dwm.h"
|
||||
|
||||
/* local functions */
|
||||
static void buttonpress(XEvent *e);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <X11/Xatom.h>
|
||||
#include <X11/Xproto.h>
|
||||
|
||||
#include "wm.h"
|
||||
#include "dwm.h"
|
||||
|
||||
/********** CUSTOMIZE **********/
|
||||
|
||||
|
@ -244,10 +244,12 @@ main(int argc, char *argv[])
|
|||
update_keys();
|
||||
|
||||
/* style */
|
||||
initcolors(BGCOLOR, FGCOLOR, BORDERCOLOR);
|
||||
initfont(&dc.font, FONT);
|
||||
dc.bg = initcolor(BGCOLOR);
|
||||
dc.fg = initcolor(FGCOLOR);
|
||||
dc.border = initcolor(BORDERCOLOR);
|
||||
initfont(FONT);
|
||||
|
||||
th = texth(&dc.font);
|
||||
th = dc.font.height + 4;
|
||||
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
Loading…
Reference in New Issue