Mercurial > hg > index.fcgi > dwm > dwm-3.6.1-12pba
changeset 3:faa4cb9d7bd6
add TASKBAR and CLICK_TO_FOCUS
author | paulo@localhost |
---|---|
date | Thu, 23 Apr 2009 02:43:13 -0700 |
parents | de6bb7885c97 |
children | a54de16f8277 |
files | config.h draw.c dwm.h event.c layout.c main.c |
diffstat | 6 files changed, 68 insertions(+), 22 deletions(-) [+] |
line diff
1.1 --- a/config.h Tue Mar 24 12:52:45 2009 -0700 1.2 +++ b/config.h Thu Apr 23 02:43:13 2009 -0700 1.3 @@ -12,6 +12,8 @@ 1.4 #define SELBGCOLOR "#222222" 1.5 #define SELFGCOLOR "#00ff00" 1.6 #define TOPBAR True /* False */ 1.7 +#define TASKBAR True /* False */ 1.8 +#define CLICK_TO_FOCUS True /* False */ 1.9 1.10 /* behavior */ 1.11 #define SNAP 10 /* pixel */
2.1 --- a/draw.c Tue Mar 24 12:52:45 2009 -0700 2.2 +++ b/draw.c Thu Apr 23 02:43:13 2009 -0700 2.3 @@ -80,25 +80,31 @@ 2.4 drawtext(stext, dc.norm); 2.5 if((dc.w = dc.x - x) > bh) { 2.6 dc.x = x; 2.7 + drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm); 2.8 + } 2.9 + XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); 2.10 + 2.11 + if (TASKBAR) { 2.12 + dc.x = dc.y = 0; 2.13 + dc.w = sw; 2.14 for(j=0, c = clients; c; c = c->next) { 2.15 if(isvisible(c)) 2.16 j++; 2.17 } 2.18 if(j && j < MAX_TASKS) 2.19 dc.w /= j; 2.20 - else { 2.21 - drawtext(sel ? sel->name : NULL, sel ? dc.sel : dc.norm); 2.22 - j = 0; 2.23 - } 2.24 - for(c = clients; j && c; c = c->next) { 2.25 + else 2.26 + drawtext("", dc.norm); 2.27 + for(c = clients; j && c && dc.x < sw; c = c->next) { 2.28 if(isvisible(c)) { 2.29 drawtext(c->name, (c == sel) ? dc.sel : dc.norm); 2.30 dc.x += dc.w; 2.31 j--; 2.32 } 2.33 } 2.34 + XCopyArea(dpy, dc.drawable, tbarwin, dc.gc, 0, 0, sw, bh, 0, 0); 2.35 } 2.36 - XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); 2.37 + 2.38 XSync(dpy, False); 2.39 } 2.40
3.1 --- a/dwm.h Tue Mar 24 12:52:45 2009 -0700 3.2 +++ b/dwm.h Thu Apr 23 02:43:13 2009 -0700 3.3 @@ -100,7 +100,7 @@ 3.4 extern DC dc; /* global draw context */ 3.5 extern Display *dpy; 3.6 extern Layout *lt; 3.7 -extern Window root, barwin; 3.8 +extern Window root, barwin, tbarwin; 3.9 3.10 /* client.c */ 3.11 extern void configure(Client *c); /* send synthetic configure event */
4.1 --- a/event.c Tue Mar 24 12:52:45 2009 -0700 4.2 +++ b/event.c Thu Apr 23 02:43:13 2009 -0700 4.3 @@ -158,13 +158,38 @@ 4.4 } 4.5 if(ev->x > x + blw) 4.6 switch(ev->button) { 4.7 - case Button1: zoom(NULL); break; 4.8 - case Button2: toggleversatile(NULL); break; 4.9 - case Button3: killclient(NULL); break; 4.10 - case Button4: focusprev(NULL); break; 4.11 - case Button5: focusnext(NULL); break; 4.12 + case Button1: zoom(NULL); break; 4.13 + case Button2: toggleversatile(NULL); break; 4.14 + case Button3: killclient(NULL); break; 4.15 + case Button4: pushup(NULL); break; 4.16 + case Button5: pushdown(NULL); break; 4.17 + } 4.18 + } 4.19 + else if(tbarwin == ev->window) { 4.20 + int i, w; 4.21 + switch(ev->button) { 4.22 + case Button4: focusprev(NULL); return; break; 4.23 + case Button5: focusnext(NULL); return; break; 4.24 } 4.25 - } 4.26 + for(i=0, c = clients; c; c = c->next) { 4.27 + if(isvisible(c)) 4.28 + i++; 4.29 + } 4.30 + if(!i && i >= MAX_TASKS) 4.31 + return; 4.32 + else 4.33 + w = sw/i; 4.34 + for(i=1, c = clients; c && i*w<=sw; c = c->next, i++) { 4.35 + for(; c && !isvisible(c); c = c->next); 4.36 + if(i*w > ev->x) { 4.37 + switch(ev->button) { 4.38 + case Button1: focus(c); restack(); break; 4.39 + case Button3: focus(c); zoom(NULL); break; 4.40 + } 4.41 + break; 4.42 + } 4.43 + } 4.44 + } 4.45 else if((c = getclient(ev->window))) { 4.46 focus(c); 4.47 if(CLEANMASK(ev->state) != MODKEY) 4.48 @@ -242,7 +267,7 @@ 4.49 4.50 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) 4.51 return; 4.52 - if((c = getclient(ev->window)) && isvisible(c)) 4.53 + if(!CLICK_TO_FOCUS && (c = getclient(ev->window)) && isvisible(c)) 4.54 focus(c); 4.55 else if(ev->window == root) { 4.56 selscreen = True; 4.57 @@ -256,7 +281,7 @@ 4.58 XExposeEvent *ev = &e->xexpose; 4.59 4.60 if(ev->count == 0) { 4.61 - if(barwin == ev->window) 4.62 + if(barwin == ev->window || tbarwin == ev->window) 4.63 drawstatus(); 4.64 } 4.65 }
5.1 --- a/layout.c Tue Mar 24 12:52:45 2009 -0700 5.2 +++ b/layout.c Thu Apr 23 02:43:13 2009 -0700 5.3 @@ -233,8 +233,8 @@ 5.4 break; 5.5 cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows; 5.6 5.7 - th = (sh - dc.h) / (rows ? rows : 1); 5.8 - tw = sw / (cols ? cols : 1); 5.9 + th = wah / (rows ? rows : 1); 5.10 + tw = waw / (cols ? cols : 1); 5.11 nw = tw - 2 * BORDERPX; 5.12 nh = th - 2 * BORDERPX; 5.13 5.14 @@ -249,8 +249,8 @@ 5.15 nx = (i / rows) * tw; 5.16 ny = (i % rows) * th + (TOPBAR ? dc.h : 0); 5.17 /* adjust height and width of last row's and last column's windows */ 5.18 - ah = ((i + 1) % rows == 0) ? sh - th * rows - dc.h : 0; 5.19 - aw = (i >= rows * (cols - 1)) ? sw - tw * cols : 0; 5.20 + ah = ((i + 1) % rows == 0) ? wah - th * rows : 0; 5.21 + aw = (i >= rows * (cols - 1)) ? waw - tw * cols : 0; 5.22 resize(c, nx, ny, nw + aw, nh + ah, False); 5.23 i++; 5.24 }
6.1 --- a/main.c Tue Mar 24 12:52:45 2009 -0700 6.2 +++ b/main.c Thu Apr 23 02:43:13 2009 -0700 6.3 @@ -29,7 +29,7 @@ 6.4 Cursor cursor[CurLast]; 6.5 Display *dpy; 6.6 DC dc = {0}; 6.7 -Window root, barwin; 6.8 +Window root, barwin, tbarwin; 6.9 6.10 /* static */ 6.11 6.12 @@ -53,6 +53,8 @@ 6.13 XFreePixmap(dpy, dc.drawable); 6.14 XFreeGC(dpy, dc.gc); 6.15 XDestroyWindow(dpy, barwin); 6.16 + if (TASKBAR) 6.17 + XDestroyWindow(dpy, tbarwin); 6.18 XFreeCursor(dpy, cursor[CurNormal]); 6.19 XFreeCursor(dpy, cursor[CurResize]); 6.20 XFreeCursor(dpy, cursor[CurMove]); 6.21 @@ -196,10 +198,21 @@ 6.22 XDefineCursor(dpy, barwin, cursor[CurNormal]); 6.23 XMapRaised(dpy, barwin); 6.24 strcpy(stext, "dwm-"VERSION); 6.25 + /* taskbar */ 6.26 + if (TASKBAR) { 6.27 + wa.override_redirect = 1; 6.28 + wa.background_pixmap = ParentRelative; 6.29 + wa.event_mask = ButtonPressMask | ExposureMask; 6.30 + tbarwin = XCreateWindow(dpy, root, sx, sy + (TOPBAR ? sh - bh : 0 ), sw, bh, 0, 6.31 + DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), 6.32 + CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 6.33 + XDefineCursor(dpy, tbarwin, cursor[CurNormal]); 6.34 + XMapRaised(dpy, tbarwin); 6.35 + } 6.36 /* windowarea */ 6.37 wax = sx; 6.38 - way = sy + (TOPBAR ? bh : 0); 6.39 - wah = sh - bh; 6.40 + way = sy + (TASKBAR ? bh : (TOPBAR ? bh : 0)); 6.41 + wah = sh - bh - (TASKBAR ? bh : 0); 6.42 waw = sw; 6.43 /* pixmap for everything */ 6.44 dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));