Subject: PATCH: New style, CenterPlacement. This patch is as complete as I can make it.

From: Francis Litterio <[email-masked]>
Date: Thu, 27 May 2004 12:38:54 -0400

Per Dan's request that I submit a complete patch, I've updated my recent
CenterPlacement patch to be as complete as I can make it.  The attached
file contains changes to these files:

	AUTHORS
	ChangeLog
	NEWS
	fvwm/fvwm.1.in
	fvwm/fvwm.h
	fvwm/placement.c
	fvwm/style.c
	sample.fvwmrc/system.fvwm2rc-sample-1

I was unable to figure out how to write a test for the CenterPlacement
style, so I didn't change tests/purify/purify.fvwm2rc.

I hope the FVWM developers find this functionality useful.
--
Francis Litterio
[email-masked]
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.

Index: AUTHORS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/AUTHORS,v
retrieving revision 1.93
diff -u -r1.93 AUTHORS
--- AUTHORS	23 May 2004 16:20:23 -0000	1.93
+++ AUTHORS	27 May 2004 16:35:41 -0000
@@ -25,7 +25,7 @@
 command.
 
 Francis Litterio:
-Fixed building FvwmScript under cygwin.
+Fixed building FvwmScript under cygwin.  Added CenterPlacement style.
 
 David Fries:
 Fixed the GNOME1 patch. WindowList class name sorting.
Index: ChangeLog
===================================================================
RCS file: /home/cvs/fvwm/fvwm/ChangeLog,v
retrieving revision 1.2491
diff -u -r1.2491 ChangeLog
--- ChangeLog	26 May 2004 08:25:24 -0000	1.2491
+++ ChangeLog	27 May 2004 16:35:50 -0000
@@ -1,3 +1,11 @@
+2004-05-26  Francis Litterio  <[email-masked]>
+
+	* fvwm/fvwm.1.in
+	* fvmw/fvwm.h
+	* fvwm/placement.c (__place_get_wm_pos)
+	* fvwm/style.c (style_parse_one_style_option)
+	Added support for new CenterPlacement style (cf. macro PLACE_CENTER).
+	
 2004-05-26  Dominik Vogt  <[email-masked]>
 
 	* fvwm/placement.c (__place_get_wm_pos):
Index: NEWS
===================================================================
RCS file: /home/cvs/fvwm/fvwm/NEWS,v
retrieving revision 1.520
diff -u -r1.520 NEWS
--- NEWS	21 Apr 2004 23:04:49 -0000	1.520
+++ NEWS	27 May 2004 16:35:52 -0000
@@ -16,6 +16,8 @@
 
 * New Style option "State".
 
+* New Style option "CenterPlacement".
+
 -------------------------------------------------------------------
 
 Changes in alpha release 2.5.10 (19-Mar-2004)
Index: fvwm/fvwm.1.in
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.1.in,v
retrieving revision 1.134
diff -u -r1.134 fvwm.1.in
--- fvwm/fvwm.1.in	9 May 2004 12:59:55 -0000	1.134
+++ fvwm/fvwm.1.in	27 May 2004 16:35:59 -0000
@@ -6256,7 +6256,7 @@
 .IR StickyAcrossDesksIcon " / " !StickyAcrossDesksIcon ,
 .IR ManualPlacement " / " CascadePlacement " / " MinOverlapPlacement " / "
 .IR MinOverlapPercentPlacement " / " TileManualPlacement " / "
-.IR TileCascadePlacement ,
+.IR TileCascadePlacement , " / " CenterPlacement ,
 .IR MinOverlapPlacementPenalties ,
 .IR MinOverlapPercentPlacementPenalties ,
 .IR DecorateTransient " / " NakedTransient ,
@@ -7295,6 +7295,9 @@
 situation. The default is
 .IR TileCascadePlacement .
 
+.I CenterPlacement
+automatically places new windows in the center of the display.
+
 .I CascadePlacement
 automatically place new windows in a cascading fashion.
 
Index: fvwm/fvwm.h
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/fvwm.h,v
retrieving revision 1.230
diff -u -r1.230 fvwm.h
--- fvwm/fvwm.h	2 Apr 2004 12:09:33 -0000	1.230
+++ fvwm/fvwm.h	27 May 2004 16:36:01 -0000
@@ -467,8 +467,9 @@
 #define PLACE_TILECASCADE       0x5
 #define PLACE_CASCADE_B         0x6
 #define PLACE_MINOVERLAP        0x7
