Subject: FVWM: Window Placement Problem

From: Ben Cohen <[email-masked]>
Date: Tue, 30 May 2000 22:04:38 +0100 (BST)

(FVWM version 2.2.4)

I found the following post in the mailing list archives after having the
similar problems.  Firstly, a new window on an empty screen will appear at
(2,2) not (0,0).  Also, a Netscape window (say) that is the full
screen-size will also appear at (2,2) not (0,0).

I have found two things which seem to cause this in placement.c; I am
including a patch which solves the problem as far as I am concerned,
although I imagine it's not the "most correct" solution (but I don't have
time to look deeper into it).

Please tell me whether this is a bug or if I'm doing something wrong...

Thanks,
Ben.

=========

To: [email-masked] 
Subject: window placement 
From: [email-masked] 
Date: Mon, 24 Apr 2000 05:11:57 -0500 (CDT) 

using smartplacement the first window (i.e. when the page is empty) is
placed on (1,1) whereas all the following ones are placed on (0,0)

=========

*** placement.c	Tue May 30 21:48:07 2000
--- placement.c.original	Tue May 30 21:46:24 2000
***************
*** 159,166 ****
      rc  =  False;
      return rc;
    }
-   test_x--;
-   test_y--;
    *x = test_x;
    *y = test_y;
    return rc;
--- 159,164 ----
***************
*** 633,639 ****
           2*tmp_win->boundary_width> PageRight)
        {
          tmp_win->attr.x = PageRight -tmp_win->attr.width
!           - tmp_win->old_bw +tmp_win->bw - 2*tmp_win->boundary_width-2;
          Scr.randomx = 0;
        }
        if(tmp_win->frame_y +
2*tmp_win->boundary_width+tmp_win->title_height
--- 631,637 ----
           2*tmp_win->boundary_width> PageRight)
        {
          tmp_win->attr.x = PageRight -tmp_win->attr.width
!           - tmp_win->old_bw +tmp_win->bw - 2*tmp_win->boundary_width;
          Scr.randomx = 0;
        }
        if(tmp_win->frame_y +
2*tmp_win->boundary_width+tmp_win->title_height
***************
*** 641,647 ****
        {
          tmp_win->attr.y = PageBottom -tmp_win->attr.height
            - tmp_win->old_bw +tmp_win->bw - tmp_win->title_height -
!           2*tmp_win->boundary_width-2;
          Scr.randomy = 0;
        }
  
--- 639,645 ----
        {
          tmp_win->attr.y = PageBottom -tmp_win->attr.height
            - tmp_win->old_bw +tmp_win->bw - tmp_win->title_height -
!           2*tmp_win->boundary_width;;
          Scr.randomy = 0;
        }

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
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: Dominik Vogt <[email-masked]>
Date: Wed, 31 May 2000 02:11:27 +0200

> screen-size will also appear at (2,2) not (0,0).

Ah, now that you rephrase that bug report I finally understand
what the problem is.  This is still happening with 2.3.19.

> Please tell me whether this is a bug or if I'm doing something wrong...

It's a bug.  The loops over the x and y coordinates are broken.
When the window finally found a proper position, the code adds
one pixel in x and y direction before placing it.  There's another
bug in the collision detection.  Windows are interpreted as
overlapping if they are directly adjacent.  This causes the two
pixel gap between windows.

Here is the proper fix for 2.2.4:

----------------------------- snip -------------------------------
--- placement.c Sat Oct  2 18:42:13 1999
+++ placement.c.orig    Wed May 31 02:08:57 2000
@@ -139,8 +139,8 @@
             th=test_window->frame_height+2*test_window->bw;
             tx = test_window->frame_x - stickyx;
             ty = test_window->frame_y - stickyy;
-            if((tx <= (test_x+width))&&((tx + tw) >= test_x)&&
-               (ty <= (test_y+height))&&((ty + th)>= test_y))
+            if((tx < (test_x+width))&&((tx + tw) > test_x)&&
+               (ty < (test_y+height))&&((ty + th)> test_y))
             {
               loc_ok = False;
               test_x = tx + tw;
@@ -149,9 +149,11 @@
         }
         test_window = test_window->next;
       }
-      test_x +=1;
+      if (!loc_ok)
+       test_x +=1;
     }
-    test_y +=1;
+    if (!loc_ok)
+      test_y +=1;
   }
   /*  RBW - 11/02/1998  */
   if(loc_ok == False)
----------------------------- snip -------------------------------

Bye

Dominik ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
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: Ben Cohen <[email-masked]>
Date: Wed, 31 May 2000 10:55:40 +0100 (BST)

>what the problem is.  This is still happening with 2.3.19.

Thanks -- that fixes the first problem (of a new window on an empty
screen). 

However, I am still having the problem with Netscape:  I have NS set up to
open its window at the maximum size for the screen.  So I would hope that
fvwm positions it from (0,0) so that it fills the screen exactly with no
edge-gaps.  But it actually appears at (2,2).  This still happens after
applying the patch you sent.  The patch I sent yesterday (where I subtract
2 from tmp_win->attr.x and y) seems to stop this problem, but as I said I
don't think it is the correct fix.

Thanks,
Ben.