Subject: FVWM: Replace function

From: Trent Piepho <[email-masked]>
Date: Tue, 5 Nov 1996 21:03:03 -0800 (PST)

Well, I implimented a replace function.  It was actually quite simple.  What
is does is call CleverPlacement to find a new spot to stick a window.  You
will need Anthony Martin's CleverPlacement replacement for placement.c.  Some
suggested uses of it:

# have windows find a nice spot when they de-iconify
AddToFunc "Iconify-and-Replace" "C" Iconify
+              "C" Replace

Mouse 1         I       A       Function "Move-or-Iconify"
Mouse 2         I       A       Function "Iconify-and-Replace"
Mouse 3         I       A       Function "Iconify-and-Replace"           

# double click on title bar replaces the window
AddToFunc "Move-or-Raise" "M" Move
+              "M" Raise
+              "C" Raise
+              "D" Replace
Mouse 1         T       A       Function "Move-or-Raise"

And finally the patch:
---------------------------- cut -------------------------
diff -u fvwm/builtins.c fvwm.new/builtins.c
--- fvwm/builtins.c	Thu Jun 27 07:34:19 1996
+++ fvwm.new/builtins.c	Mon Nov  4 08:39:22 1996
@@ -555,6 +555,21 @@
 	       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)
diff -u fvwm/functions.c fvwm.new/functions.c
--- fvwm/functions.c	Wed Jun 19 17:01:56 1996
+++ fvwm.new/functions.c	Mon Nov  4 08:24:34 1996
@@ -89,6 +89,7 @@
   {"Read",         ReadFile,         F_READ,                FUNC_NO_WINDOW},
   {"Recapture",    Recapture,        F_RECAPTURE,           FUNC_NO_WINDOW},
   {"Refresh",      refresh_function, F_REFRESH,             FUNC_NO_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},
diff -u fvwm/misc.h fvwm.new/misc.h
--- fvwm/misc.h	Wed Jun 19 18:31:15 1996
+++ fvwm.new/misc.h	Mon Nov  4 08:28:02 1996
@@ -366,6 +366,8 @@
                 unsigned long context, char *action, int *Module);
 void refresh_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);
 
diff -u fvwm/parse.h fvwm.new/parse.h
--- fvwm/parse.h	Thu May 30 11:03:10 1996
+++ fvwm.new/parse.h	Mon Nov  4 08:25:14 1996
@@ -89,6 +89,7 @@
 #define F_SEND_STRING           112
 #define F_ADD_MOD               113
 #define F_DESTROY_MOD           114
+#define F_REPLACE		115
 
 /* Functions for use by modules only! */
 #define F_SEND_WINDOW_LIST     1000
------------------------------------------ cut --------------------

|Gazing up to the breeze of the heavens \ on a quest, meaning, reason  |
|came to be, how it begun \ all alone in the family of the sun         |
|curiosity teasing everyone \ on our home, third stone from the sun.   |
|Trent Piepho ([email-masked])                   -- Metallica  |
--
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: lar3ry gensch <[email-masked]>
Date: Wed, 06 Nov 1996 09:21:43 -0500

Trent Piepho wrote:
> will need Anthony Martin's CleverPlacement replacement for placement.c.

I found another use for it that I have been wanting for quite a while: 
A way to perform a "vertical maximize" function without having the
window appear at (0,0) on the desktop (where I have a button bar):

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

(92% was empirically derived to allow for the presense of a button bar
on the top, tkgoodstuff's task bar on the bottom, plus some extra room
-- Your Milage May Vary).

Actually, I've seen requests for this functionality come through this
mailing list a few times, so it might even be a candidate for a FAQ if
Chuck decides to implement "Replace" in his forthcoming 2.0.44 release. 
[Nudge, nudge, wink, wink!]

[If anybody is interested, the patch also works in fvwm95 as well with
minor tweaks to two header files.  If you are REALLY interested in the
tweaks, let me know privately, but don't spam this mailing list with
fvwm95 requests.]

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

  "I'm sorry you saw me, Billy.  Now I'll have to kill you." -- Santa