summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-11 18:53:41 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 18:53:41 +0200
commitd6e0e6e9879c144f5d374fca0c015fd6208fc27e (patch)
tree997db1276dc89c44361a56d80a66fb3722f8f2fe
parentremoved unnecessary sel stuff (diff)
downloaddwm-d6e0e6e9879c144f5d374fca0c015fd6208fc27e.tar.gz
dwm-d6e0e6e9879c144f5d374fca0c015fd6208fc27e.zip
several changes, new stuff
-rw-r--r--bar.c24
-rw-r--r--client.c5
-rw-r--r--config.h2
-rw-r--r--event.c1
-rw-r--r--util.c2
-rw-r--r--wm.c16
-rw-r--r--wm.h3
7 files changed, 34 insertions, 19 deletions
diff --git a/bar.c b/bar.c
index 17db8cd..f3a11b8 100644
--- a/bar.c
+++ b/bar.c
@@ -5,22 +5,24 @@
5 5
6#include "wm.h" 6#include "wm.h"
7 7
8static const char *status[] = {
9 "sh", "-c", "echo -n `date` `uptime | sed 's/.*://; s/,//g'`"
10 " `acpi | awk '{print $4}' | sed 's/,//'`", 0 \
11};
12
13void 8void
14draw_bar() 9draw_bar()
15{ 10{
16 static char buf[1024];
17
18 buf[0] = 0;
19 pipe_spawn(buf, sizeof(buf), dpy, (char **)status);
20
21 brush.rect = barrect; 11 brush.rect = barrect;
22 brush.rect.x = brush.rect.y = 0; 12 brush.rect.x = brush.rect.y = 0;
23 draw(dpy, &brush, False, buf); 13 draw(dpy, &brush, False, NULL);
14
15 if(stack) {
16 brush.rect.width = textwidth(&brush.font, stack->name) + labelheight(&brush.font);
17 swap((void **)&brush.fg, (void **)&brush.bg);
18 draw(dpy, &brush, False, stack->name);
19 swap((void **)&brush.fg, (void **)&brush.bg);
20 brush.rect.x += brush.rect.width;
21 }
22
23 brush.rect.width = textwidth(&brush.font, statustext) + labelheight(&brush.font);
24 brush.rect.x = barrect.x + barrect.width - brush.rect.width;
25 draw(dpy, &brush, False, statustext);
24 26
25 XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width, 27 XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width,
26 barrect.height, 0, 0); 28 barrect.height, 0, 0);
diff --git a/client.c b/client.c
index f87fb80..9407f0a 100644
--- a/client.c
+++ b/client.c
@@ -35,6 +35,10 @@ update_name(Client *c)
35 } 35 }
36 } 36 }
37 XFree(name.value); 37 XFree(name.value);
38 if(c == stack)
39 draw_bar();
40 else
41 draw_client(c);
38} 42}
39 43
40void 44void
@@ -66,6 +70,7 @@ manage(Window w, XWindowAttributes *wa)
66 c->r[RFloat].height = wa->height; 70 c->r[RFloat].height = wa->height;
67 c->border = wa->border_width; 71 c->border = wa->border_width;
68 XSetWindowBorderWidth(dpy, c->win, 0); 72 XSetWindowBorderWidth(dpy, c->win, 0);
73 XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
69 XGetTransientForHint(dpy, c->win, &c->trans); 74 XGetTransientForHint(dpy, c->win, &c->trans);
70 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags) 75 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
71 c->size.flags = PSize; 76 c->size.flags = PSize;
diff --git a/config.h b/config.h
index ce9e7ab..a8e3449 100644
--- a/config.h
+++ b/config.h
@@ -7,4 +7,4 @@
7#define BGCOLOR "#000000" 7#define BGCOLOR "#000000"
8#define FGCOLOR "#ffaa00" 8#define FGCOLOR "#ffaa00"
9#define BORDERCOLOR "#000000" 9#define BORDERCOLOR "#000000"
10#define STATUSDELAY 1 /* milliseconds */ 10#define STATUSDELAY 10 /* milliseconds */
diff --git a/event.c b/event.c
index ccab9d1..344a0cc 100644
--- a/event.c
+++ b/event.c
@@ -187,7 +187,6 @@ propertynotify(XEvent *e)
187 } 187 }
188 if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) { 188 if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
189 update_name(c); 189 update_name(c);
190 /*draw_frame(c->sel);*/
191 } 190 }
192 } 191 }
193} 192}
diff --git a/util.c b/util.c
index 76ba5ab..9da8f52 100644
--- a/util.c
+++ b/util.c
@@ -134,7 +134,7 @@ pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[])
134 n += l; 134 n += l;
135 } 135 }
136 close(pfd[0]); 136 close(pfd[0]);
137 buf[n - 1] = 0; 137 buf[n < len ? n : len - 1] = 0;
138 } 138 }
139 wait(0); 139 wait(0);
140} 140}
diff --git a/wm.c b/wm.c
index f247372..837be3c 100644
--- a/wm.c
+++ b/wm.c
@@ -27,7 +27,7 @@ XRectangle rect, barrect;
27Bool running = True; 27Bool running = True;
28Bool sel_screen; 28Bool sel_screen;
29 29
30char *bartext, tag[256]; 30char statustext[1024], tag[256];
31int screen; 31int screen;
32 32
33Brush brush = {0}; 33Brush brush = {0};
@@ -35,9 +35,15 @@ Client *clients = NULL;
35Client *stack = NULL; 35Client *stack = NULL;
36 36
37static Bool other_wm_running; 37static Bool other_wm_running;
38static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 38static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
39static int (*x_error_handler) (Display *, XErrorEvent *); 39static int (*x_error_handler) (Display *, XErrorEvent *);
40 40
41static const char *status[] = {
42 "sh", "-c", "echo -n `date '+%Y/%m/%d %H:%M'`"
43 " `uptime | sed 's/.*://; s/,//g'`"
44 " `acpi | awk '{print $4}' | sed 's/,//'`", 0
45};
46
41static void 47static void
42usage() 48usage()
43{ 49{
@@ -258,9 +264,9 @@ main(int argc, char *argv[])
258 barrect.width, barrect.height, 0, DefaultDepth(dpy, screen), 264 barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
259 CopyFromParent, DefaultVisual(dpy, screen), 265 CopyFromParent, DefaultVisual(dpy, screen),
260 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 266 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
261 bartext = NULL;
262 XDefineCursor(dpy, barwin, cursor[CurNormal]); 267 XDefineCursor(dpy, barwin, cursor[CurNormal]);
263 XMapRaised(dpy, barwin); 268 XMapRaised(dpy, barwin);
269 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
264 draw_bar(); 270 draw_bar();
265 271
266 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ 272 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
@@ -282,8 +288,10 @@ main(int argc, char *argv[])
282 t = timeout; 288 t = timeout;
283 if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0) 289 if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
284 continue; 290 continue;
285 else if(errno != EINTR) 291 else if(errno != EINTR) {
292 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
286 draw_bar(); 293 draw_bar();
294 }
287 } 295 }
288 296
289 cleanup(); 297 cleanup();
diff --git a/wm.h b/wm.h
index 24662fa..055ef62 100644
--- a/wm.h
+++ b/wm.h
@@ -55,7 +55,7 @@ extern Bool running, sel_screen, grid;
55extern void (*handler[LASTEvent]) (XEvent *); 55extern void (*handler[LASTEvent]) (XEvent *);
56 56
57extern int screen; 57extern int screen;
58extern char *bartext, tag[256]; 58extern char statustext[1024], tag[256];
59 59
60extern Brush brush; 60extern Brush brush;
61extern Client *clients, *stack; 61extern Client *clients, *stack;
@@ -74,6 +74,7 @@ extern void unmanage(Client *c);
74extern Client *getclient(Window w); 74extern Client *getclient(Window w);
75extern void focus(Client *c); 75extern void focus(Client *c);
76extern void update_name(Client *c); 76extern void update_name(Client *c);
77extern void draw_client(Client *c);
77 78
78/* event.c */ 79/* event.c */
79extern unsigned int flush_events(long even_mask); 80extern unsigned int flush_events(long even_mask);