[dwm] [PATCH] Grid mode layout

2007-07-15 Thread Alexandru E. Ungur
Hi all,

Attached is the grid mode patch for dwm 4.3
As always :-) many thanks to Jukka Salmi for his valuable and
much appreciated suggestions.

Cheers,
Alex
diff -Naur --exclude='.hg*' dwm-tip/config.default.h 
dwm-gridmode/config.default.h
--- dwm-tip/config.default.h2007-07-15 11:52:46.0 +0300
+++ dwm-gridmode/config.default.h   2007-07-15 12:05:26.0 +0300
@@ -30,6 +30,7 @@
/* symbol   function */ \
{ "[]=",tile }, /* first entry is default */ \
{ "><>",floating }, \
+   { "+++",grid }, \
 };
 #define MASTERWIDTH600 /* master width per thousand */
 #define NMASTER1   /* clients in master 
area */
diff -Naur --exclude='.hg*' dwm-tip/layout.c dwm-gridmode/layout.c
--- dwm-tip/layout.c2007-07-15 11:52:46.0 +0300
+++ dwm-gridmode/layout.c   2007-07-15 12:37:28.0 +0300
@@ -12,6 +12,44 @@
 static unsigned int nmaster = NMASTER;
 
 static void
+grid(void) {
+   unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   /* grid dimensions */
+   for(rows = 0; rows <= n/2; rows++)
+   if(rows*rows >= n)
+   break;
+   cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+   /* window geoms (cell height/width) */
+   ch = wah / (rows ? rows : 1);
+   cw = waw / (cols ? cols : 1);
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   unban(c);
+   if(c->isfloating)
+   continue;
+   c->ismax = False;
+   cx = (i / rows) * cw;
+   cy = (i % rows) * ch + (bpos == BarTop ? bh : 0); // 
bh? adjust
+   /* adjust height/width of last row/column's windows */ 
+   ah = ((i + 1) % rows == 0) ? wah - ch * rows : 0;
+   aw = (i >= rows * (cols - 1)) ? waw - cw * cols : 0;
+   resize(c, cx, cy, cw - 2 * c->border + aw, ch - 2 * 
c->border + ah, False);
+   i++;
+   }
+   else
+ban(c);
+   focus(NULL);
+   restack();
+}
+
+static void
 tile(void) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
Client *c;


Re: [dwm] dwm-4.3 birthday release

2007-07-15 Thread Alexandru E. Ungur
>>> sender: "Anselm R. Garbe" date: "Sat, Jul 14, 2007 at 09:16:46PM +0200" 
>>> << Hi there,
> 
> after several weeks of silence here a new release with several
> bugfixes:
> 
>   http://www.suckless.org/download/dwm-4.3.tar.gz
> 
> Actually one year ago I released and announced dwm-0.1 ;) Much
> progress since then!
> 
> Happy birthday dwm!
Hehe, it's been that long? :-)
Happy bday dwm, it's really nice both to be able to use and to be
able to read the source of a software that sucks less ;-)
Thank you.

Cheers,
Alex



Re: Re: [dwm] st: a few questions from a 9term user

2007-03-17 Thread Alexandru E. Ungur
>>> sender: "Stalwart" date: "Sat, Mar 17, 2007 at 01:10:08AM +0200" << <1 sec on all computers i tried it. Check your hardware, maybe you
> have problems with APIC (usual on new laptops)
I'll second that. Urxvt is bloody fast here too:

~>> time urxvt -e exit

real0m0.043s
user0m0.009s
sys 0m0.010s
~>> time urxvt -e exit

real0m0.042s
user0m0.011s
sys 0m0.007s
~>> time urxvt -e exit

real0m0.045s
user0m0.007s
sys 0m0.012s
~>> time urxvt -e exit

real0m0.043s
user0m0.007s
sys 0m0.008s
~>> time urxvt -e exit

real0m0.043s
user0m0.009s
sys 0m0.008s

and so on, and this is without urxvtd. Of course I compiled a really slim 
version ;-)
with just the bare minimum I need:

~>> urxvt -h
rxvt-unicode (urxvt) v8.2 - released: 2007-02-12
options: 
styles,encodings=eu+vn,selectionscrolling,wheel,smart-resize,scrollbars=NONE


Cheers,
Alex



Re: [dwm] grid layout patch for dwm-3.8

2007-03-06 Thread Alexandru E. Ungur
>>> sender: "Jeroen Schot" date: "Mon, Mar 05, 2007 at 06:04:01PM +0100" << Thanks. Could you also put this patch on the diri?
You're welcome :-)
I'd be glad to, but am not sure how, I don't know the password.

Cheers,
Alex



[dwm] grid layout patch for dwm-3.8

2007-03-05 Thread Alexandru E. Ungur
Hi all,

Attached is the grid mode patch for dwm-3.8
There's only been a minor improvement and that is getting rid of
the gaps between windows and screen border (at the bottom and right
side).

