Subject: FVWM: New function, Replace

From: Trent Piepho <[email-masked]>
Date: Thu, 31 Dec 1998 14:11:17 -0800 (PST)

This is a new builtin function I wrote back for fvwm-2.0.43.  I modified it so
it would work with the new fvwms and thought I would re-submit it.  This
patches applies to fvwm-2.1.6.

Here is the man page entry for the function:

       Replace [ Anim ]
              Causes  the current window's position to be re-com-
              puted using the  initial  window  placement  logic.
              Basically,  the  window  is moved to where it would
              have been if it were a new  window  that  had  just
              appeared.    Most   useful  with  Smart  or  Clever
              (ReallySmart) placement.  If the optional  argument
              Anim  is  specified,  an  animated  move is used to
              place the window in its new position.

diff -ru fvwm-2.1.6/fvwm/builtins.c fvwm-2.1.6.new/fvwm/builtins.c
--- fvwm-2.1.6/fvwm/builtins.c	Sat Dec 26 16:02:45 1998
+++ fvwm-2.1.6.new/fvwm/builtins.c	Thu Dec 31 13:03:26 1998
@@ -679,6 +679,30 @@
   return;
 }
 
+void replace_function(XEvent *eventp,Window w,FvwmWindow *tmp_win,
+              unsigned long context,char *action, int *Module)
+{
+  int x,y;
+  char *token;
+  
+  if (DeferExecution(eventp, &w, &tmp_win, &context, SELECT, ButtonRelease))
+    return;
+    
+  /* Find new position for window */
+  SmartPlacement(tmp_win,tmp_win->frame_width+2*tmp_win->bw,
+		 tmp_win->frame_height+2*tmp_win->bw, &x, &y,
+		 0,0);
+
+  /* Possibly animate the movement */
+  GetNextToken(action, &token);
+  if(token!=NULL && StrEquals("ANIM", token))
+    AnimatedMoveOfWindow(tmp_win->frame, -1, -1, x, y, FALSE, -1, NULL);
+
+  SetupFrame(tmp_win,x,y,tmp_win->frame_width, tmp_win->frame_height, FALSE);
+                 
+  return;
+}
+
 
 void iconify_function(XEvent *eventp,Window w,FvwmWindow *tmp_win,
 		      unsigned long context,char *action, int *Module)
diff -ru fvwm-2.1.6/fvwm/functions.c fvwm-2.1.6.new/fvwm/functions.c
--- fvwm-2.1.6/fvwm/functions.c	Tue Dec 22 15:38:12 1998
+++ fvwm-2.1.6.new/fvwm/functions.c	Thu Dec 31 13:03:26 1998
@@ -143,6 +143,7 @@
   {"Recapture",    Recapture,        F_RECAPTURE,           FUNC_NO_WINDOW},
   {"Refresh",      refresh_function, F_REFRESH,             FUNC_NO_WINDOW},
   {"RefreshWindow",refresh_win_function, F_REFRESH,         FUNC_NEEDS_WINDOW},
+  {"Replace",      replace_function, F_REPLACE,             FUNC_NEEDS_WINDOW},
   {"Resize",       resize_window,    F_RESIZE,              FUNC_NEEDS_WINDOW},
   {"Restart",      restart_function, F_RESTART,             FUNC_NO_WINDOW},
   {"Scroll",       scroll,           F_SCROLL,              FUNC_NO_WINDOW},
diff -ru fvwm-2.1.6/fvwm/misc.h fvwm-2.1.6.new/fvwm/misc.h
--- fvwm-2.1.6/fvwm/misc.h	Tue Dec 22 15:41:25 1998
+++ fvwm-2.1.6.new/fvwm/misc.h	Thu Dec 31 13:05:55 1998
@@ -374,6 +374,7 @@
 void exec_setup(F_CMD_ARGS);
 void refresh_function(F_CMD_ARGS);
 void refresh_win_function(F_CMD_ARGS);
+void replace_function(F_CMD_ARGS);
 void stick_function(F_CMD_ARGS);
 
 void setEdgeThickness(F_CMD_ARGS);
diff -ru fvwm-2.1.6/fvwm/parse.h fvwm-2.1.6.new/fvwm/parse.h
--- fvwm-2.1.6/fvwm/parse.h	Mon Dec 21 17:23:59 1998
+++ fvwm-2.1.6.new/fvwm/parse.h	Thu Dec 31 13:07:38 1998
@@ -119,6 +119,7 @@
     F_WINDOW_SHADE,
     F_COLOR_LIMIT,
     F_ANIMATED_MOVE,
+    F_REPLACE,
 
 /* Functions for use by modules only! */
     F_SEND_WINDOW_LIST = 1000