[dwm] a locked window for stalonetray - a different approach

From: Marcin Cieslak <saper_AT_system.pl>
Date: Fri, 05 Dec 2008 07:12:24 +0100

Jeremy Jay wrote:
> I do a lot of roaming, and long story short, nm-applet is nearly a
> requirement for me. No biggie, I just run it in stalonetray and set
> it to all tags, shoved up in the corner, only I've ran into two
> little issues:
>
> 1) sticky windows put an indicator on every tag in the bar. I know
> it's on every tag, I put it there, tell me something I don't know.
> The patch hides any window which has tags=~0 from the indicators.
> ( this is simply the 2 lines in drawbar() )
>
> 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.
>
> To do this, I had to add a way to designate a window as nofocus, so
> Rule.isfloating is now a bitmask Rule.flags, with enums for the 3
> settings right now: Normal, Floating, NoFocus.
>
> So my config.h, for example, has this Rule:
> { "stalonetray", NULL, NULL, ~0, Floating|NoFocus },

I've had a similar problem - I switch tags with keyboard very often and
I don't want stalonetray to be moved away from the view.

I add another flag for the window, "islocked":

     { "stalonetray", NULL, NULL, 0x1ff, True, True },

The new flag means: "do not allow to change tags, and do not display tag
indicator".

Probably this behaviour could/should be combined with your "nofocus"
feature, i.e. locked windows should never get focus *at first*.

What do you think?

--Marcin

--- dwm.c.orig 2008-09-09 21:46:17.000000000 +0200
+++ dwm.c 2008-12-05 06:53:32.883218767 +0100
@@ -88,7 +88,7 @@
         int basew, baseh, incw, inch, maxw, maxh, minw, minh;
         int bw, oldbw;
         unsigned int tags;
- Bool isfixed, isfloating, isurgent;
+ Bool isfixed, isfloating, isurgent, islocked;
         Client *next;
         Client *snext;
         Window win;
@@ -127,6 +127,7 @@
         const char *title;
         unsigned int tags;
         Bool isfloating;
+ Bool islocked;
 } Rule;
 
 /* function declarations */
@@ -259,6 +260,7 @@
                         && (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) {
                                 c->isfloating = r->isfloating;
                                 c->tags |= r->tags & TAGMASK;
+ c->islocked = r->islocked;
                         }
                 }
                 if(ch.res_class)
@@ -497,9 +499,11 @@
         Client *c;
 
         for(c = clients; c; c = c->next) {
- occ |= c->tags;
- if(c->isurgent)
- urg |= c->tags;
+ if (!c->islocked) {
+ occ |= c->tags;
+ if(c->isurgent)
+ urg |= c->tags;
+ }
         }
 
         dc.x = 0;
@@ -1405,8 +1409,10 @@
 void
 tag(const Arg *arg) {
         if(sel && arg->ui & TAGMASK) {
- sel->tags = arg->ui & TAGMASK;
- arrange();
+ if (!sel->islocked) {
+ sel->tags = arg->ui & TAGMASK;
+ arrange();
+ }
         }
 }
 
@@ -1467,6 +1473,9 @@
 togglefloating(const Arg *arg) {
         if(!sel)
                 return;
+ if (sel->islocked)
+ return;
+
         sel->isfloating = !sel->isfloating || sel->isfixed;
         if(sel->isfloating)
                 resize(sel, sel->x, sel->y, sel->w, sel->h, True);
@@ -1479,6 +1488,8 @@
 
         if (!sel)
                 return;
+ if (sel->islocked)
+ return;
         
         mask = sel->tags ^ (arg->ui & TAGMASK);
         if(sel && mask) {
Received on Fri Dec 05 2008 - 06:12:24 UTC

This archive was generated by hypermail 2.2.0 : Fri Dec 05 2008 - 06:24:03 UTC