Cheers,
Alex
diff -Naur --exclude='.hg*' dwm-tip/config.default.h dwm-grid/config.default.h
--- dwm-tip/config.default.h2007-02-25 23:26:01.0 +0200
+++ dwm-grid/config.default.h   2007-03-05 17:16:29.0 +0200
@@ -32,6 +32,7 @@
/* symbol   function */ \
{ "[]=",tile }, /* first entry is default */ \
{ "><>",floating }, \
+   { "+++",grid }, \
 };
 #define MASTERWIDTH600 /* master width per thousand */
 #define NMASTER1   /* clients in master 
area */
diff -Naur --exclude='.hg*' dwm-tip/layout.c dwm-grid/layout.c
--- dwm-tip/layout.c2007-02-26 14:36:31.0 +0200
+++ dwm-grid/layout.c   2007-03-05 17:22:24.0 +0200
@@ -14,6 +14,52 @@
 static unsigned int nmaster = NMASTER;
 
 static void
+grid(void) {
+   unsigned int i, n, nx, ny, nw, nh, aw, ah, tw, th, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   for(rows = 0; rows <= n/2; rows++)
+   if(rows*rows >= n)
+   break;
+   cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+   th = (sh - dc.h) / (rows ? rows : 1);
+   tw = sw / (cols ? cols : 1);
+   nw = tw - 2 * BORDERPX;
+   nh = th - 2 * BORDERPX;
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   if(c->isbanned)
+   XMoveWindow(dpy, c->win, c->x, c->y);
+   c->isbanned = False;
+   if(c->isfloating)
+   continue;
+   c->ismax = False;
+   nx = (i / rows) * tw;
+   ny = (i % rows) * th + (TOPBAR ? dc.h : 0);
+   /* adjust height and width of last row's and last 
column's windows */ 
+   ah = ((i + 1) % rows == 0) ? sh - th * rows - dc.h : 0;
+   aw = (i >= rows * (cols - 1)) ? sw - tw * cols : 0;
+   resize(c, nx, ny, nw + aw, nh + ah, False);
+   i++;
+   }
+   else {
+   c->isbanned = True;
+   XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+   }
+
+   if(!sel || !isvisible(sel)) {
+   for(c = stack; c && !isvisible(c); c = c->snext);
+   focus(c);
+   }
+   restack();
+}
+
+static void
 tile(void) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
Client *c;


[dwm] grid layout patch for dwm-3.7

2007-02-26 Thread Alexandru E. Ungur
Hi all,

Here's the grid layout patch for dwm-3.7
Many thanks (again) to Jukka Salmi for his improvements suggestions :-)

Cheers,
Alex
diff -Naur --exclude='.hg*' dwm-tip/config.default.h dwm-grid/config.default.h
--- dwm-tip/config.default.h2007-02-25 23:26:01.0 +0200
+++ dwm-grid/config.default.h   2007-02-26 07:56:10.0 +0200
@@ -32,6 +32,7 @@
/* symbol   function */ \
{ "[]=",tile }, /* first entry is default */ \
{ "><>",floating }, \
+   { "+++",grid }, \
 };
 #define MASTERWIDTH600 /* master width per thousand */
 #define NMASTER1   /* clients in master 
area */
diff -Naur --exclude='.hg*' dwm-tip/layout.c dwm-grid/layout.c
--- dwm-tip/layout.c2007-02-25 23:26:02.0 +0200
+++ dwm-grid/layout.c   2007-02-26 07:58:57.0 +0200
@@ -14,6 +14,49 @@
 static unsigned int nmaster = NMASTER;
 
 static void
+grid(void) {
+   unsigned int i, n, nx, ny, nw, nh, tw, th, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   for(rows = 0; rows <= n/2; rows++)
+   if(rows*rows >= n)
+   break;
+   cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+   th = (sh - dc.h) / (rows ? rows : 1);
+   tw = sw / (cols ? cols : 1);
+   nw = tw - 2 * BORDERPX;
+   nh = th - 2 * BORDERPX;
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   if(c->isbanned)
+   XMoveWindow(dpy, c->win, c->x, c->y);
+   c->isbanned = False;
+   if(c->isfloating)
+   continue;
+   c->ismax = False;
+   nx = (i / rows) * tw;
+   ny = (i % rows) * th + (TOPBAR ? dc.h : 0);
+   resize(c, nx, ny, nw, nh, False);
+   i++;
+   }
+   else {
+   c->isbanned = True;
+   XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+   }
+
+   if(!sel || !isvisible(sel)) {
+   for(c = stack; c && !isvisible(c); c = c->snext);
+   focus(c);
+   }
+   restack();
+}
+
+static void
 tile(void) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
Client *c;


Re: [dwm] speaking of terminology...

2007-02-22 Thread Alexandru E. Ungur
>>> sender: "Kurt H Maier" date: "Thu, Feb 22, 2007 at 10:03:27AM -0600" << On 2/22/07, Anselm R. Garbe <[EMAIL PROTECTED]> wrote:
> >...I ask native English speakers if we should restore the term
> >'versatile' back to 'floating'
> 
> "Versatile" sounds a little grandiose.
+1 for that one :-) First time I saw the change from floating to versatile 
I though 'whoaw, can these windows really fly now or what?!' ;-) It really 
sounds like they're the best thing there is on dwm, which is quite 
misleading.
Then again, I'm no native English speaker...

