Subject: patch for windowlist

From: Staffan Hämälä <[email-masked]>
Date: Thu, 14 Oct 1999 20:33:47 +0200

Hi,

I was trying the newest CVS version tonight when I thought I'd
make a patch for the WindowList function so that it works the
way I would like it to do. I've added this as an option
'NoGeometryWithInfo', that does the same thing as 'NoGeometry',
but also shows information about which virtual screen each
window is positioned on, and if the window is iconified or not.

/Staffan

*** windowlist.c.old	Thu Oct 14 20:21:51 1999
--- windowlist.c	Thu Oct 14 20:28:00 1999
***************
*** 53,58 ****
--- 53,59 ----
  #define NO_DESK_SORT  (1<<6)
  #define SHOW_ICONNAME (1<<7)
  #define SHOW_ALPHABETIC (1<<8)
+ #define SHOW_INFONOTGEO (1<<9)
  #define SHOW_EVERYTHING (SHOW_GEOMETRY | SHOW_ALLDESKS | SHOW_NORMAL | SHOW_ICONIC | SHOW_STICKY)
  
  /* Function to compare window title names
***************
*** 174,179 ****
--- 175,185 ----
          flags |= SHOW_ICONNAME;
        else if (StrEquals(tok,"NoGeometry"))
          flags &= ~SHOW_GEOMETRY;
+       else if (StrEquals(tok,"NoGeometryWithInfo"))
+       {
+         flags &= ~SHOW_GEOMETRY;
+         flags |= SHOW_INFONOTGEO;
+       }
        else if (StrEquals(tok,"Geometry"))
          flags |= SHOW_GEOMETRY;
        else if (StrEquals(tok,"NoIcons"))
***************
*** 333,339 ****
          if (t->Desk != last_desk_displayed)
          {
            if (last_desk_displayed != INT_MIN)
!             if (flags & SHOW_GEOMETRY)
              AddToMenu(mr, NULL, NULL, FALSE, FALSE);
            last_desk_displayed = t->Desk;
          }
--- 339,345 ----
          if (t->Desk != last_desk_displayed)
          {
            if (last_desk_displayed != INT_MIN)
!             if ((flags & SHOW_GEOMETRY) || (flags & SHOW_INFONOTGEO))
              AddToMenu(mr, NULL, NULL, FALSE, FALSE);
            last_desk_displayed = t->Desk;
          }
***************
*** 343,350 ****
          else
            name = t->name;
          t_hot = safemalloc(strlen(name) + strlen(tname) + 48);
!         sprintf(t_hot, "&%c.  %s", scut, name); /* Generate label */
          if (scut++ == '9') scut = 'A';	/* Next shortcut key */
  
          if (flags & SHOW_GEOMETRY)
          {
--- 349,379 ----
          else
            name = t->name;
          t_hot = safemalloc(strlen(name) + strlen(tname) + 48);
! 
!         if(flags & SHOW_INFONOTGEO)
!           sprintf(t_hot, "&%c.  ", scut);         /* Generate label */
!         else
!           sprintf(t_hot, "&%c.  %s", scut, name); /* Generate label */
! 
          if (scut++ == '9') scut = 'A';	/* Next shortcut key */
+ 
+         if (flags & SHOW_INFONOTGEO)
+         {
+           tname[0]=0;
+           if(!IS_ICONIFIED(t))
+           {
+             sprintf(loc,"%d:", t->Desk);
+             strcat(tname,loc);
+           }
+           else
+             strcat(tname, "(");
+           strcat(tname, name);
+           if(IS_ICONIFIED(t))
+             strcat(tname, ")");
+           strcat(t_hot,"\t");
+           strcat(t_hot,tname);
+         }
+ 
  
          if (flags & SHOW_GEOMETRY)
          {

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 15 Oct 1999 04:31:37 +0200

> window is positioned on, and if the window is iconified or not.

One question: did you check that the allocated memory is still big
enough to hold the string?

Please write a patch for the man page for this option too.

Bye

Dominik ^_^

-- 
Dominik Vogt, Hewlett-Packard GmbH, Dept. BVS
Herrenberger Str.130, 71034 Boeblingen, Germany
phone: 07031/14-4596, fax: 07031/14-3883, [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Staffan Hämälä <[email-masked]>
Date: Fri, 15 Oct 1999 09:39:15 +0200

> enough to hold the string?

t_hot is strlen(name) + strlen(tname) + 48, and in this mode
the menulines never gets longer than name 4 + name + 6, so it
will suffice.
I've now changed it to append to the t_hot string directly,
which makes it safe in case 'name' is really long.

Actually, now I noticed that this line is a bit wierd:
        t_hot = safemalloc(strlen(name) + strlen(tname) + 48);

At that point tname isn't really of a length that has anything
to do with the current menuentry. The first time the loop iterates
it's strlen(tname) will be 0, and the following times it will
be the length of the previous menuentry.
This isn't how it's supposed to behave?

> Please write a patch for the man page for this option too.

Sure.

I'm including both patches here.

/Staffan

*** windowlist.c.old	Fri Oct 15 09:22:57 1999
--- windowlist.c	Fri Oct 15 09:36:40 1999
***************
*** 373,383 ****
            }
            else
              strcat(tname, "(");
-           strcat(tname, name);
-           if(IS_ICONIFIED(t))
-             strcat(tname, ")");
            strcat(t_hot,"\t");
            strcat(t_hot,tname);
          }

--- 373,383 ----
            }
            else
              strcat(tname, "(");
            strcat(t_hot,"\t");
            strcat(t_hot,tname);
+           strcat(t_hot, name);
+           if(IS_ICONIFIED(t))
+             strcat(t_hot, ")");
          }

*** fvwm2.1.old	Fri Oct 15 09:33:18 1999
--- fvwm2.1	Fri Oct 15 09:33:22 1999
***************
*** 2055,2061 ****
  "OnlyIcons", "NoNormal", "Normal", "OnlyNormal", "NoSticky", "Sticky",
  "OnlySticky", "NoOnTop", "OnTop", "OnlyOnTop", "Layer m [n]",
  "UseListSkip", "OnlyListSkip", "NoDeskSort", "UseIconName", "Alphabetic",
! "NotAlphabetic".
  
  (Note - normal means not iconic, sticky, or ontop)
  
--- 2055,2061 ----
  "OnlyIcons", "NoNormal", "Normal", "OnlyNormal", "NoSticky", "Sticky",
  "OnlySticky", "NoOnTop", "OnTop", "OnlyOnTop", "Layer m [n]",
  "UseListSkip", "OnlyListSkip", "NoDeskSort", "UseIconName", "Alphabetic",
! "NotAlphabetic", "NoGeometryWithInfo".
  
  (Note - normal means not iconic, sticky, or ontop)