summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Gurgel Pinho <eduardo@mad4.Chagas>2008-11-23 18:40:31 -0300
committerEduardo Gurgel Pinho <eduardo@mad4.Chagas>2008-11-23 18:40:31 -0300
commitcbc910a5affa1bdfdb5e8066c5cfacd230f3a143 (patch)
tree094e016d38bf6631806b1e363c5ec683d2a946c6
parentaa0a20146e93e4a038ea9c2c5f7b9082d6a46b0f (diff)
downloadsmartput-cbc910a5affa1bdfdb5e8066c5cfacd230f3a143.tar.gz
smartput-cbc910a5affa1bdfdb5e8066c5cfacd230f3a143.tar.bz2
Functions to get Box from Window and Box from XRectangle
-rw-r--r--smartput.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/smartput.c b/smartput.c
index 69a60c6..9d744c3 100644
--- a/smartput.c
+++ b/smartput.c
@@ -330,6 +330,38 @@ smartputBox(CompWindow* w,
else
return ansB;
}
+/*
+ * Box defined from rectangle
+ */
+static BOX
+smartputBoxFromWindow (CompWindow *w)
+{
+ BOX windowBox;
+
+ windowBox.x1 = w->serverX;
+ windowBox.y1 = w->serverY;
+ windowBox.x2 = w->serverWidth;
+ windowBox.y2 = w->serverHeight;
+
+ return windowBox;
+}
+
+
+/*
+ * Box defined from rectangle
+ */
+static BOX
+smartputBoxFromRect (XRectangle rect)
+{
+ BOX rectBox;
+
+ rectBox.x1 = rect.x;
+ rectBox.y1 = rect.y;
+ rectBox.x2 = rect.x + rect.width;
+ rectBox.y2 = rect.y + rect.height;
+
+ return rectBox;
+}
/*
* Finding the best place to put the current window.
@@ -347,10 +379,7 @@ smartputFindRect (CompWindow *w,
tmpRect.width = w->serverWidth;
tmpRect.height = w->serverHeight;
- windowBox.x1 = tmpRect.x;
- windowBox.y1 = tmpRect.y;
- windowBox.x2 = tmpRect.x + tmpRect.width;
- windowBox.y2 = tmpRect.y + tmpRect.height;
+ windowBox = smartputBoxFromRect(tmpRect);
int currentArea = tmpRect.width*tmpRect.height;
@@ -363,10 +392,10 @@ smartputFindRect (CompWindow *w,
for (window = s->windows; window; window = window->next)
{
- BOX testBoxes[16];
+ BOX testBoxes[4];
smartputCreateBoxes(window,testBoxes);
int i;
- for(i = 0; i < 3; i++)
+ for(i = 0; i < 4; i++)
{
BOX testBox = testBoxes[i];
@@ -404,16 +433,13 @@ smartputFindRect (CompWindow *w,
static BOX
smartputFindStapleRect (CompWindow *w,
- Region r)
+ Region r)
{
BOX windowBox, maxBox;
CompWindow *window;
int maxArea, maxRate;
- windowBox.x1 = w->serverX;
- windowBox.y1 = w->serverY;
- windowBox.x2 = w->serverX + w->serverWidth ;
- windowBox.y2 = w->serverY + w->serverHeight;
+ windowBox = smartputBoxFromWindow (w);
maxArea = -1;
maxRate = 0;
@@ -421,10 +447,8 @@ smartputFindStapleRect (CompWindow *w,
for (window = w->screen->windows; window; window = window->next) {
BOX current;
- current.x1 = window->serverX;
- current.y1 = window->serverY;
- current.x2 = window->serverX + window->serverWidth;
- current.y2 = window->serverY + window->serverHeight;
+
+ current = smartputBoxFromWindow (window);
if (window->invisible || window->hidden || window->minimized)
continue;