BTW, dwm tip works just fine for me as well.

Cheers,
Alex



Re: [dwm] grid patch for dwm-3.6 (tip 806)

2007-02-21 Thread Alexandru E. Ungur
>>> sender: "Anselm R. Garbe" date: "Wed, Feb 21, 2007 at 04:13:01PM +0100" 
>>> << Hi Alex,
> 
> On Wed, Feb 21, 2007 at 05:02:03PM +0200, Alexandru E. Ungur wrote:
> > Attached is the updated grid patch.
> 
> Well see attached a patch which does not touch dwm.h and
> Makefile. You will get into trouble anyways, even if you put
> your algorithm into a separate file (because applying different
> patches will fail in dwm.h and Makefile then, instead of
> layout.c...)
True, besides it does looks cleaner with only patching layout.c ;)
On right, forget my ideea.

Cheers,
Alex



[dwm] grid patch for dwm-3.6 (tip 806)

2007-02-21 Thread Alexandru E. Ungur
Hi all,

Attached is the updated grid patch.

Cheers,
Alex
diff -Naur --exclude='.hg*' dwm-tip/config.default.h dwm-grid/config.default.h
--- dwm-tip/config.default.h2007-02-21 16:43:04.0 +0200
+++ dwm-grid/config.default.h   2007-02-21 16:45:49.0 +0200
@@ -33,6 +33,7 @@
/* symbol   function */ \
{ "[]=",tile }, /* first entry is default */ \
{ "><>",versatile }, \
+   { "+++",grid }, \
 };
 #define MASTER 600 /* per thousand */
 #define NMASTER1   /* clients in master 
area */
diff -Naur --exclude='.hg*' dwm-tip/dwm.h dwm-grid/dwm.h
--- dwm-tip/dwm.h   2007-02-21 16:43:04.0 +0200
+++ dwm-grid/dwm.h  2007-02-21 16:46:32.0 +0200
@@ -153,4 +153,6 @@
 extern void *emallocz(unsigned int size);  /* allocates zero-initialized 
memory, exits on error */
 extern void eprint(const char *errstr, ...);   /* prints errstr and exits with 
1 */
 extern void spawn(Arg *arg);   /* forks a new subprocess with 
arg's cmd */
+/* grid mode */
+extern void grid(void);/* grid mode layout */
 
diff -Naur --exclude='.hg*' dwm-tip/layout_grid.c dwm-grid/layout_grid.c
--- dwm-tip/layout_grid.c   1970-01-01 02:00:00.0 +0200
+++ dwm-grid/layout_grid.c  2007-02-21 16:46:48.0 +0200
@@ -0,0 +1,47 @@
+#include "dwm.h"
+
+void
+grid(void) {
+   unsigned int i, n, nx, ny, nw, nh, tw, th, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   for(rows = 0; rows <= n/2; rows++)
+   if(rows*rows >= n)
+   break;
+cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+   if (n > 0) {
+   th = (sh - dc.h) / rows;
+   tw = sw / cols;
+   }
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   if(c->isbanned)
+   XMoveWindow(dpy, c->win, c->x, c->y);
+   c->isbanned = False;
+   if(c->isversatile)
+   continue;
+   c->ismax = False;
+   nx = (i / rows) * tw;
+   ny = (i % rows) * th + (TOPBAR ? dc.h : 0);
+   nw = tw - 2 * BORDERPX;
+   nh = th - 2 * BORDERPX;
+   resize(c, nx, ny, nw, nh, False);
+   i++;
+   }
+   else {
+   c->isbanned = True;
+   XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+   }
+
+   if(!sel || !isvisible(sel)) {
+   for(c = stack; c && !isvisible(c); c = c->snext);
+   focus(c);
+   }
+   restack();
+}
+
diff -Naur --exclude='.hg*' dwm-tip/Makefile dwm-grid/Makefile
--- dwm-tip/Makefile2007-02-21 16:43:04.0 +0200
+++ dwm-grid/Makefile   2007-02-21 16:44:33.0 +0200
@@ -3,7 +3,7 @@
 
 include config.mk
 
-SRC = client.c draw.c event.c layout.c main.c tag.c util.c
+SRC = client.c draw.c event.c layout.c main.c tag.c util.c layout_grid.c
 OBJ = ${SRC:.c=.o}
 
 all: options dwm


Re: Re: update: Re: [dwm] recent changes to dwm (since dwm-3.5)

