Subject: [PATCH] suppress needless icon recreation

From: "Mattias Engdeg�rd" <[email-masked]>
Date: Sat, 5 Dec 1998 21:23:20 +0100 (MET)

When an icon pixmap is changed (by changing the wmhints), fvwm kills the
existing icon window and creates a new one even if it has the same size.
This results in an annoying flash and the new icon is placed on top of any
obscuring windows. Some programs display some kind of state in their icons
which causes this at regular intervals (some clocks, mail programs,
system monitors such as qps).

The patch applies to fvwm 2.1.4.

--- events.c~	Wed Dec  2 17:29:49 1998
+++ events.c	Sat Dec  5 21:01:00 1998
@@ -404,6 +404,7 @@
 {
   XTextProperty text_prop;
   Boolean       OnThisPage    =  False;
+  unsigned long old_wmflags;
 
   DBUG("HandlePropertyNotify","Routine Entered");
 
@@ -485,21 +486,39 @@
       break;
 
     case XA_WM_HINTS:
-      if (Tmp_win->wmhints)
+      if (Tmp_win->wmhints) {
+	old_wmflags = Tmp_win->wmhints->flags;
 	XFree ((char *) Tmp_win->wmhints);
+      }
       Tmp_win->wmhints = XGetWMHints(dpy, Event.xany.window);
 
       if(Tmp_win->wmhints == NULL)
 	return;
 
       if((Tmp_win->wmhints->flags & IconPixmapHint)||
-	 (Tmp_win->wmhints->flags & IconWindowHint))
-	if(Tmp_win->icon_bitmap_file == Scr.DefaultIcon)
-	  Tmp_win->icon_bitmap_file = (char *)0;
-
-      if((Tmp_win->wmhints->flags & IconPixmapHint)||
          (Tmp_win->wmhints->flags & IconWindowHint))
 	{
+	  if(Tmp_win->icon_bitmap_file == Scr.DefaultIcon)
+	    Tmp_win->icon_bitmap_file = (char *)0;
+      
+	  if(Tmp_win->wmhints->flags == old_wmflags
+	     && (old_wmflags & IconPixmapHint) && Tmp_win->wmhints->icon_pixmap
+	     && (Tmp_win->flags & ICONIFIED) && (Tmp_win->flags & ICON_OURS)) {
+	      unsigned w, h;
+	      XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &JunkRoot,
+			   &JunkX, &JunkY, &w, &h, &JunkBW, &JunkDepth);
+	      w += 4; h += 4;	/* for border */
+	      if(w == Tmp_win->icon_p_width && h == Tmp_win->icon_p_height) {
+		  /* Only the icon pixmap has changed (size remains the same),
+		     don't destroy and recreate the icon */
+		  GetIconBitmap(Tmp_win);
+		  Tmp_win->icon_p_width += 4;
+		  Tmp_win->icon_p_height += 4;
+		  DrawIconWindow(Tmp_win);
+		  break;
+	      }
+	  }
+	     
 	  if (!(Tmp_win->flags & SUPPRESSICON))
 	    {
               if (Tmp_win->icon_w)
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
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: Dominik Vogt <[email-masked]>
Date: Mon, 7 Dec 1998 16:19:27 +0100

> system monitors such as qps).

Dan, does this have sth. to do with the reloading icons you
noticed a while ago?

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.hpc.uh.edu/fvwm/>.
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: Dan Espen <[email-masked]>
Date: Mon, 07 Dec 1998 10:30:14 -0500

> Dan, does this have sth. to do with the reloading icons you

I don't think so. But, I haven't looked into the Pixmap cache yet.

I have a  few programs that  have live icons.  I  think its normal for
fvwm2 to destroy the old icon window and create a new one when an icon
changes.   I don't see  any  annoying flash,  and  don't see why there
should be a  flash when a  new icon is  displayed.  I have seen  icons
rise to  the top when they change.   Since the icon is  usually active
for a reason,  I  wouldn't consider the icon  rising  to the top  as a
problem.

If there is a more efficient way to update an icon image when its size
is unchanged, I would think using it would be OK.

--
Dan Espen                                Phone: (732) 699-5570
444 Hoes Lane  Room RRC 1C-214           E-mail: [email-masked]
Piscataway, NJ 08854
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
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].