summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-03-10 15:20:05 +0100
committerDanny Baumann <dannybaumann@web.de>2008-03-11 16:10:00 +0100
commitd7a7063a3dd3d7ce8837324a808afcaeef715988 (patch)
treed1d09b57a04215b84a2a4968435f1dbc08d4330a
parentf18a37666247f67a972f3ac81937fd674afc9d63 (diff)
Add another overlapping output handling mode "Smart". "Smart" basically is the old "Prefer larger" mode, selecting the output most part of the rectangle is on. "Prefer larger" and "Prefer smaller" only look for the rectangle center to determine the output.
-rw-r--r--include/compiz-core.h5
-rw-r--r--metadata/core.xml.in8
-rw-r--r--src/screen.c64
3 files changed, 52 insertions, 25 deletions
diff --git a/include/compiz-core.h b/include/compiz-core.h
index 7f2c4c51..7f317eb5 100644
--- a/include/compiz-core.h
+++ b/include/compiz-core.h
@@ -1741,8 +1741,9 @@ disableTexture (CompScreen *screen,
#define GLX_FRONT_LEFT_EXT 0x20DE
#endif
-#define OUTPUT_OVERLAP_MODE_PREFER_LARGER 0
-#define OUTPUT_OVERLAP_MODE_PREFER_SMALLER 1
+#define OUTPUT_OVERLAP_MODE_SMART 0
+#define OUTPUT_OVERLAP_MODE_PREFER_LARGER 1
+#define OUTPUT_OVERLAP_MODE_PREFER_SMALLER 2
#define OUTPUT_OVERLAP_MODE_LAST OUTPUT_OVERLAP_MODE_PREFER_SMALLER
typedef void (*FuncPtr) (void);
diff --git a/metadata/core.xml.in b/metadata/core.xml.in
index 0e4b258f..27c8c4fe 100644
--- a/metadata/core.xml.in
+++ b/metadata/core.xml.in
@@ -411,13 +411,17 @@
<_long>Which one of overlapping output devices should be preferred</_long>
<default>0</default>
<min>0</min>
- <max>1</max>
+ <max>2</max>
<desc>
<value>0</value>
- <_name>Prefer larger output</_name>
+ <_name>Smart mode</_name>
</desc>
<desc>
<value>1</value>
+ <_name>Prefer larger output</_name>
+ </desc>
+ <desc>
+ <value>2</value>
<_name>Prefer smaller output</_name>
</desc>
</option>
diff --git a/src/screen.c b/src/screen.c
index 90d9604a..1a915390 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -3978,25 +3978,47 @@ outputDeviceForGeometry (CompScreen *s,
int height,
int borderWidth)
{
- int overlapAreas[s->nOutputDev];
- int i, highest, seen, highestScore;
- BOX geomRect;
+ int overlapAreas[s->nOutputDev];
+ int i, highest, seen, highestScore;
+ int strategy;
+ BOX geomRect;
if (s->nOutputDev == 1)
return 0;
- geomRect.x2 = width + 2 * borderWidth;
- geomRect.y2 = height + 2 * borderWidth;
+ strategy = s->opt[COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS].value.i;
- geomRect.x1 = x % s->width;
- if ((geomRect.x1 + geomRect.x2 / 2) < 0)
- geomRect.x1 += s->width;
- geomRect.y1 = y % s->height;
- if ((geomRect.y1 + geomRect.y2 / 2) < 0)
- geomRect.y1 += s->height;
+ if (strategy == OUTPUT_OVERLAP_MODE_SMART)
+ {
+ /* 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)
+ geomRect.x1 += s->width;
+ geomRect.y1 = y % s->height;
+ if ((geomRect.y1 + geomRect.y2 / 2) < 0)
+ geomRect.y1 += s->height;
+
+ geomRect.x2 += geomRect.x1;
+ geomRect.y2 += geomRect.y1;
+ }
+ else
+ {
+ /* for biggest/smallest modes, only use the window center to determine
+ the correct output device */
+ geomRect.x1 = (x + (width / 2) + borderWidth) % s->width;
+ if (geomRect.x1 < 0)
+ geomRect.x1 += s->width;
+ geomRect.y1 = (y + (height / 2) + borderWidth) % s->height;
+ if (geomRect.y1 < 0)
+ geomRect.y1 += s->height;
- geomRect.x2 += geomRect.x1;
- geomRect.y2 += geomRect.y1;
+ geomRect.x2 = geomRect.x1 + 1;
+ geomRect.y2 = geomRect.y1 + 1;
+ }
/* get amount of overlap on all output devices */
for (i = 0; i < s->nOutputDev; i++)
@@ -4021,13 +4043,13 @@ outputDeviceForGeometry (CompScreen *s,
/* it's not unique, select one output of the matching ones and use the
user preferred strategy for that */
unsigned int currentSize, bestOutputSize;
- int strategy;
+ Bool searchLargest;
- strategy = s->opt[COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS].value.i;
- if (strategy == OUTPUT_OVERLAP_MODE_PREFER_SMALLER)
- bestOutputSize = UINT_MAX;
- else
+ searchLargest = (strategy != OUTPUT_OVERLAP_MODE_PREFER_SMALLER);
+ if (searchLargest)
bestOutputSize = 0;
+ else
+ bestOutputSize = UINT_MAX;
for (i = 0, highest = 0; i < s->nOutputDev; i++)
if (overlapAreas[i] == highestScore)
@@ -4037,10 +4059,10 @@ outputDeviceForGeometry (CompScreen *s,
currentSize = (box->x2 - box->x1) * (box->y2 - box->y1);
- if (strategy == OUTPUT_OVERLAP_MODE_PREFER_SMALLER)
- bestFit = (currentSize < bestOutputSize);
- else
+ if (searchLargest)
bestFit = (currentSize > bestOutputSize);
+ else
+ bestFit = (currentSize < bestOutputSize);
if (bestFit)
{