2007-02-21 Thread Alexandru E. Ungur
>>> sender: "Anselm R. Garbe" date: "Wed, Feb 21, 2007 at 10:44:14AM +0100" 
>>> << On Wed, Feb 21, 2007 at 11:23:53AM +0200, Alexandru E. Ungur wrote:
> > >>> sender: "Anselm R. Garbe" date: "Tue, Feb 20, 2007 at 03:24:12PM +0100" 
> > >>> << > > > I have a question: if instead of patching the layout.c file for new 
> > > > layouts, each of us who created a layout patch would create a 
> > > > separate file, such as:
> > > > 
> > > > layout_grid.c
> > > > layout_bstack.c
> > > 
> > > Do what you like, but don't forget that those files must be
> > > included in Makefile somehow and the function signatures must be
> > > local in layout.c as well... so I consider this as don't do it
> > > that way ;)
> > Ok then, thanks for the advice :) 
> 
> There is also another reason - the wmii-2 way only supported the
> arrange-function being integrated that way. But in dwm we have
> things like incnmaster() or resizemaster() which manipulate the
> tile()-layout. Hence it would get very messy to handle such
> add-on functions with such a way like we had in wmii-2 - so it
> is much easier and simplier for patch contributors to put
> everything into 1 single superfeature.patch file.
Ah, I see what you mean. Sorry I didn't explain too well what I meant.
The suggestion was actually for the patch creators to change the way
they create patchs (they have to change it anyway at this point :D) so 
that it is easier for the endusers to integrate multiple patches. I 
did not suggest modifying dwm in any way.

What I did for my patch (well, before I asked) was create that extra
layout_grid.c and then patching Makefile (adding one 'word') and dwm.h
(adding one line). All these are done from the patch, no need for
any changes on dwm side.

Now, because the changes to dwm were so small, I can easily integrate 
other patches now ;-) and I figured if other contributors would do the
same (where applicable of course) then it would be easier for all of
us to integrate multiple patches.

I'll release the patch right away, and then it will be clear what I'm
talking about :-)


Cheers,
Alex



Re: update: Re: [dwm] recent changes to dwm (since dwm-3.5)

2007-02-21 Thread Alexandru E. Ungur
>>> sender: "Anselm R. Garbe" date: "Tue, Feb 20, 2007 at 03:24:12PM +0100" 
>>> << > I have a question: if instead of patching the layout.c file for new 
> > layouts, each of us who created a layout patch would create a 
> > separate file, such as:
> > 
> > layout_grid.c
> > layout_bstack.c
> 
> Do what you like, but don't forget that those files must be
> included in Makefile somehow and the function signatures must be
> local in layout.c as well... so I consider this as don't do it
> that way ;)
Ok then, thanks for the advice :) 

Cheers,
Alex



Re: update: Re: [dwm] recent changes to dwm (since dwm-3.5)

2007-02-20 Thread Alexandru E. Ungur
>>> sender: "Anselm R. Garbe" date: "Tue, Feb 20, 2007 at 11:35:17AM +0100" 
>>> << On Mon, Feb 19, 2007 at 09:22:41PM -0500, John S. Yates, Jr. wrote:
> > On Mon, Feb 19, 2007 at 11:56:18AM I wrote:
> > > Scanning the bundles showing up on [hackers] it is clear that
> > > those of us who have any significant investment in dwm patches
> > > are in for rough sledding trying to track this refactoring.
> > To which Anselm replied with a detailed list of his changes
> > explaining that none should be a significant impediment to
> > propagating patches.
> 
> Well I have to describe the last step:
> 
> I split screen.c into layout.c and tag.c again. layout.c
> contains all arrangement-related stuff (*also new algorithms
> like dogrid should go into this file for patches*).
I have a question: if instead of patching the layout.c file for new 
layouts, each of us who created a layout patch would create a 
separate file, such as:

layout_grid.c
layout_bstack.c
etc.

wouldn't that be easier for people wanting to try several layout
patches? This way at least the layout patching part would be a simple 
file copy, free of any merging conflicts.

Cheers,
Alex



Re: [dwm] recent changes to dwm (since dwm-3.5)

2007-02-19 Thread Alexandru E. Ungur
>>> sender: "Anselm R. Garbe" date: "Mon, Feb 19, 2007 at 05:38:24PM +0100" 
>>> << On Mon, Feb 19, 2007 at 11:56:18AM -0500, John S. Yates, Jr. wrote:
> > Scanning the bundles showing up on [hackers] it is clear that
> > those of us who have any significant investment in dwm patches
> > are in for rough sledding trying to track this refactoring.
> > Will there be appreciable new functionality or is this just
> > gilding the lily?  At what point will st get any real
> > attention?
> 
> I don't think that you will need to do nasty things with the
> next dwm release when porting your patches. I did following
> changes basically:
No nasty things needed to port the grid patch. I had a really easy 
time porting it, and the whole thing looks much cleaner now, there 
are less places I needed to touch to get my patch done. 

Thanks! :-)

Cheers,
Alex



Re: Re: [dwm] grid mode patch for dwm-3.5

