Subject: FVWM: FvwmIconMan Bug?

From: [email-masked] (Bill Rugolsky Jr.)
Date: Mon, 23 Dec 1996 15:45:26 -0500 (EST)

I are currently migrating from vtwm to fvwm-2.0.43 on SunOS 4.1.3 and
Solaris 2.5.1.  My enviroments are as follows:

 VERSION: fvwm-2.0.43, FvwmIconMan 0.9 (and prior)
COMPILER: gcc-2.7.2
 OPTIONS: -O2 -DSHAPE -DPIXMAP_BUTTONS -DXPM

      OS: SunOS 4.1.4           OS: SunOS 5.5.1
  SERVER: MIT X11R5         SERVER: Sun Microsystems, Inc. 3.51

In the process of migrating, I have uncovered the following problems
with FvwmIconMan:

1. The configuration option:

     *FvwmIconMan*resolution page

causes FvwmIconMan to exhibit buggy behavior when switching pages; in
particular, there appears to be an off-by-one error in the viewport
bounds-checking logic.  This bug causes a window that abuts the edge
of the screen to appear in the icon manager on multiple pages.  I
traced the bug to the function win_in_viewport() in file
modules/FvwmIconMan/fvwm.c .   Rather than attempt to debug the logic,
I just simplified it.  The new function definition and context diff are
appended to this message.

2. There appears to be a problem with the "dontshow" configuration
option.  We have a misbehaving news application that continuously
updates the icon name and title with progress information.  This produces
unpleasant behavior, particularly over ISDN.  I tried using the following
lines in my .fvwm2rc to suppress the headline window in the icon manager:

    Style "*Query*Headline*" Icon news.xpm
    Style "*received*of*" Icon news.xpm
    *FvwmIconMan*dontshow *Query*Headline*
    *FvwmIconMan*dontshow *received*of*

This has the desired effect upon starting the application.  However, if
I iconify the window, it suddenly appears in the icon manager.  Under
FvwmIconMan-0.5, it remained in the icon manager.  Using FvwmIconMan-0.9,
the icon is removed from the icon manager when it is de-iconified.  I tried
creating separate lines with title= and icon= before the patterns, but
this did not affect the behavior.  I have successfully worked around the
problem by using the "WindowListSkip" style for these patterns, in place
of the "dontshow" option to FvwmIconMan.

Many thanks to everyone who has worked to make Fvwm the best window
manager available!

Sincerely,

   Bill Rugolsky
   Daiwa Securities America, Inc.
   [email-masked]

--------------------------------------------------------------------------------

static int win_in_viewport (WinData *win)
{
  WinManager *manager = win->manager;
  int flag = 0;
  
  assert (manager);

  switch (manager->res) {
  case SHOW_GLOBAL:
    flag = 1;
    break;

  case SHOW_DESKTOP:
    if (win->sticky || win->desknum == globals.desknum)
      flag = 1;
    break;

  case SHOW_PAGE:
    if (win->sticky) {
      flag = 1;
    } else if (win->desknum == globals.desknum) {
      /* win and screen intersect if they are not disjoint in x and y */
      flag = !((win->x+win->width <= 0)  || (win->x >= (long)globals.screenx) ||
	       (win->y+win->height <= 0) || (win->y >= (long)globals.screeny));
    }
    break;
  }
  return flag;
}

