Hello. I made this patch for dwm-5.6.1 (but will work on other versions). I know that it is very ugly beucase i added pthread, but works for ma. Please report any bugs.
Regards, Slawek Gonet
Only in dwm-5.6.1: blinking_urgent.patch Only in dwm-5.6.1: blinking_urgent.patch~ diff -up dwm-5.6.1/dwm.c dwm-5.6.1rc/dwm.c --- dwm-5.6.1/dwm.c 2009-07-26 15:01:50.000000000 +0200 +++ dwm-5.6.1rc/dwm.c 2009-08-22 22:44:53.796226140 +0200 @@ -36,11 +36,13 @@ #include <X11/Xlib.h> #include <X11/Xproto.h> #include <X11/Xutil.h> +#include <pthread.h> #ifdef XINERAMA #include <X11/extensions/Xinerama.h> #endif /* XINERAMA */ /* macros */ +#define NUM_THREADS 1 #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) @@ -266,6 +268,8 @@ static Display *dpy; static DC dc; static Monitor *mons = NULL, *selmon = NULL; static Window root; +int blinkurgent = True; +int redraw_needed = False; /* configuration, allows nested code to access above variables */ #include "config.h" @@ -496,10 +500,28 @@ cleanupmons(void) { } void +*blinktoggle(void *threadid) { + int temp = 1; + long tid; + tid = (long)threadid; + unsigned int sec; + sec = 1; + while(temp == 1) { + blinkurgent = !blinkurgent; + if(redraw_needed) drawbars(); + sleep(sec); + } + pthread_exit(NULL); +} + + +void clearurgent(Client *c) { XWMHints *wmh; c->isurgent = False; + blinkurgent = False; + redraw_needed = False; if(!(wmh = XGetWMHints(dpy, c->win))) return; wmh->flags &= ~XUrgencyHint; @@ -657,8 +679,8 @@ drawbar(Monitor *m) { if(ISVISIBLE(c)) n++; occ |= c->tags; - if(c->isurgent) - urg |= c->tags; + if(c->isurgent && blinkurgent) + urg |= c->tags; } dc.x = 0; for(i = 0; i < LENGTH(tags); i++) { @@ -1847,6 +1869,12 @@ updatewmhints(Client *c) { } else c->isurgent = (wmh->flags & XUrgencyHint) ? True : False; + if(c->isurgent) { + redraw_needed = True; + } + else { + redraw_needed = False; + } XFree(wmh); } } @@ -1941,7 +1969,8 @@ zoom(const Arg *arg) { int main(int argc, char *argv[]) { - if(argc == 2 && !strcmp("-v", argv[1])) + XInitThreads(); + if(argc == 2 && !strcmp("-v", argv[1])) die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n"); else if(argc != 1) die("usage: dwm [-v]\n"); @@ -1949,11 +1978,24 @@ main(int argc, char *argv[]) { fputs("warning: no locale support\n", stderr); if(!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display\n"); + + pthread_t threads[NUM_THREADS]; + int rc; + long t; + for(t=0; t<NUM_THREADS; t++){ + printf("In main: creating thread %ld\n", t); + rc = pthread_create(&threads[0], NULL, blinktoggle, (void *)t); + if (rc){ + printf("ERROR; return code from pthread_create() is %d\n", rc); + exit(-1); + } + } checkotherwm(); setup(); scan(); run(); cleanup(); XCloseDisplay(dpy); + pthread_exit(NULL); return 0; } diff -up dwm-5.6.1/Makefile dwm-5.6.1rc/Makefile --- dwm-5.6.1/Makefile 2009-07-26 15:01:50.000000000 +0200 +++ dwm-5.6.1rc/Makefile 2009-08-22 22:42:36.038242547 +0200 @@ -5,6 +5,7 @@ include config.mk SRC = dwm.c OBJ = ${SRC:.c=.o} +LDFLAGS += "-lpthread" all: options dwm
pgpPpO9qa6rz3.pgp
Description: PGP signature