summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-13 11:43:05 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-13 11:43:05 +0200
commit9e8b3258a06de01c53e60243ffe3419b47d016dd (patch)
treea39ebed6cc97e75dc71f7ffb54ebb66342fef48d
parentadded dev.c instead of kb.c (diff)
downloaddwm-9e8b3258a06de01c53e60243ffe3419b47d016dd.tar.gz
dwm-9e8b3258a06de01c53e60243ffe3419b47d016dd.zip
changed default colors
Diffstat (limited to '')
-rw-r--r--Makefile4
-rw-r--r--client.c15
-rw-r--r--dev.c2
-rw-r--r--draw.c89
-rw-r--r--dwm.h (renamed from wm.h)29
-rw-r--r--event.c2
-rw-r--r--main.c (renamed from wm.c)10
-rw-r--r--util.c2
8 files changed, 71 insertions, 82 deletions
diff --git a/Makefile b/Makefile
index 41bc879..d8f9ddc 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
3 3
4include config.mk 4include config.mk
5 5
6SRC = client.c dev.c draw.c event.c util.c wm.c 6SRC = client.c dev.c draw.c event.c main.c util.c
7OBJ = ${SRC:.c=.o} 7OBJ = ${SRC:.c=.o}
8MAN1 = dwm.1 8MAN1 = dwm.1
9BIN = dwm 9BIN = dwm
@@ -22,7 +22,7 @@ config:
22 @echo CC $< 22 @echo CC $<
23 @${CC} -c ${CFLAGS} $< 23 @${CC} -c ${CFLAGS} $<
24 24
25${OBJ}: wm.h 25${OBJ}: dwm.h
26 26
27dwm: ${OBJ} 27dwm: ${OBJ}
28 @echo LD $@ 28 @echo LD $@
diff --git a/client.c b/client.c
index 679e2be..932b23e 100644
--- a/client.c
+++ b/client.c
@@ -9,7 +9,7 @@
9#include <X11/Xatom.h> 9#include <X11/Xatom.h>
10#include <X11/Xutil.h> 10#include <X11/Xutil.h>
11 11
12#include "wm.h" 12#include "dwm.h"
13 13
14static void floating(void); 14static void floating(void);
15static void tiling(void); 15static void tiling(void);
@@ -125,8 +125,8 @@ resize_title(Client *c)
125 c->tw = 0; 125 c->tw = 0;
126 for(i = 0; i < TLast; i++) 126 for(i = 0; i < TLast; i++)
127 if(c->tags[i]) 127 if(c->tags[i])
128 c->tw += textw(&dc.font, c->tags[i]) + dc.font.height; 128 c->tw += textw(c->tags[i]) + dc.font.height;
129 c->tw += textw(&dc.font, c->name) + dc.font.height; 129 c->tw += textw(c->name) + dc.font.height;
130 if(c->tw > c->w) 130 if(c->tw > c->w)
131 c->tw = c->w + 2; 131 c->tw = c->w + 2;
132 c->tx = c->x + c->w - c->tw + 2; 132 c->tx = c->x + c->w - c->tw + 2;
@@ -226,10 +226,12 @@ focus(Client *c)
226 c->snext = stack; 226 c->snext = stack;
227 stack = c; 227 stack = c;
228 if(old && old != c) { 228 if(old && old != c) {
229 XSetWindowBorder(dpy, old->win, dc.bg);
229 XMapWindow(dpy, old->title); 230 XMapWindow(dpy, old->title);
230 draw_client(old); 231 draw_client(old);
231 } 232 }
232 XUnmapWindow(dpy, c->title); 233 XUnmapWindow(dpy, c->title);
234 XSetWindowBorder(dpy, c->win, dc.fg);
233 draw_client(c); 235 draw_client(c);
234 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); 236 XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
235 XFlush(dpy); 237 XFlush(dpy);
@@ -250,8 +252,6 @@ manage(Window w, XWindowAttributes *wa)
250 c->th = th; 252 c->th = th;
251 c->border = 1; 253 c->border = 1;
252 update_size(c); 254 update_size(c);
253 XSetWindowBorderWidth(dpy, c->win, 1);
254 XSetWindowBorder(dpy, c->win, dc.border);
255 XSelectInput(dpy, c->win, 255 XSelectInput(dpy, c->win,
256 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 256 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
257 XGetTransientForHint(dpy, c->win, &c->trans); 257 XGetTransientForHint(dpy, c->win, &c->trans);
@@ -269,6 +269,7 @@ manage(Window w, XWindowAttributes *wa)
269 for(l=&clients; *l; l=&(*l)->next); 269 for(l=&clients; *l; l=&(*l)->next);
270 c->next = *l; /* *l == nil */ 270 c->next = *l; /* *l == nil */
271 *l = c; 271 *l = c;
272 XSetWindowBorderWidth(dpy, c->win, 1);
272 XMapRaised(dpy, c->win); 273 XMapRaised(dpy, c->win);
273 XMapRaised(dpy, c->title); 274 XMapRaised(dpy, c->title);
274 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, 275 XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
@@ -435,12 +436,12 @@ draw_client(Client *c)
435 for(i = 0; i < TLast; i++) { 436 for(i = 0; i < TLast; i++) {
436 if(c->tags[i]) { 437 if(c->tags[i]) {
437 dc.x += dc.w; 438 dc.x += dc.w;
438 dc.w = textw(&dc.font, c->tags[i]) + dc.font.height; 439 dc.w = textw(c->tags[i]) + dc.font.height;
439 draw(True, c->tags[i]); 440 draw(True, c->tags[i]);
440 } 441 }
441 } 442 }
442 dc.x += dc.w; 443 dc.x += dc.w;
443 dc.w = textw(&dc.font, c->name) + dc.font.height; 444 dc.w = textw(c->name) + dc.font.height;
444 draw(True, c->name); 445 draw(True, c->name);
445 XCopyArea(dpy, dc.drawable, c->title, dc.gc, 446 XCopyArea(dpy, dc.drawable, c->title, dc.gc,
446 0, 0, c->tw, c->th, 0, 0); 447 0, 0, c->tw, c->th, 0, 0);
diff --git a/dev.c b/dev.c
index 7e815ec..d5726db 100644
--- a/dev.c
+++ b/dev.c
@@ -3,7 +3,7 @@
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5 5
6#include "wm.h" 6#include "dwm.h"
7 7
8#include <stdlib.h> 8#include <stdlib.h>
9#include <string.h> 9#include <string.h>
diff --git a/draw.c b/draw.c
index 455c137..fc269a2 100644
--- a/draw.c
+++ b/draw.c
@@ -8,7 +8,7 @@
8 8
9#include <X11/Xlocale.h> 9#include <X11/Xlocale.h>
10 10
11#include "wm.h" 11#include "dwm.h"
12 12
13static void 13static void
14drawborder(void) 14drawborder(void)
@@ -59,7 +59,7 @@ draw(Bool border, const char *text)
59 x = dc.x + (h / 2); 59 x = dc.x + (h / 2);
60 60
61 /* shorten text if necessary */ 61 /* shorten text if necessary */
62 while(len && (w = textnw(&dc.font, buf, len)) > dc.w - h) 62 while(len && (w = textnw(buf, len)) > dc.w - h)
63 buf[--len] = 0; 63 buf[--len] = 0;
64 64
65 if(w > dc.w) 65 if(w > dc.w)
@@ -79,93 +79,80 @@ draw(Bool border, const char *text)
79 } 79 }
80} 80}
81 81
82static unsigned long 82unsigned long
83xinitcolors(Colormap cmap, const char *colstr) 83initcolor(const char *colstr)
84{ 84{
85 XColor color; 85 XColor color;
86 Colormap cmap = DefaultColormap(dpy, screen);
87
86 XAllocNamedColor(dpy, cmap, colstr, &color, &color); 88 XAllocNamedColor(dpy, cmap, colstr, &color, &color);
87 return color.pixel; 89 return color.pixel;
88} 90}
89 91
90void
91initcolors(const char *bg, const char *fg, const char *border)
92{
93 Colormap cmap = DefaultColormap(dpy, screen);
94 dc.bg = xinitcolors(cmap, bg);
95 dc.fg = xinitcolors(cmap, fg);
96 dc.border = xinitcolors(cmap, border);
97}
98
99unsigned int 92unsigned int
100textnw(Fnt *font, char *text, unsigned int len) 93textnw(char *text, unsigned int len)
101{ 94{
102 XRectangle r; 95 XRectangle r;
103 if(font->set) { 96 if(dc.font.set) {
104 XmbTextExtents(font->set, text, len, NULL, &r); 97 XmbTextExtents(dc.font.set, text, len, NULL, &r);
105 return r.width; 98 return r.width;
106 } 99 }
107 return XTextWidth(font->xfont, text, len); 100 return XTextWidth(dc.font.xfont, text, len);
108}
109
110unsigned int
111textw(Fnt *font, char *text)
112{
113 return textnw(font, text, strlen(text));
114} 101}
115 102
116unsigned int 103unsigned int
117texth(Fnt *font) 104textw(char *text)
118{ 105{
119 return font->height + 4; 106 return textnw(text, strlen(text));
120} 107}
121 108
122void 109void
123initfont(Fnt *font, const char *fontstr) 110initfont(const char *fontstr)
124{ 111{
125 char **missing, *def; 112 char **missing, *def;
126 int i, n; 113 int i, n;
127 114
128 missing = NULL; 115 missing = NULL;
129 setlocale(LC_ALL, ""); 116 setlocale(LC_ALL, "");
130 if(font->set) 117 if(dc.font.set)
131 XFreeFontSet(dpy, font->set); 118 XFreeFontSet(dpy, dc.font.set);
132 font->set = XCreateFontSet(dpy, fontstr, &missing, &n, &def); 119 dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
133 if(missing) { 120 if(missing) {
134 while(n--) 121 while(n--)
135 fprintf(stderr, "missing fontset: %s\n", missing[n]); 122 fprintf(stderr, "missing fontset: %s\n", missing[n]);
136 XFreeStringList(missing); 123 XFreeStringList(missing);
137 if(font->set) { 124 if(dc.font.set) {
138 XFreeFontSet(dpy, font->set); 125 XFreeFontSet(dpy, dc.font.set);
139 font->set = NULL; 126 dc.font.set = NULL;
140 } 127 }
141 } 128 }
142 if(font->set) { 129 if(dc.font.set) {
143 XFontSetExtents *font_extents; 130 XFontSetExtents *font_extents;
144 XFontStruct **xfonts; 131 XFontStruct **xfonts;
145 char **font_names; 132 char **font_names;
146 133
147 font->ascent = font->descent = 0; 134 dc.font.ascent = dc.font.descent = 0;
148 font_extents = XExtentsOfFontSet(font->set); 135 font_extents = XExtentsOfFontSet(dc.font.set);
149 n = XFontsOfFontSet(font->set, &xfonts, &font_names); 136 n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
150 for(i = 0, font->ascent = 0, font->descent = 0; i < n; i++) { 137 for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
151 if(font->ascent < (*xfonts)->ascent) 138 if(dc.font.ascent < (*xfonts)->ascent)
152 font->ascent = (*xfonts)->ascent; 139 dc.font.ascent = (*xfonts)->ascent;
153 if(font->descent < (*xfonts)->descent) 140 if(dc.font.descent < (*xfonts)->descent)
154 font->descent = (*xfonts)->descent; 141 dc.font.descent = (*xfonts)->descent;
155 xfonts++; 142 xfonts++;
156 } 143 }
157 } 144 }
158 else { 145 else {
159 if(font->xfont) 146 if(dc.font.xfont)
160 XFreeFont(dpy, font->xfont); 147 XFreeFont(dpy, dc.font.xfont);
161 font->xfont = NULL; 148 dc.font.xfont = NULL;
162 font->xfont = XLoadQueryFont(dpy, fontstr); 149 dc.font.xfont = XLoadQueryFont(dpy, fontstr);
163 if (!font->xfont) 150 if (!dc.font.xfont)
164 font->xfont = XLoadQueryFont(dpy, "fixed"); 151 dc.font.xfont = XLoadQueryFont(dpy, "fixed");
165 if (!font->xfont) 152 if (!dc.font.xfont)
166 error("error, cannot init 'fixed' font\n"); 153 error("error, cannot init 'fixed' font\n");
167 font->ascent = font->xfont->ascent; 154 dc.font.ascent = dc.font.xfont->ascent;
168 font->descent = font->xfont->descent; 155 dc.font.descent = dc.font.xfont->descent;
169 } 156 }
170 font->height = font->ascent + font->descent; 157 dc.font.height = dc.font.ascent + dc.font.descent;
171} 158}
diff --git a/wm.h b/dwm.h
index 7e48434..acfdcbb 100644
--- a/wm.h
+++ b/dwm.h
@@ -8,10 +8,9 @@
8/********** CUSTOMIZE **********/ 8/********** CUSTOMIZE **********/
9 9
10#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*" 10#define FONT "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
11#define BGCOLOR "#666699" 11#define BGCOLOR "DarkSlateGrey"
12#define FGCOLOR "#ffffff" 12#define FGCOLOR "LightSteelBlue"
13#define BORDERCOLOR "#9999CC" 13#define BORDERCOLOR "SlateGray"
14#define STATUSDELAY 10 /* seconds */
15#define WM_PROTOCOL_DELWIN 1 14#define WM_PROTOCOL_DELWIN 1
16 15
17/* tags */ 16/* tags */
@@ -106,11 +105,11 @@ extern void gravitate(Client *c, Bool invert);
106 105
107/* draw.c */ 106/* draw.c */
108extern void draw(Bool border, const char *text); 107extern void draw(Bool border, const char *text);
109extern void initcolors(const char *bg, const char *fg, const char *bo); 108extern unsigned long initcolor(const char *colstr);
110extern void initfont(Fnt *font, const char *fontstr); 109extern void initfont(const char *fontstr);
111extern unsigned int textnw(Fnt *font, char *text, unsigned int len); 110extern unsigned int textnw(char *text, unsigned int len);
112extern unsigned int textw(Fnt *font, char *text); 111extern unsigned int textw(char *text);
113extern unsigned int texth(Fnt *font); 112extern unsigned int texth(void);
114 113
115/* event.c */ 114/* event.c */
116extern void discard_events(long even_mask); 115extern void discard_events(long even_mask);
@@ -121,6 +120,12 @@ extern void keypress(XEvent *e);
121extern void mresize(Client *c); 120extern void mresize(Client *c);
122extern void mmove(Client *c); 121extern void mmove(Client *c);
123 122
123/* main.c */
124extern int error_handler(Display *dsply, XErrorEvent *e);
125extern void send_message(Window w, Atom a, long value);
126extern int win_proto(Window w);
127extern void quit(void *aux);
128
124/* util.c */ 129/* util.c */
125extern void error(const char *errstr, ...); 130extern void error(const char *errstr, ...);
126extern void *emallocz(unsigned int size); 131extern void *emallocz(unsigned int size);
@@ -129,9 +134,3 @@ extern void *erealloc(void *ptr, unsigned int size);
129extern char *estrdup(const char *str); 134extern char *estrdup(const char *str);
130extern void spawn(char *argv[]); 135extern void spawn(char *argv[]);
131extern void swap(void **p1, void **p2); 136extern void swap(void **p1, void **p2);
132
133/* wm.c */
134extern int error_handler(Display *dsply, XErrorEvent *e);
135extern void send_message(Window w, Atom a, long value);
136extern int win_proto(Window w);
137extern void quit(void *aux);
diff --git a/event.c b/event.c
index 5ff6b91..937bee2 100644
--- a/event.c
+++ b/event.c
@@ -9,7 +9,7 @@
9#include <X11/keysym.h> 9#include <X11/keysym.h>
10#include <X11/Xatom.h> 10#include <X11/Xatom.h>
11 11
12#include "wm.h" 12#include "dwm.h"
13 13
14/* local functions */ 14/* local functions */
15static void buttonpress(XEvent *e); 15static void buttonpress(XEvent *e);
diff --git a/wm.c b/main.c
index ed002f7..b63d07e 100644
--- a/wm.c
+++ b/main.c
@@ -11,7 +11,7 @@
11#include <X11/Xatom.h> 11#include <X11/Xatom.h>
12#include <X11/Xproto.h> 12#include <X11/Xproto.h>
13 13
14#include "wm.h" 14#include "dwm.h"
15 15
16/********** CUSTOMIZE **********/ 16/********** CUSTOMIZE **********/
17 17
@@ -244,10 +244,12 @@ main(int argc, char *argv[])
244 update_keys(); 244 update_keys();
245 245
246 /* style */ 246 /* style */
247 initcolors(BGCOLOR, FGCOLOR, BORDERCOLOR); 247 dc.bg = initcolor(BGCOLOR);
248 initfont(&dc.font, FONT); 248 dc.fg = initcolor(FGCOLOR);
249 dc.border = initcolor(BORDERCOLOR);
250 initfont(FONT);
249 251
250 th = texth(&dc.font); 252 th = dc.font.height + 4;
251 253
252 dc.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen)); 254 dc.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
253 dc.gc = XCreateGC(dpy, root, 0, 0); 255 dc.gc = XCreateGC(dpy, root, 0, 0);
diff --git a/util.c b/util.c
index 0a5bd96..14a4511 100644
--- a/util.c
+++ b/util.c
@@ -11,7 +11,7 @@
11#include <sys/wait.h> 11#include <sys/wait.h>
12#include <unistd.h> 12#include <unistd.h>
13 13
14#include "wm.h" 14#include "dwm.h"
15 15
16void 16void
17error(const char *errstr, ...) { 17error(const char *errstr, ...) {