Subject: patch for many windows

From: David Fries <[email-masked]>
Date: Sun, 9 Feb 2003 16:03:13 -0600

I've noticed before that when I start gimp to view a ton of images at
once fvwm crashes so I decided to do something about it.  My test had
gimp loading a window per png icon image, something like 783 windows
total.  I included a patch to fix the segfault that was happening.

fvwm/gnome.c GNOME_SetClientList had an array with 256 entries, which
causes problems if there are more than 256 windows being displayed.  I
made it dynamic.  Is there anyway for us to know how many windows we
will need to keep track of without having to discover the number by
going through the entire list just to count them?

I don't know if it is an issue, but in my case I started gimp with all
thess windows and then started fvwm.  The windows were already in
place and it was calling the GNOME_SetClientList per window, which
builds a list of all previously registered windows.  It would be nice
if we could call it once after fvwm gets started so we could avoid
doing so much extra work that gets discarded when fvwm starts
processing the next window.

Comments welcome, I'm on the list but Cc me anyway.

-- 
David Fries <[email-masked]>
http://fries.net/~david/pgpkey.txt
Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.2231
diff -u -r1.2231 ChangeLog
--- ChangeLog	8 Feb 2003 19:04:34 -0000	1.2231
+++ ChangeLog	9 Feb 2003 21:11:46 -0000
@@ -1,3 +1,10 @@
+2003-02-09  David Fries <[email-masked]>
+
+	* fvwm/gnome.c (GNOME_SetClientList): The statically sized window
+	list held only 256 entries and would crash when there were more
+	windows than this being displayed.  The array is now dynamically
+	sized.
+
 2003-02-08  Dan Espen  <[email-masked]>
 
 	* fvwm/fvwm.1.in: Fully document the emulate command.
Index: fvwm/gnome.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/gnome.c,v
retrieving revision 1.61
diff -u -r1.61 gnome.c
--- fvwm/gnome.c	3 Jan 2003 06:57:36 -0000	1.61
+++ fvwm/gnome.c	9 Feb 2003 21:11:49 -0000
@@ -772,31 +772,39 @@
 GNOME_SetClientList(void)
 {
 	Atom atom_set;
-	Window wl[256];
+	Window *wl=NULL;
+	int displayed=0;
 	int i = 0;
 	FvwmWindow *t;
 
-	atom_set = XInternAtom(dpy, XA_WIN_CLIENT_LIST, False);
-	for (t = Scr.FvwmRoot.next; t != NULL; t = t->next)
+	/* Find out how many window pointers we need to store, allocate
+	 * the space and go through the list again to actually store them.
+	 */
+	for (t = Scr.FvwmRoot.next; t; t = t->next)
 	{
 		if (!DO_SKIP_WINDOW_LIST(t))
 		{
-			wl[i++] = FW_W(t);
+			displayed++;
 		}
 	}
-
-	if (i > 0)
-	{
-		XChangeProperty(
-			dpy, Scr.Root, atom_set, XA_CARDINAL, 32,
-			PropModeReplace, (unsigned char *)wl, i);
-	}
-	else
+	if(displayed)
 	{
-		XChangeProperty(
-			dpy, Scr.Root, atom_set, XA_CARDINAL, 32,
-			PropModeReplace, (unsigned char *)NULL, 0);
+		wl=(Window*)malloc(sizeof(Window*)*displayed);
+		for (t = Scr.FvwmRoot.next; t; t = t->next)
+		{
+			if (!DO_SKIP_WINDOW_LIST(t))
+			{
+				wl[i++] = FW_W(t);
+			}
+		}
 	}
+	/* Update X */
+	atom_set = XInternAtom(dpy, XA_WIN_CLIENT_LIST, False);
+	XChangeProperty(
+		dpy, Scr.Root, atom_set, XA_CARDINAL, 32,
+		PropModeReplace, (unsigned char *)wl, i);
+	if(wl)
+		free(wl);
 
 	return;
 }

---

From: Olivier Chapuis <[email-masked]>
Date: Thu, 13 Feb 2003 14:52:37 +0100

> total.  I included a patch to fix the segfault that was happening.

Applied, thanks.

> processing the next window.

Yes maybe, patch welcome, but I am not sure this is a real pb.

Regards, Olivier
--
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]