Re: [dwm] patch to hide sticky indicators, and add nofocus windows

2008-11-25 Thread Jeremy Jay

Small bug-fix - cycling through visible windows was broken (in focusstack())...

This is the cumulative patch, but the only differences from the last one
are the few lines in focusstack()

Jeremy
diff -r f6c3491c41f1 config.def.h
--- a/config.def.h  Sun Nov 16 13:22:24 2008 +
+++ b/config.def.h  Tue Nov 25 13:32:05 2008 -0500
@@ -21,9 +21,9 @@
 static unsigned int tagset[] = {1, 1}; /* after start, first tag is selected */
 
 static Rule rules[] = {
-   /* class  instancetitle   tags mask isfloating */
-   { Gimp, NULL,   NULL,   0,True },
-   { Firefox,  NULL,   NULL,   1  8,   True },
+   /* class  instancetitle   tags mask flags */
+   { Gimp, NULL,   NULL,   0,Floating },
+   { Firefox,  NULL,   NULL,   1  8,   Floating },
 };
 
 /* layout(s) */
diff -r f6c3491c41f1 dwm.c
--- a/dwm.c Sun Nov 16 13:22:24 2008 +
+++ b/dwm.c Tue Nov 25 13:32:05 2008 -0500
@@ -65,6 +65,7 @@
 enum { WMProtocols, WMDelete, WMState, WMLast };/* default atoms */
 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
+enum { Normal, Floating, NoFocus=2 };   /* Client flags for 
Rules */
 
 typedef union {
int i;
@@ -89,7 +90,7 @@
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
-   Bool isfixed, isfloating, isurgent;
+   Bool isfixed, isfloating, isurgent, nofocus;
Client *next;
Client *snext;
Window win;
@@ -127,7 +128,7 @@
const char *instance;
const char *title;
unsigned int tags;
-   Bool isfloating;
+   unsigned int flags;
 } Rule;
 
 /* function declarations */
@@ -258,7 +259,8 @@
if((!r-title || strstr(c-name, r-title))
 (!r-class || (ch.res_class  strstr(ch.res_class, 
r-class)))
 (!r-instance || (ch.res_name  strstr(ch.res_name, 
r-instance {
-   c-isfloating = r-isfloating;
+   c-isfloating = (r-flagsFloating)!=0;
+   c-nofocus = (r-flagsNoFocus)!=0;
c-tags |= r-tags  TAGMASK;
}
}
@@ -498,7 +500,8 @@
Client *c;
 
for(c = clients; c; c = c-next) {
-   occ |= c-tags;
+   if(c-tags!=TAGMASK)
+   occ |= c-tags;
if(c-isurgent)
urg |= c-tags;
}
@@ -508,7 +511,7 @@
dc.w = TEXTW(tags[i]);
col = tagset[seltags]  1  i ? dc.sel : dc.norm;
drawtext(tags[i], col, urg  1  i);
-   drawsquare(sel  sel-tags  1  i, occ  1  i, urg  1  
i, col);
+   drawsquare(sel  tagset[seltags]  sel-tags  1  i, occ  1 
 i, urg  1  i, col);
dc.x += dc.w;
}
if(blw  0) {
@@ -610,6 +613,7 @@
 
 void
 focus(Client *c) {
+   Client *inc=c;
if(!c || !ISVISIBLE(c))
for(c = stack; c  !ISVISIBLE(c); c = c-snext);
if(sel  sel != c) {
@@ -619,6 +623,9 @@
if(c) {
detachstack(c);
attachstack(c);
+   }
+   while( !inc  c  c-nofocus ) c=c-next;
+   if(c) {
grabbuttons(c, True);
XSetWindowBorder(dpy, c-win, dc.sel[ColBorder]);
XSetInputFocus(dpy, c-win, RevertToPointerRoot, CurrentTime);
@@ -644,17 +651,17 @@
if(!sel)
return;
if (arg-i  0) {
-   for(c = sel-next; c  !ISVISIBLE(c); c = c-next);
+   for(c = sel-next; c  (!ISVISIBLE(c) || c-nofocus); c = 
c-next);
if(!c)
-   for(c = clients; c  !ISVISIBLE(c); c = c-next);
+   for(c = clients; c  (!ISVISIBLE(c) || c-nofocus); c 
= c-next);
}
else {
for(i = clients; i != sel; i = i-next)
-   if(ISVISIBLE(i))
+   if(ISVISIBLE(i)  !i-nofocus)
c = i;
if(!c)
for(; i; i = i-next)
-   if(ISVISIBLE(i))
+   if(ISVISIBLE(i)  !i-nofocus)
c = i;
}
if(c) {


Re: [dwm] patch to hide sticky indicators, and add nofocus windows

2008-11-25 Thread yy
You could do something very similar just caling unmanage. The problem
is you can't call functions from the rules definition (though you
could use a keybinding to unmanage windows).

It could be interesting to modify applyrules and the Rule definition
in order to call functions, like buttons and keys:

typedef struct {
const char *class;
const char *instance;
const char *title;
void (*func)(const Arg *);
const Arg arg;
} Rule;

Of course, you would also have to tweak manage in order to make it work.

I'm not sure it would be a very good idea, but it probably is not
difficult to try. As a side effect, somebody could control dwm
creating windows with well chosen names (and probably somebody would
write a program to do it), I would find such a hack very unelegant...

-- 


- yiyus || JGL .



Re: [dwm] patch to hide sticky indicators, and add nofocus windows

2008-11-21 Thread Thayer Williams
On Fri, Nov 21, 2008 at 10:38 AM, Jeremy Jay [EMAIL PROTECTED] wrote:
 2) since it's on every tag, every time i switch tags, it is the first
   thing focused.  I dont need to type into a system tray, so the
   patch also adds a flag to designate a window as nofocus which
   tells dwm to skip it when trying to find a window to focus.

Awesome, I use trayer and would like a nofocus feature as well.  I'll
try this out when I get a chance.

Thanks!