Subject: FVWM: PATCH: icon pixmap update

From: "Mattias Engdegård" <[email-masked]>
Date: Fri, 23 Jan 1998 15:19:23 +0100 (MET)

When changing icon pixmap from within a program, fvwm2 destroys the current
icon window and creates a new one with the new pixmap, even if it has the
same size. This causes:

a) an annoying flash as the icon is removed/recreated
b) a possible jump to a different location on the screen
c) the new icon window is placed on top of any window that was previously
   over it.

The patch below (applies on 2.0.46) cures this.

Cheers,

	Mattias Engdegård.

(please CC: any response to me, not just post it on the list)

--- events.c.orig	Fri Jan 23 14:26:43 1998
+++ events.c	Fri Jan 23 15:10:12 1998
@@ -392,6 +392,7 @@
 void HandlePropertyNotify()
 {
   XTextProperty text_prop;
+  long old_wmflags;
   
   DBUG("HandlePropertyNotify","Routine Entered");
 
@@ -443,21 +444,40 @@
       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" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].