2007-02-17 Thread Alexandru E. Ungur
>>> sender: "Tener Hades" date: "Fri, Feb 16, 2007 at 03:53:53PM +" << On Fri, Feb 16, 2007 at 03:40:20PM +, Tener Hades wrote:
> > I've added
> > 
> >  if(arrange == gridmode)
> > return;
> 
> yeah.. rather
> 
>   if(arrange == dogrid)
> 
> ..oops.. but i've changed it to
> 
>   if(arrange != dotile)
> 
> as i don't use bottom stack anymore and just thought about dofloat
> changing the master size as well..
Nice, thanks for the suggestion! :-)

Cheers,
Alex



Re: Re: [dwm] bundle section in wiki

2007-02-16 Thread Alexandru E. Ungur
>>> sender: "Julian Romero" date: "Fri, Feb 16, 2007 at 10:03:52AM +0100" << On 2/16/07, John S. Yates, Jr. <[EMAIL PROTECTED]> wrote:
> >
> >
> >What I understand you to be suggesting is if I integrate patches
> >X, Y, and Z that I would post a bundle providing the results of my
> >integration efforts.  Is this correct?  If it existed I would be
> >both a client and a contributor.
> 
> 
> Exactly that. We can provide/consume .hg files like
> bundle-bstatck.grid.whatever-3.5.hg ready to apply to a certain dwm-vanilla
> version.
I think it's a very good ideea and I'd be glad to help with what I can.

Cheers,
Alex



[dwm] grid mode patch for dwm-3.5

2007-02-14 Thread Alexandru E. Ungur
Hi all,

Attached is the grid mode patch updated for for dwm-3.5
The only enhancement is that it honours TOPBAR setting.

Cheers,
Alex
diff -Naur --exclude='.hg*' dwm-tip/config.default.h 
dwm-gridmode/config.default.h
--- dwm-tip/config.default.h2007-02-14 12:55:38.0 +0200
+++ dwm-gridmode/config.default.h   2007-02-14 13:07:01.0 +0200
@@ -9,6 +9,7 @@
 #define DEFMODEdotile  /* dofloat */
 #define FLOATSYMBOL"><>"
 #define TILESYMBOL "[]="
+#define GRIDSYMBOL "[-]"
 
 #define FONT   "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
 #define NORMBORDERCOLOR"#dd"
diff -Naur --exclude='.hg*' dwm-tip/draw.c dwm-gridmode/draw.c
--- dwm-tip/draw.c  2007-02-05 18:31:44.0 +0200
+++ dwm-gridmode/draw.c 2007-02-14 13:07:20.0 +0200
@@ -101,7 +101,7 @@
dc.x += dc.w;
}
dc.w = bmw;
-   drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, 
False);
+   drawtext(arrange == dofloat ? FLOATSYMBOL : (arrange == dogrid ? 
GRIDSYMBOL : TILESYMBOL), dc.norm, False, False);
x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = sw - dc.w;
diff -Naur --exclude='.hg*' dwm-tip/dwm.h dwm-gridmode/dwm.h
--- dwm-tip/dwm.h   2007-02-07 17:34:08.0 +0200
+++ dwm-gridmode/dwm.h  2007-02-14 13:07:32.0 +0200
@@ -142,6 +142,7 @@
 extern void detach(Client *c); /* detaches c from global 
client list */
 extern void dofloat(void); /* arranges all windows 
floating */
 extern void dotile(void);  /* arranges all windows tiled */
+extern void dogrid(void);  /* arranges all windows in a 
grid */
 extern void focusnext(Arg *arg);   /* focuses next visible client, 
arg is ignored  */
 extern void focusprev(Arg *arg);   /* focuses previous visible 
client, arg is ignored */
 extern void incnmaster(Arg *arg);  /* increments nmaster with 
arg's index value */
diff -Naur --exclude='.hg*' dwm-tip/view.c dwm-gridmode/view.c
--- dwm-tip/view.c  2007-02-14 12:55:38.0 +0200
+++ dwm-gridmode/view.c 2007-02-14 13:08:39.0 +0200
@@ -117,6 +117,47 @@
 }
 
 void
+dogrid(void) {
+   unsigned int i, n, tw, th, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   for(rows = 0; rows <= n/2; rows++)
+   if(rows*rows >= n)
+   break;
+cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+   if (n > 0) {
+   th = (sh - dc.h) / rows;
+   tw = sw / cols;
+   }
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   if(c->isfloat) {
+   resize(c, True);
+   continue;
+   }
+   c->ismax = False;
+   c->x = (i / rows) * tw;
+   c->y = (i % rows) * th + (TOPBAR ? dc.h : 0);
+   c->w = tw - 2 * BORDERPX;
+   c->h = th - 2 * BORDERPX;
+   resize(c, False);
+   i++;
+   }
+   else
+   XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+   if(!sel || !isvisible(sel)) {
+   for(c = stack; c && !isvisible(c); c = c->snext);
+   focus(c);
+   }
+   restack();
+}
+
+void
 focusnext(Arg *arg) {
Client *c;

@@ -214,7 +255,8 @@
 
 void
 togglemode(Arg *arg) {
-   arrange = (arrange == dofloat) ? dotile : dofloat;
+   arrange = (arrange == dofloat) ? 
+   dotile : (arrange == dotile) ? dogrid : dofloat;
if(sel)
arrange();
else


Re: [dwm] uriel sez the default config is retarded

2007-02-09 Thread Alexandru E. Ungur
>>> sender: "Anselm R. Garbe" date: "Fri, Feb 09, 2007 at 10:32:35AM +0100" 
>>> << 1. You stick with default config?
> 2. You basically stick with default config, but
>a) use different colors/font
>b) use dmenu
>c) use some different shortcuts
>d) use more rules
> 3. You use totally different shortcuts?
> 4. You use totally different config?
2a, 2b, 2c and 2d, here's the diff against the dwm tip config.default.h:
http://pastie.caboo.se/39096
Nothing out of the ordinary (well, except adding more colors :-) and
patching dwm accordingly). Also, I do change the Modkey-[0-9] to
Modkey-[F1-F9] as I want to keep those shorcuts for changing tabs in FF
and for a couple of other applications where it's useful.

