Subject: FVWM: expansion for SnapAttraction (Argh!)

From: Sami Lehtinen <[email-masked]>
Date: Thu, 7 Jan 1999 03:56:37 +0200 (EET)

And here's the patch :-) Silly me.
-- 
[[email-masked]           --  Sami J. Lehtinen  --           [email-masked]]
[work:+358 9 43543214][gsm:+358 50 5170 258][http://www.iki.fi/~sjl]
[SSH Communications Security Ltd.                http://www.ssh.fi/]
diff -u --recursive fvwm-2.1.6.orig/fvwm/builtins.c fvwm-2.1.6/fvwm/builtins.c
--- fvwm-2.1.6.orig/fvwm/builtins.c	Sun Dec 27 02:02:45 1998
+++ fvwm-2.1.6/fvwm/builtins.c	Thu Jan  7 03:05:58 1999
@@ -1274,6 +1274,16 @@
     { Scr.SnapMode = 3; }
 
   free(token);
+
+  action = GetNextToken(action, &token);
+  if(token == NULL)
+  {
+    return;
+  }
+
+  if(StrEquals(token,"Edges"))
+    { Scr.SnapMode += 8; }
+
 }
 
 void SetSnapGrid(XEvent *eventp,Window w,FvwmWindow *tmp_win,
diff -u --recursive fvwm-2.1.6.orig/fvwm/move.c fvwm-2.1.6/fvwm/move.c
--- fvwm-2.1.6.orig/fvwm/move.c	Sun Dec 27 00:56:14 1998
+++ fvwm-2.1.6/fvwm/move.c	Thu Jan  7 03:20:48 1999
@@ -324,17 +324,16 @@
 	       (other.y) > (*py + self.h) ))
 	    {
 	      dist = abs(other.x - (*px + self.w));
-	      if(dist < closestRight)
+              if(dist < closestRight)
 		{
 		  closestRight = dist;
 		  if(((*px + self.w) >= other.x)&&
 		     ((*px + self.w) < other.x+Scr.SnapAttraction))
 		    nxl = other.x - self.w;
-
 		  if(((*px + self.w) >= other.x - Scr.SnapAttraction)&&
 		     ((*px + self.w) < other.x))
 		    nxl = other.x - self.w;
-		}
+                }
 	      dist = abs(other.x + other.w - *px);
 	      if(dist < closestLeft)
 		{
@@ -347,7 +346,43 @@
 		    nxl = other.x + other.w;
 		}
 	    }
-	  if(!((other.x + other.w) < (*px) || (other.x) > (*px + self.w) ))
+          /* ScreenEdges - SJL */
+          if(!(Scr.MyDisplayHeight < (*py) ||
+               (*py + self.h) < 0) && (Scr.SnapMode & 8))
+            {
+              dist = abs(Scr.MyDisplayWidth - (*px + self.w));
+              
+              if(dist < closestRight)
+		{
+		  closestRight = dist;
+
+		  if(((*px + self.w) >= Scr.MyDisplayWidth)&&
+		     ((*px + self.w) < Scr.MyDisplayWidth +
+                      Scr.SnapAttraction))
+		    nxl = Scr.MyDisplayWidth - self.w;
+                  
+		  if(((*px + self.w) >= Scr.MyDisplayWidth -
+                      Scr.SnapAttraction)&&
+		     ((*px + self.w) < Scr.MyDisplayWidth))
+		    nxl = Scr.MyDisplayWidth - self.w;
+                }
+              
+              dist = abs(*px);
+
+	      if(dist < closestLeft)
+		{
+		  closestLeft = dist;
+
+                  if((*px <= 0)&&
+		     (*px > - Scr.SnapAttraction))
+		    nxl = 0;
+		  if((*px <= Scr.SnapAttraction)&&
+		     (*px > 0))
+		    nxl = 0;
+                }
+            }
+          
+	  if(!((other.x + other.w) < (*px) || (other.x) > (*px + self.w)))
 	    {
 	      dist = abs(other.y - (*py + self.h));
 	      if(dist < closestBottom)
@@ -372,6 +407,38 @@
 		    nyt = other.y + other.h;
 		}
 	    }
+          /* ScreenEdges - SJL */
+          if (!(Scr.MyDisplayWidth < (*px) || (*px + self.w) < 0 )
+              && (Scr.SnapMode & 8))
+            {
+              dist = abs(Scr.MyDisplayHeight - (*py + self.h));
+              
+	      if(dist < closestBottom)
+		{
+		  closestBottom = dist;
+                  if(((*py + self.h) >= Scr.MyDisplayHeight)&&
+                     ((*py + self.h) < Scr.MyDisplayHeight+Scr.SnapAttraction))
+                    nyt = Scr.MyDisplayHeight - self.h;
+                  if(((*py + self.h) >= Scr.MyDisplayHeight -
+                      Scr.SnapAttraction)&&
+                     ((*py + self.h) < Scr.MyDisplayHeight))
+                    nyt = Scr.MyDisplayHeight - self.h;
+                }
+              
+              dist = abs(- *py);
+              
+              if(dist < closestTop)
+		{
+                  closestTop = dist;
+		  if((*py <= 0)&&
+		     (*py > - Scr.SnapAttraction))
+		    nyt = 0;
+		  if((*py <=  Scr.SnapAttraction)&&
+		     (*py > 0))
+		    nyt = 0;
+                  
+                }
+            }
 	}
       tmp = tmp->next;
     }