summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/place.c
diff options
context:
space:
mode:
authorracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-17 06:28:21 +0000
committerracarr <racarr@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-12-17 06:28:21 +0000
commitab94774ba92cc067e3bcb022f4d289f74b7e15cd (patch)
treefa06ea030056d684ecf71bc21ef11e9a51654136 /beryl-plugins/src/place.c
parent0008397f945e20a03258bf137751613fe4fafa15 (diff)
downloadmarex-dev-ab94774ba92cc067e3bcb022f4d289f74b7e15cd.tar.gz
marex-dev-ab94774ba92cc067e3bcb022f4d289f74b7e15cd.tar.bz2
Better placement
git-svn-id: file:///beryl/trunk@1817 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/place.c')
-rw-r--r--beryl-plugins/src/place.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/beryl-plugins/src/place.c b/beryl-plugins/src/place.c
index e86ef71..a02744a 100644
--- a/beryl-plugins/src/place.c
+++ b/beryl-plugins/src/place.c
@@ -61,7 +61,7 @@ typedef enum _PlaceMode{
char *placeModes[] = { N_("Cascade"),N_("Centered"),N_("Random"),N_("Intelligent") };
-#define PLACE_MODE_DEFAULT PlaceModeCascade
+#define PLACE_MODE_DEFAULT PlaceModeIntelligent
#define NUM_PLACE_MODES 4
#define GET_PLACE_DISPLAY(d) \
@@ -260,24 +260,10 @@ static void placeRandom(CompWindow *window, int *x, int *y){
-static void placeIntelligent(CompWindow *w, int *x, int *y){
- static int xi,yi,max;
- *x=xi + (rand() % 10);
- *y=yi + (rand() % 10);
- yi+=w->attrib.height;
-
- if (w->attrib.width > max){
- max=w->attrib.width;
- }
- if (yi > w->screen->workArea.height) {
- yi=0;
- xi+=max;
- max=0;
- }
-}
+
static void
find_next_cascade(CompWindow * window,
@@ -558,6 +544,33 @@ rectangle_overlaps_some_window(XRectangle * rect, GList * windows)
return FALSE;
}
+static void placeIntelligent(CompWindow *w, int *x, int *y, GList *windows){
+
+ XRectangle wRect = RECTANGLE_FROM_WINDOW(w);
+ XRectangle sRect = {0,0,0,0};
+
+ CompScreen *screen = w->screen;
+
+ get_workarea_of_current_output_device(screen,&sRect);
+
+ CompWindow *l;
+ int xi; int yi;
+
+ for (xi = 0; xi < (sRect.width-sRect.x); xi+=10){
+ wRect.x=xi;
+ for (yi = 0 ; yi < (sRect.height-sRect.y); yi+=10 ){
+ wRect.y=yi;
+
+ if (! rectangle_overlaps_some_window(&wRect,windows) ){
+ *x=xi;
+ *y=yi;
+ return;
+ }
+ }
+ }
+ placeRandom(w,x,y);
+ }
+
static gint leftmost_cmp(gconstpointer a, gconstpointer b)
{
CompWindow *aw = (gpointer) a;
@@ -985,7 +998,7 @@ placeWindow(CompWindow * window, int x, int y, int *new_x, int *new_y)
} else if (ps->placeMode == PlaceModeRandom) {
placeRandom(window, &x, &y);
} else {
- placeIntelligent(window, &x, &y);
+ placeIntelligent(window, &x, &y,windows);
}