And for the record, I don't find the default config 'retarded'. It's
quite a good default. I'm sure that all people able to build their WM
from sources, are able to modify a default config to suit them ;-)

Cheers,
Alex



Re: Re: [dwm] bar position

2007-02-08 Thread Alexandru E. Ungur
>>> sender: "Stalwart" date: "Thu, Feb 08, 2007 at 12:27:45AM +0200" << I like the idea of statusbar being window caption + pager + infobar. I
> can't imagine it on bottom
+1, that's exactly what I like about the top bar as well.

Cheers,
Alex



Re: Re: [dwm] dwm 3.3 grid mode patch

2007-02-07 Thread Alexandru E. Ungur
Hi all,

Here's the grid patch for dwm 3.4
Thanks again to Jukka Salmi :-) for the bug reports and improvements 
suggestions. 

Cheers,
Alex
diff -Naur --exclude='.hg*' dwm-tip/config.default.h dwm-tip-g2/config.default.h
--- dwm-tip/config.default.h2007-01-31 00:12:46.0 +0200
+++ dwm-tip-g2/config.default.h 2007-02-07 17:36:56.0 +0200
@@ -9,6 +9,7 @@
 #define DEFMODEdotile  /* dofloat */
 #define FLOATSYMBOL"><>"
 #define TILESYMBOL "[]="
+#define GRIDSYMBOL "[-]"
 
 #define FONT   "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
 #define NORMBORDERCOLOR"#dd"
diff -Naur --exclude='.hg*' dwm-tip/draw.c dwm-tip-g2/draw.c
--- dwm-tip/draw.c  2007-02-05 18:31:44.0 +0200
+++ dwm-tip-g2/draw.c   2007-02-07 17:37:28.0 +0200
@@ -101,7 +101,7 @@
dc.x += dc.w;
}
dc.w = bmw;
-   drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, 
False);
+   drawtext(arrange == dofloat ? FLOATSYMBOL : (arrange == dogrid ? 
GRIDSYMBOL : TILESYMBOL), dc.norm, False, False);
x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = sw - dc.w;
diff -Naur --exclude='.hg*' dwm-tip/dwm.h dwm-tip-g2/dwm.h
--- dwm-tip/dwm.h   2007-02-07 17:34:08.0 +0200
+++ dwm-tip-g2/dwm.h2007-02-07 17:38:01.0 +0200
@@ -142,6 +142,7 @@
 extern void detach(Client *c); /* detaches c from global 
client list */
 extern void dofloat(void); /* arranges all windows 
floating */
 extern void dotile(void);  /* arranges all windows tiled */
+extern void dogrid(void);  /* arranges all windows in a 
grid */
 extern void focusnext(Arg *arg);   /* focuses next visible client, 
arg is ignored  */
 extern void focusprev(Arg *arg);   /* focuses previous visible 
client, arg is ignored */
 extern void incnmaster(Arg *arg);  /* increments nmaster with 
arg's index value */
diff -Naur --exclude='.hg*' dwm-tip/view.c dwm-tip-g2/view.c
--- dwm-tip/view.c  2007-02-02 12:49:14.0 +0200
+++ dwm-tip-g2/view.c   2007-02-07 17:39:10.0 +0200
@@ -118,6 +118,47 @@
 }
 
 void
