On Fri, May 22, 2015, at 02:26 PM, Greg Reagle wrote:
> Hello.  I would like dvtm to behave differently.  I don't want creating
> a new shell window (Mod-c) to make the new shell window the master; I
> want the master to stay the master.  I also don't want creating a new
> shell window to renumber all the windows; I want the new window to be
> one plus the last window number.
> 
> I have started to work on this, and it seems that adding the new window
> to the end of the window list rather than the beginning will achieve
> these two goals.
> 
> Has anyone already implemented this functionality?  Does the way I'm
> suggesting make sense?

So here is my attempt.  It compiles and works pretty well.  It has one
issue that I think might be a problem though.  In the window numbering,
the visible windows can be in a state where they are not continuous
(e.g. window 3 might be minimized and windows 1,2,4 might be visible).

Any thoughts?  Thanks.

-- 
http://www.fastmail.com - IMAP accessible web-mail

diff --git a/dvtm.c b/dvtm.c
index 464a223..efbbec6 100644
--- a/dvtm.c
+++ b/dvtm.c
@@ -503,6 +503,19 @@ attach(Client *c) {
 }
 
 static void
+attachatend(Client *c) {
+       Client *j;
+
+       for (j = clients; j && j->next; j = j->next) ; /* set j to last client*/
+       if (j)
+               j->next = c;
+       else
+               clients = c;
+       c->next = NULL;
+       c->prev = j;
+}
+
+static void
 attachafter(Client *c, Client *a) { /* attach c after a */
        if (c == a)
                return;
@@ -1029,7 +1042,7 @@ create(const char *args[]) {
        c->x = wax;
        c->y = way;
        debug("client with pid %d forked\n", c->pid);
-       attach(c);
+       attachatend(c);
        focus(c);
        arrange();
 }

Reply via email to