summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-09-24 15:03:59 +0200
committerDanny Baumann <dannybaumann@web.de>2008-09-25 09:36:37 +0200
commit98bdf75f332f04b670d36758e655eac8fa304f8d (patch)
tree7282584155c7e4e81fcac6b4fda456f16ceedf4f
parent703ff5ff3238febc98a3b8ed9a774d8223848962 (diff)
Make sure geometry rectangle is kept inside the screen area.
-rw-r--r--src/screen.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/screen.c b/src/screen.c
index df7bd18d..7d051b3e 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -4103,17 +4103,26 @@ outputDeviceForGeometry (CompScreen *s,
if (strategy == OUTPUT_OVERLAP_MODE_SMART)
{
+ int centerX, centerY;
+
/* for smart mode, calculate the overlap of the whole rectangle
with the output device rectangle */
geomRect.x2 = width + 2 * borderWidth;
geomRect.y2 = height + 2 * borderWidth;
geomRect.x1 = x % s->width;
- if ((geomRect.x1 + geomRect.x2 / 2) < 0)
+ centerX = geomRect.x1 + (geomRect.x2 / 2);
+ if (centerX < 0)
geomRect.x1 += s->width;
+ else if (centerX > s->width)
+ geomRect.x1 -= s->width;
+
geomRect.y1 = y % s->height;
- if ((geomRect.y1 + geomRect.y2 / 2) < 0)
+ centerY = geomRect.y1 + (geomRect.y2 / 2);
+ if (centerY < 0)
geomRect.y1 += s->height;
+ else if (centerY > s->height)
+ geomRect.y1 -= s->height;
geomRect.x2 += geomRect.x1;
geomRect.y2 += geomRect.y1;