+dogrid(void) {
+   unsigned int i, n, tw, th, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   for(rows = 0; rows <= n/2; rows++)
+   if(rows*rows >= n)
+   break;
+   cols = (rows && (rows - 1) * rows >= n) ? rows - 1 : rows;
+
+   if (n > 0) {
+   th = (sh - dc.h) / rows;
+   tw = sw / cols;
+   }
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   if(c->isfloat) {
+   resize(c, True);
+   continue;
+   }
+   c->ismax = False;
+   c->x = (i / rows) * tw;
+   c->y = (i % rows) * th + dc.h;
+   c->w = tw - 2 * BORDERPX;
+   c->h = th - 2 * BORDERPX;
+   resize(c, False);
+   i++;
+   }
+   else
+   XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+   if(!sel || !isvisible(sel)) {
+   for(c = stack; c && !isvisible(c); c = c->snext);
+   focus(c);
+   }
+   restack();
+}
+
+void
 focusnext(Arg *arg) {
Client *c;

@@ -215,7 +256,8 @@
 
 void
 togglemode(Arg *arg) {
-   arrange = (arrange == dofloat) ? dotile : dofloat;
+   arrange = (arrange == dofloat) ? 
+   dotile : (arrange == dotile) ? dogrid : dofloat;
if(sel)
arrange();
else


Re: [dwm] dwm 3.3 grid mode patch

2007-02-05 Thread Alexandru E. Ungur
Hi all,

Thanks to the very good advices I received from Jukka Salmi a most annoying 
bug has been fixed (about changing views while in grid mode), and also the 
patch is now smaller by 11 SLOC (has only 44 SLOC).

The new patch is attached.

Cheers,
Alex
diff -Naur --exclude='.hg*' dwm-tip/config.default.h 
dwm-tip-gridmode/config.default.h
--- dwm-tip/config.default.h2007-01-31 00:12:46.0 +0200
+++ dwm-tip-gridmode/config.default.h   2007-02-05 10:37:38.0 +0200
@@ -9,6 +9,7 @@
 #define DEFMODEdotile  /* dofloat */
 #define FLOATSYMBOL"><>"
 #define TILESYMBOL "[]="
+#define GRIDSYMBOL "[-]"
 
 #define FONT   "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
 #define NORMBORDERCOLOR"#dd"
diff -Naur --exclude='.hg*' dwm-tip/draw.c dwm-tip-gridmode/draw.c
--- dwm-tip/draw.c  2007-01-31 00:12:46.0 +0200
+++ dwm-tip-gridmode/draw.c 2007-02-05 10:38:14.0 +0200
@@ -111,7 +111,7 @@
dc.x += dc.w;
}
dc.w = bmw;
-   drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, 
False);
+   drawtext(arrange == dofloat ? FLOATSYMBOL : (arrange == dogrid ? 
GRIDSYMBOL : TILESYMBOL), dc.norm, False, False);
x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = sw - dc.w;
diff -Naur --exclude='.hg*' dwm-tip/dwm.h dwm-tip-gridmode/dwm.h
--- dwm-tip/dwm.h   2007-02-02 12:47:36.0 +0200
+++ dwm-tip-gridmode/dwm.h  2007-02-05 10:38:52.0 +0200
@@ -144,6 +144,7 @@
 extern void detach(Client *c); /* detaches c from global 
client list */
 extern void dofloat(void); /* arranges all windows 
floating */
 extern void dotile(void);  /* arranges all windows tiled */
+extern void dogrid(void);  /* arranges all windows in a 
grid */
 extern void focusnext(Arg *arg);   /* focuses next visible client, 
arg is ignored  */
 extern void focusprev(Arg *arg);   /* focuses previous visible 
client, arg is ignored */
 extern void incnmaster(Arg *arg);  /* increments nmaster with 
arg's index value */
diff -Naur --exclude='.hg*' dwm-tip/view.c dwm-tip-gridmode/view.c
--- dwm-tip/view.c  2007-02-02 12:49:14.0 +0200
+++ dwm-tip-gridmode/view.c 2007-02-05 10:41:31.0 +0200
@@ -118,6 +118,47 @@
 }
 
 void
+dogrid(void) {
+   unsigned int i, n, tw, th, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   for(rows = 0; rows <= n/2; rows++)
+   if(rows*rows >= n)
+   break;
+   cols = ((rows - 1) * rows >= n) ? rows - 1 : rows;
+
+   if (n > 0) {
+   th = (sh - dc.h) / rows;
+   tw = sw / cols;
+   }
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   if(c->isfloat) {
+   resize(c, True);
+   continue;
+   }
+   c->ismax = False;
+   c->x = (i / rows) * tw;
+   c->y = (i % rows) * th + dc.h;
+   c->w = tw - 2 * BORDERPX;
+   c->h = th - 2 * BORDERPX;
+   resize(c, False);
+   i++;
+   }
+   else
+   XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+   if(!sel || !isvisible(sel)) {
+   for(c = stack; c && !isvisible(c); c = c->snext);
+   focus(c);
+   }
+   restack();
+}
+
+void
 focusnext(Arg *arg) {
Client *c;

@@ -216,6 +257,8 @@
 void
 togglemode(Arg *arg) {
arrange = (arrange == dofloat) ? dotile : dofloat;
+   arrange = (arrange == dofloat) ? 
+   dotile : (arrange == dotile) ? dogrid : dofloat;
if(sel)
arrange();
else


[dwm] dwm 3.3 grid mode patch

2007-02-02 Thread Alexandru E. Ungur
Hi all,

I wrote a small patch that maybe others can find usefull too.
It adds grid mode to DWM, so that you can easily use tools like
http://sourceforge.net/projects/clusterssh under DWM

This is my first attempt to write any useful C code, since my
daily coding consists mainly of PHP and/or Ruby, before that Perl, 
and in the beginning Pascal. I've always wanted to learn C though,
but never found a good excuse to do so. Not until now, when I
really had an itch to scratch I guess :-) but more important
when I saw how clean, elegant and beautiful C can be... Reading
the DWM source code was inspiring, so thank you Anselm for this
pearl of coding.


Sincerely,
Alex

P.S. any feedback is more than welcome :-)
diff -Naur --exclude='.hg*' dwm-tip/config.default.h 
dwm-tip-custom/config.default.h
--- dwm-tip/config.default.h2007-01-31 00:12:46.0 +0200
+++ dwm-tip-custom/config.default.h 2007-02-02 13:32:26.0 +0200
@@ -9,6 +9,7 @@
 #define DEFMODEdotile  /* dofloat */
 #define FLOATSYMBOL"><>"
 #define TILESYMBOL "[]="
