dwm-meillo
changeset 16:359b6e563b95
several changes, new stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 18:53:41 +0200 |
parents | 00d4d52b231f |
children | aaf520f53110 |
files | bar.c client.c config.h event.c util.c wm.c wm.h |
diffstat | 7 files changed, 34 insertions(+), 19 deletions(-) [+] |
line diff
1.1 --- a/bar.c Tue Jul 11 18:19:01 2006 +0200 1.2 +++ b/bar.c Tue Jul 11 18:53:41 2006 +0200 1.3 @@ -5,22 +5,24 @@ 1.4 1.5 #include "wm.h" 1.6 1.7 -static const char *status[] = { 1.8 - "sh", "-c", "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" 1.9 - " `acpi | awk '{print $4}' | sed 's/,//'`", 0 \ 1.10 -}; 1.11 - 1.12 void 1.13 draw_bar() 1.14 { 1.15 - static char buf[1024]; 1.16 - 1.17 - buf[0] = 0; 1.18 - pipe_spawn(buf, sizeof(buf), dpy, (char **)status); 1.19 - 1.20 brush.rect = barrect; 1.21 brush.rect.x = brush.rect.y = 0; 1.22 - draw(dpy, &brush, False, buf); 1.23 + draw(dpy, &brush, False, NULL); 1.24 + 1.25 + if(stack) { 1.26 + brush.rect.width = textwidth(&brush.font, stack->name) + labelheight(&brush.font); 1.27 + swap((void **)&brush.fg, (void **)&brush.bg); 1.28 + draw(dpy, &brush, False, stack->name); 1.29 + swap((void **)&brush.fg, (void **)&brush.bg); 1.30 + brush.rect.x += brush.rect.width; 1.31 + } 1.32 + 1.33 + brush.rect.width = textwidth(&brush.font, statustext) + labelheight(&brush.font); 1.34 + brush.rect.x = barrect.x + barrect.width - brush.rect.width; 1.35 + draw(dpy, &brush, False, statustext); 1.36 1.37 XCopyArea(dpy, brush.drawable, barwin, brush.gc, 0, 0, barrect.width, 1.38 barrect.height, 0, 0);
2.1 --- a/client.c Tue Jul 11 18:19:01 2006 +0200 2.2 +++ b/client.c Tue Jul 11 18:53:41 2006 +0200 2.3 @@ -35,6 +35,10 @@ 2.4 } 2.5 } 2.6 XFree(name.value); 2.7 + if(c == stack) 2.8 + draw_bar(); 2.9 + else 2.10 + draw_client(c); 2.11 } 2.12 2.13 void 2.14 @@ -66,6 +70,7 @@ 2.15 c->r[RFloat].height = wa->height; 2.16 c->border = wa->border_width; 2.17 XSetWindowBorderWidth(dpy, c->win, 0); 2.18 + XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 2.19 XGetTransientForHint(dpy, c->win, &c->trans); 2.20 if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags) 2.21 c->size.flags = PSize;
3.1 --- a/config.h Tue Jul 11 18:19:01 2006 +0200 3.2 +++ b/config.h Tue Jul 11 18:53:41 2006 +0200 3.3 @@ -7,4 +7,4 @@ 3.4 #define BGCOLOR "#000000" 3.5 #define FGCOLOR "#ffaa00" 3.6 #define BORDERCOLOR "#000000" 3.7 -#define STATUSDELAY 1 /* milliseconds */ 3.8 +#define STATUSDELAY 10 /* milliseconds */
4.1 --- a/event.c Tue Jul 11 18:19:01 2006 +0200 4.2 +++ b/event.c Tue Jul 11 18:53:41 2006 +0200 4.3 @@ -187,7 +187,6 @@ 4.4 } 4.5 if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) { 4.6 update_name(c); 4.7 - /*draw_frame(c->sel);*/ 4.8 } 4.9 } 4.10 }
5.1 --- a/util.c Tue Jul 11 18:19:01 2006 +0200 5.2 +++ b/util.c Tue Jul 11 18:53:41 2006 +0200 5.3 @@ -134,7 +134,7 @@ 5.4 n += l; 5.5 } 5.6 close(pfd[0]); 5.7 - buf[n - 1] = 0; 5.8 + buf[n < len ? n : len - 1] = 0; 5.9 } 5.10 wait(0); 5.11 }
6.1 --- a/wm.c Tue Jul 11 18:19:01 2006 +0200 6.2 +++ b/wm.c Tue Jul 11 18:53:41 2006 +0200 6.3 @@ -27,7 +27,7 @@ 6.4 Bool running = True; 6.5 Bool sel_screen; 6.6 6.7 -char *bartext, tag[256]; 6.8 +char statustext[1024], tag[256]; 6.9 int screen; 6.10 6.11 Brush brush = {0}; 6.12 @@ -35,9 +35,15 @@ 6.13 Client *stack = NULL; 6.14 6.15 static Bool other_wm_running; 6.16 -static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 6.17 +static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 6.18 static int (*x_error_handler) (Display *, XErrorEvent *); 6.19 6.20 +static const char *status[] = { 6.21 + "sh", "-c", "echo -n `date '+%Y/%m/%d %H:%M'`" 6.22 + " `uptime | sed 's/.*://; s/,//g'`" 6.23 + " `acpi | awk '{print $4}' | sed 's/,//'`", 0 6.24 +}; 6.25 + 6.26 static void 6.27 usage() 6.28 { 6.29 @@ -258,9 +264,9 @@ 6.30 barrect.width, barrect.height, 0, DefaultDepth(dpy, screen), 6.31 CopyFromParent, DefaultVisual(dpy, screen), 6.32 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 6.33 - bartext = NULL; 6.34 XDefineCursor(dpy, barwin, cursor[CurNormal]); 6.35 XMapRaised(dpy, barwin); 6.36 + pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); 6.37 draw_bar(); 6.38 6.39 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ 6.40 @@ -282,8 +288,10 @@ 6.41 t = timeout; 6.42 if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0) 6.43 continue; 6.44 - else if(errno != EINTR) 6.45 + else if(errno != EINTR) { 6.46 + pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); 6.47 draw_bar(); 6.48 + } 6.49 } 6.50 6.51 cleanup();
7.1 --- a/wm.h Tue Jul 11 18:19:01 2006 +0200 7.2 +++ b/wm.h Tue Jul 11 18:53:41 2006 +0200 7.3 @@ -55,7 +55,7 @@ 7.4 extern void (*handler[LASTEvent]) (XEvent *); 7.5 7.6 extern int screen; 7.7 -extern char *bartext, tag[256]; 7.8 +extern char statustext[1024], tag[256]; 7.9 7.10 extern Brush brush; 7.11 extern Client *clients, *stack; 7.12 @@ -74,6 +74,7 @@ 7.13 extern Client *getclient(Window w); 7.14 extern void focus(Client *c); 7.15 extern void update_name(Client *c); 7.16 +extern void draw_client(Client *c); 7.17 7.18 /* event.c */ 7.19 extern unsigned int flush_events(long even_mask);