Subject: FVWM: RaiseWindow bug fix

From: Richard Lister <[email-masked]>
Date: Wed, 12 Jun 1996 22:23:39 +0100

Chuck, here's another bug fix for icons without a pixmap.

PROBLEM:
If an icon without a pixmap is deiconified it comes up underneath
all other windows on the screen.

CAUSE:
In RaiseWindow(), if there's no icon_pixmap_w then NULL gets pushed
onto the wins[] array, screwing up the call to XRestackWindows().

TO FIX:
Test for icon_pixmap_w != NULL first. Here's the patch.

Ric

--- fvwm/misc.c.orig    Wed Jun 12 22:12:19 1996
+++ fvwm/misc.c Wed Jun 12 22:17:30 1996
@@ -686,7 +686,9 @@
 #endif
   if ((t->flags & ICONIFIED)&&(!(t->flags & SUPPRESSICON)))
     {
-      if(!(t->flags & NOICON_TITLE))wins[i++] = t->icon_w;
+      if(!(t->flags & NOICON_TITLE))
+        wins[i++] = t->icon_w;
+      if ( t->icon_pixmap_w != None )
       wins[i++] = t->icon_pixmap_w;
     }
   if(!(t->flags & ONTOP))

 ~~~~~~~~~~~~~~ Richard J. Lister    [email-masked] ~~~~~~~~~~~~~~~~
            Research Assistant, Neural Computing Research Group
                  Aston University, Birmingham B4 7ET, UK
 ~~~~~~~~~~~~~~~~~ http://www.ncrg.aston.ac.uk/~listerrj/ ~~~~~~~~~~~~~~~~~~
--
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].

---

From: Austin Donnelly <[email-masked]>
Date: Wed, 12 Jun 96 22:35 BST

> Test for icon_pixmap_w != NULL first. Here's the patch.

Yup, I fixed this one about 1-2 months ago.  Strangely enough, my
patch was almost exactly yours :)

Austin

---

From: Richard Lister <[email-masked]>
Date: Thu, 13 Jun 1996 12:05:22 +0100

On Wed, 12 Jun 96 22:35 BST
Austin Donnelly <[email-masked]> 
> patch was almost exactly yours :)

Aha! I should have checked the archive first :-). Strange that I missed
your fix when it was first posted ... I must have read that message
before my first coffee of the day!

Incidentally, I note Chuck said this doesn't happen under AIX. Is it
a bug in some implementations of XRestackWindows(), not treating the
array index i as authoritative and stopping at NULL array members?
Or a feature :-)   I'm on Irix 6.2 (X11R6).

Ric

---

From: Austin Donnelly <[email-masked]>
Date: Thu, 13 Jun 96 12:43 BST

> before my first coffee of the day!

I posted it on 19th April. I still have my original emails, which I
include below.

> Or a feature :-)   I'm on Irix 6.2 (X11R6).

Yes, I think it's due to some X servers attempting to protect
themselves from poorly written programs :)

Austin
------------------------------------------------------------
On Fri, 19 Apr 1996, Austin Donnelly wrote:

> In fvwm-2.0.42, if you deiconify a window without an icon associated
> with it, it appeared behind all other windows, but is entered in
> fvwm's idea of things as the top-most window.
> 
> This can be demostrated by 'raise-or-lower'ing it.
> 
> To see this:
> 
> 1) Iconify a window that doesn't have an icon specified.
>      -> iconised window is now just a small recangle of text
> 2) deiconify it.
>      -> window comes back, but displayed at the bottom stacking order
>         on screen
> 3) raise-or-lower the window.
>      -> nothing happens, since fvwm thinks the window is at the top,
>         so it sends it to the bottom (it's already at the bottom).
> 4) raise-or-lower the window again.
>      -> now comes to the front for the first time.
> 

Ok, I've got a fix for it:

------------------------------------------------------------
--- misc.c~	Mon Mar 11 18:27:35 1996
+++ misc.c	Fri Apr 19 18:05:15 1996
@@ -686,8 +686,10 @@
 #endif
   if ((t->flags & ICONIFIED)&&(!(t->flags & SUPPRESSICON)))
     {
-      if(!(t->flags & NOICON_TITLE))wins[i++] = t->icon_w;
-      wins[i++] = t->icon_pixmap_w;
+      if(!(t->flags & NOICON_TITLE)) 
+	wins[i++] = t->icon_w;
+      if (t->icon_pixmap_w)
+	wins[i++] = t->icon_pixmap_w;
     }
   if(!(t->flags & ONTOP))
     wins[i++] = t->frame;
------------------------------------------------------------

Basically, what was happening was that when building a list of windows
to be raised, it would include icon_pixmap_w, which was a NULL (since
the window had no icon).

The list of windows to be raised was passed to the X server in the
  XRestackWindows(dpy,wins,i);
call. In this call, X was taking the NULL in wins to mean the end of
the list, rather than relying on i. Since the main window is in wins[]
after the NULL, it never got re-stacked.

Austin

---

From: <[email-masked]> (Charles Hines)
Date: Thu, 13 Jun 1996 09:24:29 -0400

The RaiseWindow fix will be in the next beta.  There was another spot
in that code that needed it as well (in the transient section just
above there).

Chuck