diff options
| author | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-11 18:53:41 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-11 18:53:41 +0200 |
| commit | d6e0e6e9879c144f5d374fca0c015fd6208fc27e (patch) | |
| tree | 997db1276dc89c44361a56d80a66fb3722f8f2fe | |
| parent | removed unnecessary sel stuff (diff) | |
| download | dwm-d6e0e6e9879c144f5d374fca0c015fd6208fc27e.tar.gz dwm-d6e0e6e9879c144f5d374fca0c015fd6208fc27e.zip | |
several changes, new stuff
| -rw-r--r-- | bar.c | 24 | ||||
| -rw-r--r-- | client.c | 5 | ||||
| -rw-r--r-- | config.h | 2 | ||||
| -rw-r--r-- | event.c | 1 | ||||
| -rw-r--r-- | util.c | 2 | ||||
| -rw-r--r-- | wm.c | 16 | ||||
| -rw-r--r-- | wm.h | 3 |
7 files changed, 34 insertions, 19 deletions
| @@ -5,22 +5,24 @@ | |||
| 5 | 5 | ||
| 6 | #include "wm.h" | 6 | #include "wm.h" |
| 7 | 7 | ||
| 8 | static const char *status[] = { | ||
| 9 | "sh", "-c", "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" | ||
| 10 | " `acpi | awk '{print $4}' | sed 's/,//'`", 0 \ | ||
| 11 | }; | ||
| 12 | |||
| 13 | void | 8 | void |
| 14 | draw_bar() | 9 | draw_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); |
| @@ -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 | ||
| 40 | void | 44 | void |
| @@ -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; |
| @@ -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 */ |
| @@ -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 | } |
| @@ -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 | } |
| @@ -27,7 +27,7 @@ XRectangle rect, barrect; | |||
| 27 | Bool running = True; | 27 | Bool running = True; |
| 28 | Bool sel_screen; | 28 | Bool sel_screen; |
| 29 | 29 | ||
| 30 | char *bartext, tag[256]; | 30 | char statustext[1024], tag[256]; |
| 31 | int screen; | 31 | int screen; |
| 32 | 32 | ||
| 33 | Brush brush = {0}; | 33 | Brush brush = {0}; |
| @@ -35,9 +35,15 @@ Client *clients = NULL; | |||
| 35 | Client *stack = NULL; | 35 | Client *stack = NULL; |
| 36 | 36 | ||
| 37 | static Bool other_wm_running; | 37 | static Bool other_wm_running; |
| 38 | static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; | 38 | static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; |
| 39 | static int (*x_error_handler) (Display *, XErrorEvent *); | 39 | static int (*x_error_handler) (Display *, XErrorEvent *); |
| 40 | 40 | ||
| 41 | static 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 | |||
| 41 | static void | 47 | static void |
| 42 | usage() | 48 | usage() |
| 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(); |
| @@ -55,7 +55,7 @@ extern Bool running, sel_screen, grid; | |||
| 55 | extern void (*handler[LASTEvent]) (XEvent *); | 55 | extern void (*handler[LASTEvent]) (XEvent *); |
| 56 | 56 | ||
| 57 | extern int screen; | 57 | extern int screen; |
| 58 | extern char *bartext, tag[256]; | 58 | extern char statustext[1024], tag[256]; |
| 59 | 59 | ||
| 60 | extern Brush brush; | 60 | extern Brush brush; |
| 61 | extern Client *clients, *stack; | 61 | extern Client *clients, *stack; |
| @@ -74,6 +74,7 @@ extern void unmanage(Client *c); | |||
| 74 | extern Client *getclient(Window w); | 74 | extern Client *getclient(Window w); |
| 75 | extern void focus(Client *c); | 75 | extern void focus(Client *c); |
| 76 | extern void update_name(Client *c); | 76 | extern void update_name(Client *c); |
| 77 | extern void draw_client(Client *c); | ||
| 77 | 78 | ||
| 78 | /* event.c */ | 79 | /* event.c */ |
| 79 | extern unsigned int flush_events(long even_mask); | 80 | extern unsigned int flush_events(long even_mask); |