------------------------------ cut here ----------------------------------------
*** fvwm.c.orig	Sun Dec  8 16:34:02 1996
--- fvwm.c	Mon Dec 23 12:41:07 1996
***************
*** 145,151 ****
  static int win_in_viewport (WinData *win)
  {
    WinManager *manager = win->manager;
-   long xmin, xmax, ymin, ymax;
    int flag = 0;
    
    assert (manager);
--- 145,150 ----
***************
*** 161,269 ****
      break;
  
    case SHOW_PAGE:
- #if 0
-     if (win->sticky || (win->desknum == globals.desknum && 
- 			win->x >= 0 && win->x < globals.screenx &&
- 			win->y >= 0 && win->y < globals.screeny))
-     {
-     }
- #endif
-     xmin = win->x;
-     xmax = win->x + win->width;
-     ymin = win->y;
-     ymax = win->y + win->height;
- 
-     /* cases: (1) one of the corners is inside screen - handled here
-               (2) one of the edges intersects an edge of the screen
- 	      (3) (1) with window and screen reversed
-      */
- 
- /*  case 1:
- 
-     xmin >= 0 && xmin < screex && ymin >= 0 && ymin <= screeny
-       ||
-     xmin >= 0 && xmin < screex && ymax >= 0 && ymax <= screeny
-       ||
-     xmax >= 0 && xmax < screex && ymin >= 0 && ymin <= screeny
-       ||
-     xmax >= 0 && xmax < screex && ymax >= 0 && ymax <= screeny
- 
- goes to:
- 
-     xmin && (ymin || ymax)
-       ||
-     xmax && (ymin || ymax)
- 
- goes to:
- 
-     (xmin || xmax) && (ymin || max)
- 
- */
- 
- /*  Case 2:
-     
-     xmin <= 0 && xmax >= 0 && ymin >= 0 && ymin <= screeny ||
-     xmin <= screenx && xman >= screenx && ymin >= 0 && ymin <= screeny ||
-     ymin <= 0 && ymax >= 0 && xmin >= 0 && xmax <= screenx ||
-     ymin <= screeny && ymax >= screeny && xmin >= 0 && xmax <= screenx
- 
- goes to:
- 
-     (ymin >= 0 && ymin <= screeny) && 
-           (xmin <= 0 && xmax >= 0 || xmin <= screenx && xmax >= screenx) ||
-     (xmin >= 0 && xmax <= screenx) &&
-           (ymin <= 0 && ymax >= 0 || ymin <= screeny && ymax >= screeny)
-        
- */
- 
-     ConsoleDebug ("Screenx = %d, Screeny = %d\n", globals.screenx,
- 		  globals.screeny);
-     ConsoleDebug ("Window (%s) coords: (%d, %d), (%d, %d)\n", win->iconname, xmin, ymin, xmax, ymax);
      if (win->sticky) {
-       ConsoleDebug ("Sticky\n");
        flag = 1;
      }
!     else if (win->desknum == globals.desknum) {
!       if (((xmin >= 0 && xmin < globals.screenx) ||
! 	   (xmax >= 0 && xmax < globals.screenx)) &&
! 	  ((ymin >= 0 && ymin < globals.screeny) ||
! 	   (ymax >= 0 && ymax < globals.screeny))) {
! 	ConsoleDebug ("Window in screen\n");
! 	flag = 1;
!       }
!       else if (((ymin >= 0 && ymin < globals.screeny) && 
! 	       ((xmin <= 0 && xmax >= 0) || 
! 		(xmin < globals.screenx && xmax >= globals.screenx))) ||
! 	       ((xmin >= 0 && xmax <= globals.screenx) &&
! 	       ((ymin <= 0 && ymax >= 0) || 
! 		(ymin < globals.screeny && ymax >= globals.screeny)))) {
! 	ConsoleDebug ("Screen - window cross\n");
! 	flag = 1;
!       }
!       else if (((0 > xmin && 0 < xmax) ||
! 		(globals.screenx > xmin && globals.screenx < xmax)) &&
! 	       ((0 > ymin && 0 < ymax) ||
! 		(globals.screeny > 0 && globals.screeny < ymax))) {
! 	ConsoleDebug ("Screen in window\n");
! 	flag = 1;
!       }
!       else {
! 	ConsoleDebug ("Not in view\n");
! 	ConsoleDebug ("xmin = %d\txmax = %d\n", xmin, xmax);
! 	ConsoleDebug ("ymin = %d\tymax = %d\n", ymin, ymax);
! 	ConsoleDebug ("screenx = %d\tscreeny = %d\n", globals.screenx, 
! 		      globals.screeny);
! 	ConsoleDebug ("Expr: %d\n", 
! 		      ((0 >= xmin && 0) < xmax ||
! 		       (globals.screenx >= xmin && globals.screenx < xmax)) &&
! 		      ((0 >= ymin && 0 < ymax) ||
! 		       (globals.screeny >= 0 && globals.screeny < ymax)));
! 	  
!       }
!     }
!     else {
!       ConsoleDebug ("Not on desk\n");
!     }
    }
    return flag;
  }
--- 160,173 ----
      break;
  
    case SHOW_PAGE:
      if (win->sticky) {
        flag = 1;
+     } else if (win->desknum == globals.desknum) {
+       /* win and screen intersect if they are not disjoint in x and y */
+       flag = !((win->x+win->width <= 0)  || (win->x >= (long)globals.screenx) ||
+ 	       (win->y+win->height <= 0) || (win->y >= (long)globals.screeny));
      }
!     break;
    }
    return flag;
  }
--
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: Allen Brady Montz <[email-masked]>
Date: 23 Dec 1996 16:00:37 -0700

> Solaris 2.5.1.  My enviroments are as follows:
...
> appended to this message.

I'm the author of FvwmIconMan.

This might not be a problem with FvwmIconMan. In the last few years, I've seen
this behavior fairly often, but when looking REAL careful, it always turns out
that the offending window is actually extending into the next page by 1
pixel. Xv seems fond of doing this when it resizes and moves itself.I've
though about making a little fudge in the logic so that a window has to be in
the current page by at least a few pixels to count. Please check if this is
what's happening for you. An easy way to check is to set EdgeResistance in
your .fvwm2rc to something nice and big (I use "EdgeResistance 10000 100") and
then move the offending window up the the edge of the page. With
EdgeResistance set, fvwm should keep the window entirely in the current page.

As for your patch, it seems correct. How embarrassing. 

> of the "dontshow" option to FvwmIconMan.

FvwmIconMan determines which manager, if any, manages a window each time the
window name changes. I can't tell from what you said whether this is the cause
of your problem, or if the problem stems from a bug in this process. Could you
be more specific about what the title and icon names are when the program is
showing up in the manager, and when it isn't? Also, does the window title or
icon name change when the window is uniconified? A good thing to do is bind:

*FvwmIconBoxMouse       3       Click           Module FvwmIdent

in your .fvwm2rc and then clicking the third mouse button on a window in the
manager runs FvwmIdent on it. 

I haven't tested this code too thoroughly (ie, I don't use it in real life, so
I've only tested it with xterms changing their icon and title names), but I
can't reproduce this behavior.

Also, ouy of curiosity, what the "unpleasant behavior" that results when this
news program is listed in the manager?

-- 
 Brady Montz
 [email-masked]