diff options
-rw-r--r-- | beryl-plugins/src/place.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/beryl-plugins/src/place.c b/beryl-plugins/src/place.c index 6cc93c4..48c6393 100644 --- a/beryl-plugins/src/place.c +++ b/beryl-plugins/src/place.c @@ -29,6 +29,7 @@ #include <glib.h> #define PLACE_WORKAROUND_DEFAULT TRUE +#define RECTANGLE_FROM_WINDOW(w) {w->attrib.x,w->attrib.y,w->attrib.width,w->attrib.height} static int displayPrivateIndex; @@ -272,27 +273,32 @@ static void placeRandom(CompWindow *window, int *x, int *y){ static void placeIntelligent(CompWindow *window, int *xo, int *yo){ int x = 0; int y = 0; - int x_optimal, y_optimal; - int xloc=window->attrib.x; int yloc=window->attrib.y; int height=window->attrib.height; int width=window->attrib.width; int tr=xloc+width; - int overlaps = 0; + XRectangle windowRec = RECTANGLE_FROM_WINDOW(window); + + Bool overlaps = FALSE; for (x = 0; x < window->screen->workArea.width; x++){ - overlaps=0; + overlaps=FALSE; for (y = 0; y < window->screen->workArea.height;y++){ CompScreen *l=window->screen->windows; while (l){ - if (((xloc + width/2) < (l->attrib.x + l->attrib.width + width) && (xloc>l->attrib.x)) || (tr + width/2) < (l->attrib.x + l->attrib.width + width) && (tr>l->attrib.x)){ - overlaps=1; - } else if (yloc < (l->attrib.y) && yloc > (l->attrib.y - l->attrib.height)) { - overlaps=1; + XRectangle dest; + XRectangle temp = RECTANGLE_FROM_WINDOW(l); + if (rectangleIntersect(&windowRec,&temp,&dest)){ + overlaps=TRUE; + } + + } - l++; + } + if (overlaps) {break;} } - if (overlaps){break;} + *xo=x; *yo=y; } -} + + static void find_next_cascade(CompWindow * window, |