summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--put.c82
1 files changed, 46 insertions, 36 deletions
diff --git a/put.c b/put.c
index daf268f..9870cd3 100644
--- a/put.c
+++ b/put.c
@@ -43,6 +43,14 @@
GET_PUT_SCREEN (w->screen, \
GET_PUT_DISPLAY (w->screen->display)))
+#define TOP_BORDER(w) ((w)->input.top)
+#define LEFT_BORDER(w) ((w)->input.left)
+#define RIGHT_BORDER(w) ((w)->input.right + 2 * (w)->serverBorderWidth)
+#define BOTTOM_BORDER(w) ((w)->input.bottom + 2 * (w)->serverBorderWidth)
+
+#define HALF_WIDTH(w) ((w)->serverWidth / 2 + (w)->serverBorderWidth)
+#define HALF_HEIGHT(w) ((w)->serverHeight / 2 + (w)->serverBorderWidth)
+
static int displayPrivateIndex;
typedef enum
@@ -395,54 +403,56 @@ putGetDistance (CompWindow *w,
switch (type) {
case PutCenter:
/* center of the screen */
- dx = (workArea.width / 2) - (w->serverWidth / 2) - (x - workArea.x);
- dy = (workArea.height / 2) - (w->serverHeight / 2) - (y - workArea.y);
+ dx = (workArea.width / 2) - (w->serverWidth / 2) -
+ w->serverBorderWidth - (x - workArea.x);
+ dy = (workArea.height / 2) - (w->serverHeight / 2) -
+ w->serverBorderWidth - (y - workArea.y);
break;
case PutLeft:
/* center of the left edge */
- dx = -(x - workArea.x) + w->input.left + putGetPadLeft (s);
- dy = (workArea.height / 2) - (w->serverHeight / 2) - (y - workArea.y);
+ dx = -(x - workArea.x) + LEFT_BORDER (w) + putGetPadLeft (s);
+ dy = (workArea.height / 2) - HALF_HEIGHT (w) - (y - workArea.y);
break;
case PutTopLeft:
/* top left corner */
- dx = -(x - workArea.x) + w->input.left + putGetPadLeft (s);
- dy = -(y - workArea.y) + w->input.top + putGetPadTop (s);
+ dx = -(x - workArea.x) + LEFT_BORDER (w) + putGetPadLeft (s);
+ dy = -(y - workArea.y) + TOP_BORDER (w) + putGetPadTop (s);
break;
case PutTop:
/* center of top edge */
- dx = (workArea.width / 2) - (w->serverWidth / 2) - (x - workArea.x);
- dy = -(y - workArea.y) + w->input.top + putGetPadTop (s);
+ dx = (workArea.width / 2) - HALF_WIDTH (w) - (x - workArea.x);
+ dy = -(y - workArea.y) + TOP_BORDER (w) + putGetPadTop (s);
break;
case PutTopRight:
/* top right corner */
dx = workArea.width - w->serverWidth - (x - workArea.x) -
- w->input.right - putGetPadRight (s);
- dy = -(y - workArea.y) + w->input.top + putGetPadTop (s);
+ RIGHT_BORDER (w) - putGetPadRight (s);
+ dy = -(y - workArea.y) + TOP_BORDER (w) + putGetPadTop (s);
break;
case PutRight:
/* center of right edge */
dx = workArea.width - w->serverWidth - (x - workArea.x) -
- w->input.right - putGetPadRight (s);
- dy = (workArea.height / 2) - (w->serverHeight / 2) - (y - workArea.y);
+ RIGHT_BORDER (w) - putGetPadRight (s);
+ dy = (workArea.height / 2) - HALF_HEIGHT (w) - (y - workArea.y);
break;
case PutBottomRight:
/* bottom right corner */
dx = workArea.width - w->serverWidth - (x - workArea.x) -
- w->input.right - putGetPadRight (s);
+ RIGHT_BORDER (w) - putGetPadRight (s);
dy = workArea.height - w->serverHeight - (y - workArea.y) -
- w->input.bottom - putGetPadBottom (s);
+ BOTTOM_BORDER (w) - putGetPadBottom (s);
break;
case PutBottom:
/* center of bottom edge */
- dx = (workArea.width / 2) - (w->serverWidth / 2) - (x - workArea.x);
+ dx = (workArea.width / 2) - HALF_WIDTH (w) - (x - workArea.x);
dy = workArea.height - w->serverHeight - (y - workArea.y) -
- w->input.bottom - putGetPadBottom (s);
+ BOTTOM_BORDER (w) - putGetPadBottom (s);
break;
case PutBottomLeft:
/* bottom left corner */
- dx = -(x - workArea.x) + w->input.left + putGetPadLeft (s);
+ dx = -(x - workArea.x) + LEFT_BORDER (w) + putGetPadLeft (s);
dy = workArea.height - w->serverHeight - (y - workArea.y) -
- w->input.bottom - putGetPadBottom (s);
+ BOTTOM_BORDER (w) - putGetPadBottom (s);
break;
case PutRestore:
/* back to last position */
@@ -538,16 +548,16 @@ putGetDistance (CompWindow *w,
if (posX < 0)
/* account for a specified negative position,
like geometry without (-0) */
- dx = posX + s->width - w->serverWidth - x - w->input.right;
+ dx = posX + s->width - w->serverWidth - x - RIGHT_BORDER (w);
else
- dx = posX - x + w->input.left;
+ dx = posX - x + LEFT_BORDER (w);
if (posY < 0)
/* account for a specified negative position,
like geometry without (-0) */
- dy = posY + s->height - w->height - y - w->input.bottom;
+ dy = posY + s->height - w->serverHeight - y - BOTTOM_BORDER (w);
else
- dy = posY - y + w->input.top;
+ dy = posY - y + TOP_BORDER (w);
break;
case PutRelative:
/* move window by offset */
@@ -572,35 +582,35 @@ putGetDistance (CompWindow *w,
if (putGetWindowCenter (s))
{
/* window center */
- dx = rx - (w->serverWidth / 2) - x;
- dy = ry - (w->serverHeight / 2) - y;
+ dx = rx - HALF_WIDTH (w) - x;
+ dy = ry - HALF_HEIGHT (w) - y;
}
else if (rx < s->workArea.width / 2 &&
ry < s->workArea.height / 2)
{
/* top left quad */
- dx = rx - x + w->input.left;
- dy = ry - y + w->input.top;
+ dx = rx - x + LEFT_BORDER (w);
+ dy = ry - y + TOP_BORDER (w);
}
else if (rx < s->workArea.width / 2 &&
ry >= s->workArea.height / 2)
{
/* bottom left quad */
- dx = rx - x + w->input.left;
- dy = ry - w->height - y - w->input.bottom;
+ dx = rx - x + LEFT_BORDER (w);
+ dy = ry - w->serverHeight - y - BOTTOM_BORDER (w);
}
else if (rx >= s->workArea.width / 2 &&
ry < s->workArea.height / 2)
{
/* top right quad */
- dx = rx - w->width - x - w->input.right;
- dy = ry - y + w->input.top;
+ dx = rx - w->serverWidth - x - RIGHT_BORDER (w);
+ dy = ry - y + TOP_BORDER (w);
}
else
{
/* bottom right quad */
- dx = rx - w->width - x - w->input.right;
- dy = ry - w->height - y - w->input.bottom;
+ dx = rx - w->serverWidth - x - RIGHT_BORDER (w);
+ dy = ry - w->serverHeight - y - BOTTOM_BORDER (w);
}
}
else
@@ -627,10 +637,10 @@ putGetDistance (CompWindow *w,
inDx = dxBefore = dx % s->width;
inDy = dyBefore = dy % s->height;
- extents.left = x + inDx - w->input.left;
- extents.top = y + inDy - w->input.top;
- extents.right = x + inDx + w->serverWidth + w->input.right;
- extents.bottom = y + inDy + w->serverHeight + w->input.bottom;
+ extents.left = x + inDx - LEFT_BORDER (w);
+ extents.top = y + inDy - TOP_BORDER (w);
+ extents.right = x + inDx + w->serverWidth + RIGHT_BORDER (w);
+ extents.bottom = y + inDy + w->serverHeight + BOTTOM_BORDER (w);
area.left = workArea.x + putGetPadLeft (s);
area.top = workArea.y + putGetPadTop (s);