+#define GRIDSYMBOL "[-]"
 
 #define FONT   "-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*"
 #define NORMBORDERCOLOR"#dd"
diff -Naur --exclude='.hg*' dwm-tip/draw.c dwm-tip-custom/draw.c
--- dwm-tip/draw.c  2007-01-31 00:12:46.0 +0200
+++ dwm-tip-custom/draw.c   2007-02-02 13:21:00.0 +0200
@@ -111,7 +111,7 @@
dc.x += dc.w;
}
dc.w = bmw;
-   drawtext(arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, dc.norm, False, 
False);
+drawtext(arrange == dofloat ? FLOATSYMBOL : (arrange == dogrid ? 
GRIDSYMBOL : TILESYMBOL), dc.norm, False, False);
x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = sw - dc.w;
diff -Naur --exclude='.hg*' dwm-tip/dwm.h dwm-tip-custom/dwm.h
--- dwm-tip/dwm.h   2007-02-02 12:47:36.0 +0200
+++ dwm-tip-custom/dwm.h2007-02-02 13:30:19.0 +0200
@@ -139,11 +139,13 @@
 extern void *emallocz(unsigned int size);  /* allocates zero-initialized 
memory, exits on error */
 extern void eprint(const char *errstr, ...);   /* prints errstr and exits with 
1 */
 extern void spawn(Arg *arg);   /* forks a new subprocess with 
to arg's cmd */
+extern unsigned int grid_cols(unsigned int n); /* determine the number of 
columns in grid mode */
 
 /* view.c */
 extern void detach(Client *c); /* detaches c from global 
client list */
 extern void dofloat(void); /* arranges all windows 
floating */
 extern void dotile(void);  /* arranges all windows tiled */
+extern void dogrid(void);  /* arranges all windows in a 
grid */
 extern void focusnext(Arg *arg);   /* focuses next visible client, 
arg is ignored  */
 extern void focusprev(Arg *arg);   /* focuses previous visible 
client, arg is ignored */
 extern void incnmaster(Arg *arg);  /* increments nmaster with 
arg's index value */
diff -Naur --exclude='.hg*' dwm-tip/util.c dwm-tip-custom/util.c
--- dwm-tip/util.c  2007-01-31 00:12:46.0 +0200
+++ dwm-tip-custom/util.c   2007-02-02 13:22:24.0 +0200
@@ -52,3 +52,12 @@
}
wait(0);
 }
+
+unsigned int grid_cols(unsigned int n) {
+unsigned int i;
+for(i = 0; i <= n/2; i++)
+if(i*i >= n)
+break;
+return i;
+}
+
diff -Naur --exclude='.hg*' dwm-tip/view.c dwm-tip-custom/view.c
--- dwm-tip/view.c  2007-02-02 12:49:14.0 +0200
+++ dwm-tip-custom/view.c   2007-02-02 13:25:14.0 +0200
@@ -118,6 +118,48 @@
 }
 
 void
+dogrid(void) {
+   unsigned int i, n, tw, th, cols, rows;
+   Client *c;
+
+   for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+   n++;
+
+   if (n == 0)
+   return;
+
+   cols = grid_cols(n);
+   rows = cols;
+   if (((cols - 1) * rows) >= n)
+   cols--;
+
+   th = (sh - dc.h) / rows;
+   tw = sw / cols;
+
+   for(i = 0, c = clients; c; c = c->next)
+   if(isvisible(c)) {
+   if(c->isfloat) {
+   resize(c, True);
+   continue;
+   }
+   c->ismax = False;
+   c->x = (i / rows) * tw;
+   c->y = (i % rows) * th + dc.h;
+   c->w = tw - 2 * BORDERPX;
+   c->h = th - 2 * BORDERPX;
+   resize(c, False);
+   i++;
+   }
+   else
+   XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
+   if(!sel || !isvisible(sel)) {
+   for(c = stack; c && !isvisible(c); c = c->snext);
+   focus(c);
+   }
+   restack();
+}
+
+void
 focusnext(Arg *arg) {
Client *c;