Here is a patch for place plugin.

It add a "place_mode" option wich actually can have two values: "Cascade" 
(original placement mode) and "Centered".

Thanks for any comment!

Cedric
--- compiz_orig/plugins/place.c	2006-12-05 13:26:53.000000000 +0100
+++ compiz/plugins/place.c	2006-12-05 13:36:17.000000000 +0100
@@ -22,6 +22,7 @@
 
 #include <math.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <compiz.h>
 
@@ -29,6 +30,20 @@
 
 #define PLACE_WORKAROUND_DEFAULT TRUE
 
+typedef enum _PlaceMode
+{
+    PlaceModeCascade,
+    PlaceModeCentered,
+} PlaceMode;
+
+char *placeModes[] = {
+    N_("Cascade"),
+    N_("Centered")
+};
+
+#define PLACE_MODE_DEFAULT PlaceModeCascade
+#define NUM_PLACE_MODES 2
+
 static int displayPrivateIndex;
 
 typedef struct _PlaceDisplay {
@@ -37,12 +52,14 @@
 } PlaceDisplay;
 
 #define PLACE_SCREEN_OPTION_WORKAROUND 0
-#define PLACE_SCREEN_OPTION_NUM        1
+#define PLACE_SCREEN_OPTION_MODE       1
+#define PLACE_SCREEN_OPTION_NUM        2
 
 typedef struct _PlaceScreen {
     CompOption opt[PLACE_SCREEN_OPTION_NUM];
 
     DamageWindowRectProc damageWindowRect;
+    int placeMode;
 } PlaceScreen;
 
 #define GET_PLACE_DISPLAY(d)				      \
@@ -87,6 +104,14 @@
     case PLACE_SCREEN_OPTION_WORKAROUND:
 	if (compSetBoolOption (o, value))
 	    return TRUE;
+    case PLACE_SCREEN_OPTION_MODE:
+        if (compSetStringOption (o, value)) 
+	{
+            int i;
+            for (i = 0; i < o->rest.s.nString; i++)
+                if (strcmp (placeModes[i], o->value.s) == 0)
+                    ps->placeMode = (PlaceMode) i;
+	}
     default:
 	break;
     }
@@ -105,6 +130,16 @@
     o->longDesc	 = N_("Window placement workarounds");
     o->type	 = CompOptionTypeBool;
     o->value.b	 = PLACE_WORKAROUND_DEFAULT;
+
+    o = &ps->opt[PLACE_SCREEN_OPTION_MODE];
+    o->name = "place_mode";
+    o->shortDesc = N_("Place Mode");
+    o->longDesc =
+    N_("Select between Cascade or Centered placement");
+    o->type = CompOptionTypeString;
+    o->value.s = strdup (placeModes[PLACE_MODE_DEFAULT]);
+    o->rest.s.string = placeModes;
+    o->rest.s.nString = NUM_PLACE_MODES;
 }
 
 typedef enum {
@@ -554,7 +589,7 @@
 
     fluff = (work_area->width % (rect->width + 1)) / 2;
     rect->x = work_area->x + fluff;
-    fluff = (work_area->height % (rect->height + 1)) / 3;
+    fluff = (work_area->height % (rect->height + 1)) / 2;
     rect->y = work_area->y + fluff;
 }
 
@@ -692,6 +727,17 @@
 }
 
 static void
+placeCentered(CompWindow *window, 
+	      int *x, 
+	      int *y)
+{
+    *x = window->screen->workArea.x 
+	+ (window->screen->workArea.width - get_window_width (window)) / 2;
+    *y = window->screen->workArea.y 
+        + (window->screen->workArea.height - get_window_height (window)) / 2;
+}
+
+static void
 placeWindow (CompWindow *window,
 	     int        x,
 	     int        y,
@@ -916,13 +962,17 @@
     x = x0;
     y = y0;
 
-    if (find_first_fit (window, windows, x, y, &x, &y))
-	goto done_check_denied_focus;
-
-    /* if the window wasn't placed at the origin of screen,
-     * cascade it onto the current screen
-     */
-    find_next_cascade (window, windows, x, y, &x, &y);
+    if (ps->placeMode == PlaceModeCascade)
+    {
+        if (find_first_fit (window, windows, x, y, &x, &y))
+	    goto done_check_denied_focus;
+        /* if the window wasn't placed at the origin of screen,
+         * cascade it onto the current screen
+         */
+         find_next_cascade (window, windows, x, y, &x, &y);
+    }
+    else /* Centered Mode */
+         placeCentered(window, &x, &y);
 
     /* Maximize windows if they are too big for their work area (bit of
      * a hack here). Assume undecorated windows probably don't intend to
_______________________________________________
compiz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/compiz

Reply via email to