Subject: "Replace" patch

From: lar3ry gensch <[email-masked]>
Date: Fri, 17 Jan 1997 10:34:50 -0500

This patch was provided by somebody else (not I) for fvwm-2.0.43, but
was not included in the fvwm-2.0.44 distribution.  It provides a
"Replace" function, which uses CleverPlacement to reposition an existing
window on the screen.

A useful example:

	AddToFunc	"MaximizeVert"
	+	"I"	Maximize 0 92
	+	"I"	Replace

My setup has a button bar on the top of the screen, and the tkgoodstuff
task bar on the bottom of the screen.  If I execute the "Maximize 0 92"
function, it will move the window to the top of the screen, partially
obscuring the button bar.  The "Replace" function will call
CleverPlacement to find a more suitable location to put the window (if
possible).

I've MIME-attached the patch to this message.

-- 
(void) lar3ry();                                      [email-masked]

     "Sometimes it happens.  People just explode.  Natural causes."
*** fvwm-2.0.44/fvwm/builtins.c	Tue Jan 14 11:38:36 1997
--- use/fvwm-2.0.44/fvwm/builtins.c	Fri Jan 17 10:19:17 1997
***************
*** 319,325 ****
    if(tmp_win == NULL)
      return;
    
!   if(check_allowed_function2(F_MAXIMIZE,tmp_win) == 0)
    {
      XBell(dpy, Scr.screen);
      return;
--- 319,329 ----
    if(tmp_win == NULL)
      return;
    
!   if(check_allowed_function2(F_MAXIMIZE,tmp_win) == 0
! #ifdef WINDOWSHADE
!      || (tmp_win->buttons & WSHADE)
! #endif
!       )
    {
      XBell(dpy, Scr.screen);
      return;
***************
*** 333,342 ****
      val2_unit = Scr.MyDisplayHeight;
    }
  
- #ifdef WINDOWSHADE
-   tmp_win->buttons &= ~WSHADE;
- #endif
- 
    if (tmp_win->flags & MAXIMIZED)
    {
      tmp_win->flags &= ~MAXIMIZED;
--- 337,342 ----
***************
*** 660,665 ****
--- 660,681 ----
  	       y+val2*val2_unit/100 - warp_y);
  }
  
+ 
+ void replace_function(XEvent *eventp,Window w,FvwmWindow *tmp_win,
+                      unsigned long context,char *action, int *Module)
+ {
+        int x,y;
+ 
+     if (DeferExecution(eventp,&w,&tmp_win,&context, SELECT, 
+                     ButtonRelease))
+     return;
+ 
+        CleverPlacement(tmp_win, &x, &y, 1);
+ 
+        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)
*** fvwm-2.0.44/fvwm/functions.c	Tue Jan 14 09:06:33 1997
--- use/fvwm-2.0.44/fvwm/functions.c	Fri Jan 17 10:21:05 1997
***************
*** 111,116 ****
--- 111,117 ----
    {"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},
    {"KillModule",   module_zapper,    F_ZAP,                 FUNC_NO_WINDOW},
*** fvwm-2.0.44/fvwm/misc.h	Mon Dec 23 17:07:47 1996
--- use/fvwm-2.0.44/fvwm/misc.h	Fri Jan 17 10:20:14 1997
***************
*** 408,413 ****
--- 408,415 ----
  		      unsigned long context, char *action, int *Module);
  void refresh_win_function(XEvent *eventp,Window w,FvwmWindow *tmp_win,
  		      unsigned long context, char *action, int *Module);
+ void replace_function(XEvent *eventp,Window w,FvwmWindow *tmp_win,
+                      unsigned long context, char *action, int *Module);
  void stick_function(XEvent *eventp,Window w,FvwmWindow *tmp_win,
  		    unsigned long context, char *action, int *Module);
  
*** fvwm-2.0.44/fvwm/parse.h	Mon Dec 23 17:07:47 1996
--- use/fvwm-2.0.44/fvwm/parse.h	Fri Jan 17 10:21:42 1997
***************
*** 101,106 ****
--- 101,107 ----
  #define F_DESTROY_DECOR         124
  #define F_UPDATE_DECOR          125
  #define F_WINDOW_SHADE          126
+ #define F_REPLACE		127
  
  /* Functions for use by modules only! */
  #define F_SEND_WINDOW_LIST     1000