This is the first time I've ever submitted a patch to FVWM, so if I've
missed something, please let me know.

The below patch to the CVS sources adds a new style, CenterPlacement.
This style causes FVWM to place new windows in the center of the screen
if they do not request a position using window manager hints or a
geometry specification.

Example usage:

        Style * CenterPlacement

The patch includes an update to the man page describing the new style.

I hope people find this useful.  I was motivated to code this patch
because my previous method for getting new windows to appear in the
center of the screen was to use FvwmEvent's add_window command, but that
requires that the window appear first before it is moved to the center
of the screen, which is too jumpy visually.
--
Francis Litterio
[EMAIL PROTECTED]
http://world.std.com/~franl/
GPG and PGP public keys available on keyservers.


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      16 May 2004 21:29:50 -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 ,
@@ -7294,6 +7294,9 @@
 for the window.  Fvwm knows six ways to deal with this
 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 16 May 2004 21:29:55 -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.134
diff -u -r1.134 placement.c
--- fvwm/placement.c    17 Mar 2004 16:57:50 -0000      1.134
+++ fvwm/placement.c    16 May 2004 21:30:04 -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,
@@ -1785,6 +1799,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        16 May 2004 21:30:28 -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;

--
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 PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to