-#define PLACE_MASK              0x7
-	unsigned placement_mode : 3;
+#define PLACE_CENTER		0x8
+#define PLACE_MASK              0xF
+	unsigned placement_mode : 4;
 	unsigned ewmh_placement_mode : 2; /* see ewmh.h */
 #define WS_CR_MOTION_METHOD_AUTO CR_MOTION_METHOD_AUTO
 #define WS_CR_MOTION_METHOD_USE_GRAV CR_MOTION_METHOD_USE_GRAV
Index: fvwm/placement.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/placement.c,v
retrieving revision 1.135
diff -u -r1.135 placement.c
--- fvwm/placement.c	26 May 2004 08:25:24 -0000	1.135
+++ fvwm/placement.c	27 May 2004 16:36:02 -0000
@@ -898,6 +898,20 @@
 	reason->pos.algo = placement_mode;
 	switch (placement_mode)
 	{
+	case PLACE_CENTER:
+		attr_g->x = (screen_g.width - fw->frame_g.width) / 2;
+		attr_g->y = ((screen_g.height - fw->frame_g.height) / 2) + fw->title_thickness;
+
+		/* Don't let the upper left corner be offscreen. */
+		if (attr_g->x < PageLeft)
+		{
+			attr_g->x = PageLeft;
+		}
+		if (attr_g->y < PageTop)
+		{
+			attr_g->y = PageTop;
+		}
+		break;
 	case PLACE_TILEMANUAL:
 		flags.is_smartly_placed = SmartPlacement(
 			fw, &screen_g, fw->frame_g.width, fw->frame_g.height,
@@ -1784,6 +1798,9 @@
 
 		switch (reason->pos.algo)
 		{
+		case PLACE_CENTER:
+			a = "Center";
+			break;
 		case PLACE_TILEMANUAL:
 			a = "TileManual";
 			break;
Index: fvwm/style.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/style.c,v
retrieving revision 1.225
diff -u -r1.225 style.c
--- fvwm/style.c	6 May 2004 12:08:55 -0000	1.225
+++ fvwm/style.c	27 May 2004 16:36:04 -0000
@@ -2096,7 +2096,13 @@
 		break;
 
 	case 'c':
-		if (StrEquals(token, "CascadePlacement"))
+		if (StrEquals(token, "CenterPlacement"))
+		{
+			ps->flags.placement_mode = PLACE_CENTER;
+			ps->flag_mask.placement_mode = PLACE_MASK;
+			ps->change_mask.placement_mode = PLACE_MASK;
+		}
+		else if (StrEquals(token, "CascadePlacement"))
 		{
 			ps->flags.placement_mode = PLACE_CASCADE;
 			ps->flag_mask.placement_mode = PLACE_MASK;
Index: sample.fvwmrc/system.fvwm2rc-sample-1
===================================================================
RCS file: /home/cvs/fvwm/fvwm/sample.fvwmrc/system.fvwm2rc-sample-1,v
retrieving revision 1.12
diff -u -r1.12 system.fvwm2rc-sample-1
--- sample.fvwmrc/system.fvwm2rc-sample-1	5 Aug 2001 12:12:24 -0000	1.12
+++ sample.fvwmrc/system.fvwm2rc-sample-1	27 May 2004 16:36:05 -0000
@@ -53,7 +53,7 @@
 Style "xman"	    Icon xman.xpm,TileCascadePlacement,ClickToFocus
 Style "xvgr"	    Icon graphs.xpm,TileCascadePlacement,ClickToFocus
 Style "matlab"	    Icon math4.xpm,ClickToFocus
-Style "xmag"	    Icon mag_glass.xpm,TileCascadePlacement, ClickToFocus
+Style "xmag"	    Icon mag_glass.xpm,CenterPlacement, ClickToFocus
 Style "xgraph"      Icon graphs.xpm,TileCascadePlacement,ClickToFocus
 Style "sppeed6"     Icon math3.xpm,NoTitle,ClickToFocus
 Style "sppeed6_user" Icon math4.xpm,NoTitle

---

From: Dan Espen <[email-masked]>
Date: Thu, 27 May 2004 13:40:46 -0400

Francis Litterio <[email-masked]> writes:
> --=-=-=

I'll take a close look at the patch, probably this weekend.
For the purify.fvm2rc, all that is needed is an invocation of
the command.  We run that file under a debugger that checks
for memory leaks and uninitialized variables.  No need to resubmit
for that, I'll take care of it.

I've been wondering if CenterPlacement isn't a special case of something
else, like "TopCenterPlacement" or "UpperRightCornerPlacement" but so far,
no useful insight has come to me so I think this is OK.

-- 
Dan Espen                           E-mail: [email-masked]
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]